Add quick actions buttons to create an accepted or rejected review

This commit is contained in:
Sebastian Martinez
2025-02-07 14:55:26 +01:00
parent 263037d0a7
commit 4ff909c7e9
3 changed files with 34 additions and 6 deletions
+6
View File
@@ -98,12 +98,18 @@
--color-fill-primary-hover: #ff4dff;
--color-fill-primary-shade: #e500e5;
--color-fill-danger: #aa5078;
--color-fill-danger-hover: #be7495;
--color-fill-danger-shade: #8b3e5e;
--color-fill-danger-counter: #ce97af;
--color-fill-yellow: #ffe609;
--color-fill-yellow-iconic: #ffff55;
--color-fill-gray: #9b9bb1;
--color-fill-diff-red: #4d1929;
--color-fill-diff-red-light: #2d060d;
--color-fill-success: #4fa877;
--color-fill-success-hover: #71bc93;
--color-fill-success-shade: #408760;
--color-fill-success-counter: #97ceb0;
--color-fill-diff-green: #183425;
--color-fill-diff-green-light: #142a1d;
--color-fill-float: #14151a;
+1 -1
View File
@@ -3,7 +3,7 @@
interface Props {
children: Snippet;
variant: "primary" | "secondary" | "ghost";
variant: "primary" | "secondary" | "ghost" | "success" | "danger";
onclick?: () => void;
disabled?: boolean;
active?: boolean;
+27 -5
View File
@@ -6,6 +6,7 @@
import type { Embed } from "@bindings/cob/thread/Embed";
import type { Revision } from "@bindings/cob/patch/Revision";
import type { Thread } from "@bindings/cob/thread/Thread";
import type { Verdict } from "@bindings/cob/patch/Verdict";
import partial from "lodash/partial";
import { tick } from "svelte";
@@ -20,6 +21,7 @@
scrollIntoView,
} from "@app/lib/utils";
import Button from "@app/components/Button.svelte";
import Changeset from "@app/components/Changeset.svelte";
import CobCommitTeaser from "./CobCommitTeaser.svelte";
import CommentComponent from "@app/components/Comment.svelte";
@@ -141,7 +143,7 @@
}
}
async function createReview() {
async function createReview(verdict?: Verdict) {
try {
await invoke("edit_patch", {
rid: rid,
@@ -149,6 +151,7 @@
action: {
type: "review",
revision: revision.id,
verdict,
// We need to pass an empty string to create a review without a verdict.
summary: "",
labels: [],
@@ -417,10 +420,29 @@
<div class="txt-semibold global-flex txt-regular">Reviews</div>
</NakedButton>
</div>
<NakedButton variant="ghost" disabled={hasOwnReview} onclick={createReview}>
<Icon name="plus" />
<span class="txt-small">New Review</span>
</NakedButton>
<div class="global-flex">
<Button
variant="success"
disabled={hasOwnReview}
onclick={() => createReview("accept")}>
<Icon name="comment-checkmark" />
<span class="txt-small">Accept</span>
</Button>
<Button
variant="danger"
disabled={hasOwnReview}
onclick={() => createReview("reject")}>
<Icon name="comment-cross" />
<span class="txt-small">Reject</span>
</Button>
<Button
variant="secondary"
disabled={hasOwnReview}
onclick={() => createReview()}>
<Icon name="plus" />
<span class="txt-small">New Review</span>
</Button>
</div>
</div>
{#if revision.reviews && revision.reviews.length}