Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: implement issue review rejection (#6595)

Liu Jie2d6efe52b8f
diff --git a/frontend/src/bbkit/BBAvatar.vue b/frontend/src/bbkit/BBAvatar.vue
index 269149ba06..63e009d190 100644
--- a/frontend/src/bbkit/BBAvatar.vue
+++ b/frontend/src/bbkit/BBAvatar.vue
@@ -15,6 +15,7 @@
import { computed, withDefaults } from "vue";
import { hashCode } from "./BBUtil";
import { BBAvatarSizeType } from "./types";
+import { VueClass } from "@/utils";
const BACKGROUND_COLOR_LIST: string[] = [
"#64748B",
@@ -55,12 +56,16 @@ const props = withDefaults(
size: BBAvatarSizeType;
rounded?: boolean;
backgroundColor?: string;
+ overrideClass?: VueClass;
+ overrideTextSize?: string;
}>(),
{
username: "",
size: "NORMAL",
rounded: true,
backgroundColor: "",
+ overrideClass: undefined,
+ overrideTextSize: undefined,
}
);
@@ -102,11 +107,11 @@ const style = computed(() => {
borderRadius: props.rounded ? "50%" : 0,
backgroundColor: backgroundColor.value,
color: "white",
- "font-size": fontStyleClassMap.get(props.size),
+ "font-size": props.overrideTextSize ?? fontStyleClassMap.get(props.size),
};
});
const textClass = computed(() => {
- return sizeClassMap.get(props.size);
+ return props.overrideClass ?? sizeClassMap.get(props.size);
});
</script>
diff --git a/frontend/src/components/Issue/IssueBanner.vue b/frontend/src/components/Issue/IssueBanner.vue
index 99d7eb1b02..b63095ca53 100644
--- a/frontend/src/components/Issue/IssueBanner.vue
+++ b/frontend/src/components/Issue/IssueBanner.vue
@@ -6,6 +6,13 @@
{{ $t("issue.waiting-for-review") }}
</div>
</template>
+ <template v-else-if="showRejectedReview">
+ <div
+ class="h-8 w-full text-base font-medium bg-warning text-white flex justify-center items-center"
+ >
+ {{ $t("issue.review-sent-back") }}
+ </div>
+ </template>
<template v-else>
<div
v-if="showCancelBanner"
@@ -44,6 +51,7 @@ import { Issue } from "@/types";
import { activeTask, isDatabaseRelatedIssueType } from "@/utils";
import { useIssueLogic } from "./logic";
import { useIssueReviewContext } from "@/plugins/issue/logic/review/context";
+import { Review_Approver_Status } from "@/types/proto/v1/review_service";
const issueContext = useIssueLogic();
const issue = issueContext.issue as Ref<Issue>;
@@ -52,7 +60,13 @@ const reviewContext = useIssueReviewContext();
const showPendingReview = computed(() => {
if (issueContext.create.value) return false;
if (issue.value.status !== "OPEN") return false;
- return !reviewContext.done.value;
+ return reviewContext.status.value === Review_Approver_Status.PENDING;
+});
+
+const showRejectedReview = computed(() => {
+ if (issueContext.create.value) return false;
+ if (issue.value.status !== "OPEN") return false;
+ return reviewContext.status.value === Review_Approver_Status.REJECTED;
});
const showCancelBanner = computed(() => {
@@ -69,7 +83,7 @@ const showPendingRollout = computed(() => {
return false;
}
- const task = activeTask(issue.value.pipeline);
+ const task = activeTask(issue.value.pipeline!);
return task.status == "PENDING_APPROVAL";
});
@@ -79,7 +93,7 @@ const showEarliestAllowedTimeBanner = computed(() => {
return false;
}
- const task = activeTask(issue.value.pipeline);
+ const task = activeTask(issue.value.pipeline!);
if (task.status !== "PENDING") {
return false;
@@ -90,7 +104,7 @@ const showEarliestAllowedTimeBanner = computed(() => {
});
const earliestAllowedTime = computed(() => {
- const task = activeTask(issue.value.pipeline);
+ const task = activeTask(issue.value.pipeline!);
const tz = "UTC" + dayjs().format("ZZ");
return dayjs(task.earliestAllowedTs * 1000).format(
`YYYY-MM-DD HH:mm:ss ${tz}`
diff --git a/frontend/src/components/Issue/activity/ActionIcon.vue b/frontend/src/components/Issue/activity/ActionIcon.vue
index 1fbdf9e01f..e716545cce 100644
--- a/frontend/src/components/Issue/activity/ActionIcon.vue
+++ b/frontend/src/components/Issue/activity/ActionIcon.vue
@@ -4,14 +4,18 @@
<div
class="w-7 h-7 bg-control-bg rounded-full ring-4 ring-white flex items-center justify-center"
>
- <img class="mt-1" src="../../../assets/logo-icon.svg" alt="Bytebase" />
+ <img class="mt-1" src="@/assets/logo-icon.svg" alt="Bytebase" />
</div>
</div>
<div v-else-if="icon == 'avatar'" class="relative pl-0.5">
<div
class="w-7 h-7 bg-white rounded-full ring-4 ring-white flex items-center justify-center"
>
- <PrincipalAvatar :principal="activity.creator" :size="'SMALL'" />
+ <PrincipalAvatar
+ :principal="activity.creator"
+ override-class="w-7 h-7 font-medium"
+ override-text-size="0.8rem"
+ />
</div>
</div>
<div v-else-if="icon == 'create'" class="relative pl-0.5">
@@ -35,13 +39,31 @@
<heroicons-outline:play class="w-6 h-6 text-control" />
</div>
</div>
- <div v-else-if="icon == 'approve'" class="relative pl-0.5">
+ <div v-else-if="icon == 'approve-review'" class="relative pl-0.5">
<div
class="w-7 h-7 bg-control-bg rounded-full ring-4 ring-white flex items-center justify-center"
>
<heroicons-outline:thumb-up class="w-5 h-5 text-control" />
</div>
</div>
+ <div v-else-if="icon == 'reject-review'" class="relative pl-0.5">
+ <div
+ class="w-7 h-7 bg-warning rounded-full ring-4 ring-white flex items-center justify-center"
+ >
+ <heroicons:pause-solid class="w-5 h-5 text-white" />
+ </div>
+ </div>
+ <div v-else-if="icon == 're-request-review'" class="relative pl-0.5">
+ <div
+ class="w-7 h-7 bg-white rounded-full ring-4 ring-white flex items-center justify-center"
+ >
+ <PrincipalAvatar
+ :principal="activity.creator"
+ override-class="w-7 h-7 font-medium"
+ override-text-size="0.8rem"
+ />
+ </div>
+ </div>
<div v-else-if="icon == 'cancel'" class="relative pl-0.5">
<div
class="w-7 h-7 bg-control-bg rounded-full ring-4 ring-white flex items-center justify-center"
@@ -89,6 +111,7 @@ import {
ActivityTaskStatusUpdatePayload,
SYSTEM_BOT_ID,
} from "@/types";
+import PrincipalAvatar from "@/components/PrincipalAvatar.vue";
import { SkipIcon } from "@/components/Icon";
type ActionIconType =
@@ -97,7 +120,9 @@ type ActionIconType =
| "create"
| "update"
| "run"
- | "approve"
+ | "approve-review"
+ | "reject-review"
+ | "re-request-review"
| "rollout"
| "cancel"
| "fail"
@@ -166,8 +191,16 @@ const icon = computed((): ActionIconType => {
return "update";
} else if (activity.type === "bb.issue.comment.create") {
const payload = activity.payload as ActivityIssueCommentCreatePayload;
- if (payload.approvalEvent?.status === "APPROVED") {
- return "approve";
+ if (payload.approvalEvent) {
+ const { status } = payload.approvalEvent;
+ switch (status) {
+ case "APPROVED":
+ return "approve-review";
+ case "REJECTED":
+ return "reject-review";
+ case "PENDING":
+ return "re-request-review";
+ }
}
}
diff --git a/frontend/src/components/Issue/activity/ActionSentence.vue b/frontend/src/components/Issue/activity/ActionSentence.vue
index 76e006f1dc..00bae90e83 100644
--- a/frontend/src/components/Issue/activity/ActionSentence.vue
+++ b/frontend/src/components/Issue/activity/ActionSentence.vue
@@ -69,12 +69,19 @@ const renderActionSentence = () => {
);
}
}
- if (payload.approvalEvent?.status === "APPROVED") {
- const verb = maybeAutomaticallyVerb(
- activity,
- t("custom-approval.issue-review.approved-issue")
- );
- return renderSpan(verb);
+ if (payload.approvalEvent) {
+ if (payload.approvalEvent) {
+ const { status } = payload.approvalEvent;
+ const dict: Record<typeof status, string> = {
+ APPROVED: t("custom-approval.issue-review.approved-issue"),
+ REJECTED: t("custom-approval.issue-review.sent-back-issue"),
+ PENDING: t("custom-approval.issue-review.re-requested-review"),
+ };
+ const verb = dict[status];
+ if (verb) {
+ return renderSpan(maybeAutomaticallyVerb(activity, verb));
+ }
+ }
}
}
diff --git a/frontend/src/components/Issue/review/ApprovalTimeline.vue b/frontend/src/components/Issue/review/ApprovalTimeline.vue
index 56e3d5bdd9..99dabd0d99 100644
--- a/frontend/src/components/Issue/review/ApprovalTimeline.vue
+++ b/frontend/src/components/Issue/review/ApprovalTimeline.vue
@@ -7,7 +7,11 @@
:class="iconClass(step)"
>
<heroicons-outline:thumb-up
- v-if="step.status === 'DONE'"
+ v-if="step.status === 'APPROVED'"
+ class="w-3.5 h-3.5 text-white"
+ />
+ <heroicons:pause-solid
+ v-else-if="step.status === 'REJECTED'"
class="w-3.5 h-3.5 text-white"
/>
<heroicons-outline:user
@@ -27,7 +31,7 @@
<div class="mr-1.5 shrink-0">:</div>
<div class="flex-1 overflow-hidden">
<NEllipsis
- v-if="step.status === 'DONE'"
+ v-if="step.status === 'APPROVED'"
class="inline-block"
:class="step.approver?.name === currentUser.name && 'font-bold'"
>
@@ -69,7 +73,8 @@ const { currentUser } = storeToRefs(useAuthStore());
const iconClass = (step: WrappedReviewStep) => {
const { status } = step;
return [
- status === "DONE" && "bg-success",
+ status === "APPROVED" && "bg-success",
+ status === "REJECTED" && "bg-warning",
status === "CURRENT" && "bg-white border-[2px] border-info text-accent",
status === "PENDING" && "bg-white border-[3px] border-gray-300",
];
@@ -78,7 +83,8 @@ const iconClass = (step: WrappedReviewStep) => {
const itemClass = (step: WrappedReviewStep) => {
const { status } = step;
return [
- status === "DONE" && "text-control-light",
+ status === "APPROVED" && "text-control-light",
+ status === "REJECTED" && "text-control-light",
status === "CURRENT" && "text-accent",
status === "PENDING" && "text-control-placeholder",
];
diff --git a/frontend/src/components/Issue/review/IssueReviewButtonGroup.vue b/frontend/src/components/Issue/review/IssueReviewButtonGroup.vue
index 3abda8321d..a29aab2495 100644
--- a/frontend/src/components/Issue/review/IssueReviewButtonGroup.vue
+++ b/frontend/src/components/Issue/review/IssueReviewButtonGroup.vue
@@ -1,14 +1,22 @@
<template>
- <div class="flex items-stretch gap-x-2">
+ <div class="flex items-stretch gap-x-4">
+ <button
+ v-if="allowReject"
+ class="btn-normal"
+ @click="showModal(Review_Approver_Status.REJECTED)"
+ >
+ {{ $t("custom-approval.issue-review.send-back") }}
+ </button>
+
<BBTooltipButton
- v-if="showApproveButton"
+ v-if="allowApprove"
:disabled="disallowApproveReasonList.length > 0"
:tooltip-props="{
placement: 'bottom-end',
}"
type="primary"
tooltip-mode="DISABLED-ONLY"
- @click="state.modal = true"
+ @click="showModal(Review_Approver_Status.APPROVED)"
>
{{ $t("common.approve") }}
@@ -21,17 +29,29 @@
</template>
</BBTooltipButton>
+ <button
+ v-if="allowReRequestReview"
+ class="btn-primary"
+ @click="showModal(Review_Approver_Status.PENDING)"
+ >
+ {{ $t("custom-approval.issue-review.re-request-review") }}
+ </button>
+
<StandaloneIssueStatusTransitionButtonGroup
- :display-mode="showApproveButton ? 'DROPDOWN' : 'BUTTON'"
+ :display-mode="
+ allowApprove || allowReject || allowReRequestReview
+ ? 'DROPDOWN'
+ : 'BUTTON'
+ "
/>
</div>
<BBModal
v-if="state.modal"
- :title="$t('custom-approval.issue-review.approve-issue')"
+ :title="state.modal.title"
class="relative overflow-hidden !w-[30rem] !max-w-[30rem]"
header-class="overflow-hidden"
- @close="state.modal = false"
+ @close="state.modal = undefined"
>
<div
v-if="state.loading"
@@ -40,8 +60,11 @@
<BBSpin />
</div>
<IssueReviewForm
- @cancel="state.modal = false"
- @confirm="handleConfirmApprove"
+ :status="state.modal.status"
+ :ok-text="state.modal.okText"
+ :button-style="state.modal.buttonStyle"
+ @cancel="state.modal = undefined"
+ @confirm="handleModalConfirm"
/>
</BBModal>
</template>
@@ -59,17 +82,23 @@ import { Issue } from "@/types";
import { BBTooltipButton } from "@/bbkit";
import { useIssueLogic } from "../logic";
import IssueReviewForm from "./IssueReviewForm.vue";
-import { taskCheckRunSummary } from "@/utils";
+import { extractUserUID, taskCheckRunSummary } from "@/utils";
import { useI18n } from "vue-i18n";
import { StandaloneIssueStatusTransitionButtonGroup } from "../StatusTransitionButtonGroup";
+import { Review_Approver_Status } from "@/types/proto/v1/review_service";
type LocalState = {
- modal: boolean;
+ modal?: {
+ title: string;
+ status: Review_Approver_Status;
+ okText: string;
+ buttonStyle: "PRIMARY" | "ERROR" | "NORMAL";
+ };
loading: boolean;
};
const state = reactive<LocalState>({
- modal: false,
+ modal: undefined,
loading: false,
});
@@ -78,9 +107,9 @@ const store = useReviewStore();
const currentUserV1 = useCurrentUserV1();
const issueContext = useIssueLogic();
const issue = issueContext.issue as Ref<Issue>;
-const { flow, ready, done } = useIssueReviewContext();
+const { flow, ready, status, done } = useIssueReviewContext();
-const showApproveButton = computed(() => {
+const allowApproveOrReject = computed(() => {
if (issue.value.status === "CANCELED" || issue.value.status === "DONE") {
return false;
}
@@ -96,6 +125,24 @@ const showApproveButton = computed(() => {
return candidates.includes(currentUserV1.value.name);
});
+const allowApprove = computed(() => {
+ if (!allowApproveOrReject.value) return false;
+
+ return status.value === Review_Approver_Status.PENDING;
+});
+const allowReject = computed(() => {
+ if (!allowApproveOrReject.value) return false;
+ return status.value === Review_Approver_Status.PENDING;
+});
+
+const allowReRequestReview = computed(() => {
+ return (
+ String(issue.value.creator.id) ===
+ extractUserUID(currentUserV1.value.name) &&
+ status.value === Review_Approver_Status.REJECTED
+ );
+});
+
const allTaskChecksPassed = computed(() => {
const taskList =
issue.value.pipeline?.stageList.flatMap((stage) => stage.taskList) ?? [];
@@ -117,12 +164,54 @@ const disallowApproveReasonList = computed((): string[] => {
return reasons;
});
-const handleConfirmApprove = async (onSuccess: () => void) => {
+const showModal = (status: Review_Approver_Status) => {
+ state.modal = {
+ status,
+ title: "",
+ okText: "",
+ buttonStyle: "NORMAL",
+ };
+ switch (status) {
+ case Review_Approver_Status.APPROVED:
+ state.modal.title = t("custom-approval.issue-review.approve-issue");
+ state.modal.okText = t("common.approval");
+ state.modal.buttonStyle = "PRIMARY";
+ break;
+ case Review_Approver_Status.REJECTED:
+ state.modal.title = t("custom-approval.issue-review.send-back-issue");
+ state.modal.okText = t("custom-approval.issue-review.send-back");
+ state.modal.buttonStyle = "ERROR";
+ break;
+ case Review_Approver_Status.PENDING:
+ state.modal.title = t(
+ "custom-approval.issue-review.re-request-review-issue"
+ );
+ state.modal.okText = t("custom-approval.issue-review.re-request-review");
+ state.modal.buttonStyle = "PRIMARY";
+ }
+};
+
+const handleModalConfirm = async (
+ {
+ status,
+ comment,
+ }: {
+ status: Review_Approver_Status;
+ comment?: string;
+ },
+ onSuccess: () => void
+) => {
state.loading = true;
try {
- await store.approveReview(issue.value);
- onSuccess();
- state.modal = false;
+ if (status === Review_Approver_Status.APPROVED) {
+ await store.approveReview(issue.value, comment);
+ onSuccess();
+ } else if (status === Review_Approver_Status.PENDING) {
+ await store.requestReview(issue.value, comment);
+ } else if (status === Review_Approver_Status.REJECTED) {
+ await store.rejectReview(issue.value, comment);
+ }
+ state.modal = undefined;
// notify the issue logic to update issue status
issueContext.onStatusChanged(true);
diff --git a/frontend/src/components/Issue/review/IssueReviewForm.vue b/frontend/src/components/Issue/review/IssueReviewForm.vue
index e9def283f7..b10175618b 100644
--- a/frontend/src/components/Issue/review/IssueReviewForm.vue
+++ b/frontend/src/components/Issue/review/IssueReviewForm.vue
@@ -1,38 +1,77 @@
<template>
- <div class="mt-2">
+ <div class="mt-2 flex flex-col gap-y-4">
<div class="text-sm">
{{ issue.name }}
</div>
- <div class="pt-4 pb-1 flex justify-end gap-x-3">
+ <div class="flex flex-col gap-y-1">
+ <p class="textlabel">
+ {{ $t("common.comment") }}
+ </p>
+ <AutoHeightTextarea
+ v-model:value="comment"
+ :placeholder="$t('issue.leave-a-comment')"
+ :max-height="160"
+ class="w-full"
+ />
+ </div>
+ <div class="py-1 flex justify-end gap-x-3">
<button class="btn-normal" @click="$emit('cancel')">
{{ $t("common.cancel") }}
</button>
- <button class="btn-primary" @click="handleConfirm">
- {{ $t("common.approve") }}
+ <button
+ :class="
+ buttonStyle === 'PRIMARY'
+ ? 'btn-primary'
+ : buttonStyle === 'ERROR'
+ ? 'btn-danger'
+ : 'btn-normal'
+ "
+ @click="handleConfirm"
+ >
+ {{ okText }}
</button>
</div>
</div>
</template>
<script lang="ts" setup>
-import { Ref } from "vue";
+import { Ref, ref } from "vue";
import { useIssueLogic } from "../logic";
import { Issue } from "@/types";
+import { Review_Approver_Status } from "@/types/proto/v1/review_service";
+import AutoHeightTextarea from "@/components/misc/AutoHeightTextarea.vue";
+
+const props = defineProps<{
+ okText: string;
+ status: Review_Approver_Status;
+ buttonStyle: "PRIMARY" | "ERROR" | "NORMAL";
+}>();
const emit = defineEmits<{
(event: "cancel"): void;
- (event: "confirm", onSuccess: () => void): void;
+ (
+ event: "confirm",
+ params: {
+ status: Review_Approver_Status;
+ comment?: string;
+ },
+ onSuccess: () => void
+ ): void;
}>();
const issueContext = useIssueLogic();
const issue = issueContext.issue as Ref<Issue>;
+const comment = ref("");
const handleConfirm = (e: MouseEvent) => {
const button = e.target as HTMLElement;
const { left, top, width, height } = button.getBoundingClientRect();
const { innerWidth: winWidth, innerHeight: winHeight } = window;
const onSuccess = () => {
+ if (props.status !== Review_Approver_Status.APPROVED) {
+ return;
+ }
// import the effect lib asynchronously
import("canvas-confetti").then(({ default: confetti }) => {
// Create a confetti effect from the position of the LGTM button
@@ -47,6 +86,13 @@ const handleConfirm = (e: MouseEvent) => {
});
};
- emit("confirm", onSuccess);
+ emit(
+ "confirm",
+ {
+ status: props.status,
+ comment: comment.value,
+ },
+ onSuccess
+ );
};
</script>
diff --git a/frontend/src/components/PrincipalAvatar.vue b/frontend/src/components/PrincipalAvatar.vue
index 710574094a..97949f66c8 100644
--- a/frontend/src/components/PrincipalAvatar.vue
+++ b/frontend/src/components/PrincipalAvatar.vue
@@ -1,14 +1,23 @@
<template>
- <BBAvatar :username="username" :size="size" />
+ <BBAvatar
+ :username="username"
+ :size="size"
+ :override-class="overrideClass"
+ :override-text-size="overrideTextSize"
+ />
</template>
<script lang="ts">
import { computed, defineComponent, PropType } from "vue";
-import { BBAvatarSizeType } from "../bbkit/types";
-import { Principal, unknown, UNKNOWN_ID } from "../types";
+
+import { BBAvatar } from "@/bbkit";
+import { BBAvatarSizeType } from "@/bbkit/types";
+import { Principal, unknown, UNKNOWN_ID } from "@/types";
+import { VueClass } from "@/utils";
export default defineComponent({
name: "PrincipalAvatar",
+ components: { BBAvatar },
props: {
principal: {
type: Object as PropType<Principal>,
@@ -18,6 +27,14 @@ export default defineComponent({
type: String as PropType<BBAvatarSizeType>,
default: "NORMAL",
},
+ overrideClass: {
+ type: [String, Object, Array] as PropType<VueClass>,
+ default: undefined,
+ },
+ overrideTextSize: {
+ type: String,
+ default: undefined,
+ },
},
setup(props) {
const username = computed((): string => {
diff --git a/frontend/src/components/User/UserAvatar.vue b/frontend/src/components/User/UserAvatar.vue
index 0e87241e5a..8a62fa48e7 100644
--- a/frontend/src/components/User/UserAvatar.vue
+++ b/frontend/src/components/User/UserAvatar.vue
@@ -1,12 +1,20 @@
<template>
- <BBAvatar :username="username" :size="size" />
+ <BBAvatar
+ :username="username"
+ :size="size"
+ :override-class="overrideClass"
+ :override-text-size="overrideTextSize"
+ />
</template>
<script lang="ts" setup>
import { computed, PropType } from "vue";
+
+import { BBAvatar } from "@/bbkit";
import { BBAvatarSizeType } from "@/bbkit/types";
import { UNKNOWN_ID, unknownUser } from "@/types";
import { User } from "@/types/proto/v1/auth_service";
+import { VueClass } from "@/utils";
const props = defineProps({
user: {
@@ -17,6 +25,14 @@ const props = defineProps({
type: String as PropType<BBAvatarSizeType>,
default: "NORMAL",
},
+ overrideClass: {
+ type: [String, Object, Array] as PropType<VueClass>,
+ default: undefined,
+ },
+ overrideTextSize: {
+ type: String,
+ default: undefined,
+ },
});
const username = computed((): string => {
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index a3684f6808..78851fee48 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -779,7 +779,8 @@
"manually-select": "Manually select",
"customize": "Customize",
"data-export-attention": "The data will be exported to a file and downloaded to your local machine. And you can only do the export action once."
- }
+ },
+ "review-sent-back": "Review sent back"
},
"alter-schema": {
"vcs-enabled": "This project has enabled VCS based version control and selecting database below will navigate you to the corresponding Git repository to initiate the change process.",
@@ -2458,8 +2459,15 @@
"approved-issue": "approved issue",
"disallow-approve-reason": {
"some-task-checks-didnt-pass": "Some task checks didn't pass"
- }
- }
+ },
+ "send-back": "Send back",
+ "send-back-issue": "Send back issue?",
+ "re-request-review": "Re-request review",
+ "re-request-review-issue": "Re-request review issue?",
+ "sent-back-issue": "Sent back issue",
+ "re-requested-review": "re-requested issue review"
+ },
+ "send-back": "Send back"
},
"slow-query": {
"self": "Slow query",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 1ed9484544..6d76c90707 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -773,7 +773,8 @@
"manually-select": "selección manual",
"customize": "personalice",
"data-export-attention": "Los datos se exportarán a un archivo y se descargarán en su computadora local. Y solo puede realizar la acción de exportación una vez."
- }
+ },
+ "review-sent-back": "Revisión devuelta"
},
"alter-schema": {
"vcs-enabled": "Este proyecto ha habilitado el control de versiones basado en VCS y seleccionar la base de datos a continuación lo llevará al repositorio Git correspondiente para iniciar el proceso de cambio.",
@@ -2438,8 +2439,15 @@
"approved-issue": "incidencia aprobada",
"disallow-approve-reason": {
"some-task-checks-didnt-pass": "Algunas comprobaciones de tareas no pasaron"
- }
- }
+ },
+ "send-back": "Enviar de vuelta",
+ "send-back-issue": "¿Devolver el problema?",
+ "re-request-review": "Volver a solicitar revisión",
+ "re-request-review-issue": "¿Volver a solicitar revisión?",
+ "sent-back-issue": "Problema devuelto",
+ "re-requested-review": "revisión de problema nuevamente solicitada"
+ },
+ "send-back": "Enviar de vuelta"
},
"slow-query": {
"self": "Consulta lenta",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index b47a117385..3f72fd16ea 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -777,7 +777,8 @@
"manually-select": "手动选择",
"customize": "自定义",
"data-export-attention": "数据将被导出到一个文件并自动下载。而且您只能完成一次导出操作。"
- }
+ },
+ "review-sent-back": "审核被退回"
},
"alter-schema": {
"vcs-enabled": "该项目开启了基于 VCS 的版本管理,选择下面的数据库会将您导航到相应的 Git 仓库以发起变更流程。",
@@ -2453,8 +2454,15 @@
"approved-issue": "批准工单",
"disallow-approve-reason": {
"some-task-checks-didnt-pass": "尚有未通过的任务检查项"
- }
- }
+ },
+ "send-back": "退回",
+ "send-back-issue": "退回工单?",
+ "re-request-review": "请求再次审批",
+ "re-request-review-issue": "请求再次审批工单?",
+ "sent-back-issue": "退回工单",
+ "re-requested-review": "再次请求审批工单"
+ },
+ "send-back": "退回"
},
"slow-query": {
"self": "慢查询",
diff --git a/frontend/src/plugins/issue/logic/review/context.ts b/frontend/src/plugins/issue/logic/review/context.ts
index 2961e488fb..57e5533231 100644
--- a/frontend/src/plugins/issue/logic/review/context.ts
+++ b/frontend/src/plugins/issue/logic/review/context.ts
@@ -1,5 +1,8 @@
import { ReviewFlow } from "@/types";
-import { Review } from "@/types/proto/v1/review_service";
+import {
+ Review,
+ Review_Approver_Status,
+} from "@/types/proto/v1/review_service";
import { inject, provide, type InjectionKey, type Ref } from "vue";
export type IssueReviewContext = {
@@ -11,7 +14,10 @@ export type IssueReviewContext = {
// The review flow.
// Now we have only one flow in an issue
flow: Ref<ReviewFlow>;
+ // The overall status of the entire review flow
+ status: Ref<Review_Approver_Status>;
// Whether the review flow is finished successfully.
+ // A shortcut to `status === Review_Approver_Status.APPROVED`
done: Ref<boolean>;
// Whether the review finding has error.
error: Ref<string | undefined>;
diff --git a/frontend/src/plugins/issue/logic/review/index.ts b/frontend/src/plugins/issue/logic/review/index.ts
index 796d6a7794..b4a995fe58 100644
--- a/frontend/src/plugins/issue/logic/review/index.ts
+++ b/frontend/src/plugins/issue/logic/review/index.ts
@@ -2,7 +2,11 @@ import { computed, watch, type ComputedRef, unref } from "vue";
import type Emittery from "emittery";
import type { Issue, MaybeRef, ReviewFlow, WrappedReviewStep } from "@/types";
-import { Review } from "@/types/proto/v1/review_service";
+import {
+ ApprovalTemplate,
+ Review,
+ Review_Approver_Status,
+} from "@/types/proto/v1/review_service";
import {
candidatesOfApprovalStep,
useAuthStore,
@@ -10,7 +14,6 @@ import {
useUserStore,
} from "@/store";
import { IssueReviewContext, provideIssueReviewContext } from "./context";
-import { ApprovalTemplate } from "@/types/proto/store/approval";
import { useProgressivePoll } from "@/composables/useProgressivePoll";
import { extractUserResourceName } from "@/utils";
@@ -35,14 +38,41 @@ export const extractIssueReviewContext = (
currentStepIndex: approvers.length,
};
});
- const done = computed(() => {
- if (!ready.value) return false;
- if (review.value.approvalFindingError) return false;
+ const status = computed(() => {
+ if (!ready.value) {
+ return Review_Approver_Status.PENDING;
+ }
+ if (review.value.approvalFindingError) {
+ return Review_Approver_Status.PENDING;
+ }
const { template, approvers } = flow.value;
const steps = template.flow?.steps ?? [];
- if (steps.length === 0) return true;
- return approvers.length === steps.length;
+
+ if (steps.length === 0) {
+ // No review flow steps. That means need not manual review.
+ return Review_Approver_Status.APPROVED;
+ }
+
+ if (
+ approvers.some((app) => app.status === Review_Approver_Status.REJECTED)
+ ) {
+ // If any of the approvers down voted, the overall status should be 'REJECTED'
+ return Review_Approver_Status.REJECTED;
+ }
+
+ // For an N-steps approval flow, we need exactly N upvote approvals to
+ // pass the entire flow.
+ const upVotes = approvers.filter(
+ (app) => app.status === Review_Approver_Status.APPROVED
+ );
+ if (upVotes.length === steps.length) {
+ return Review_Approver_Status.APPROVED;
+ }
+ return Review_Approver_Status.PENDING;
+ });
+ const done = computed(() => {
+ return status.value === Review_Approver_Status.APPROVED;
});
const error = computed(() => {
return review.value.approvalFindingError;
@@ -52,6 +82,7 @@ export const extractIssueReviewContext = (
review,
ready,
flow,
+ status,
done,
error,
};
@@ -111,16 +142,31 @@ export const useWrappedReviewSteps = (
return computed(() => {
const { flow, done } = context;
const steps = flow.value.template.flow?.steps;
+ const approvers = flow.value.approvers;
const currentStepIndex = flow.value.currentStepIndex ?? -1;
const statusOfStep = (index: number) => {
- if (done.value) return "DONE";
- if (index < currentStepIndex) return "DONE";
- if (index === currentStepIndex) return "CURRENT";
+ if (done.value) {
+ return "APPROVED";
+ }
+ if (index >= (steps?.length ?? 0)) {
+ // Out of index
+ return "PENDING";
+ }
+ const approval = approvers[index];
+ if (approval && approval.status === Review_Approver_Status.REJECTED) {
+ return "REJECTED";
+ }
+ if (index < currentStepIndex) {
+ return "APPROVED";
+ }
+ if (index === currentStepIndex) {
+ return "CURRENT";
+ }
return "PENDING";
};
const approverOfStep = (index: number) => {
- const principal = flow.value.approvers[index]?.principal;
+ const principal = approvers[index]?.principal;
if (!principal) return undefined;
const email = extractUserResourceName(principal);
return userStore.getUserByEmail(email);
diff --git a/frontend/src/store/modules/review.ts b/frontend/src/store/modules/review.ts
index f03c2fd2fc..7fb47a9994 100644
--- a/frontend/src/store/modules/review.ts
+++ b/frontend/src/store/modules/review.ts
@@ -52,9 +52,26 @@ export const useReviewStore = defineStore("review", () => {
}
};
- const approveReview = async (issue: Issue) => {
+ const approveReview = async (issue: Issue, comment?: string) => {
const review = await reviewServiceClient.approveReview({
name: reviewName(issue),
+ comment,
+ });
+ await setReviewByIssue(issue, review);
+ };
+
+ const rejectReview = async (issue: Issue, comment?: string) => {
+ const review = await reviewServiceClient.rejectReview({
+ name: reviewName(issue),
+ comment,
+ });
+ await setReviewByIssue(issue, review);
+ };
+
+ const requestReview = async (issue: Issue, comment?: string) => {
+ const review = await reviewServiceClient.requestReview({
+ name: reviewName(issue),
+ comment,
});
await setReviewByIssue(issue, review);
};
@@ -74,6 +91,8 @@ export const useReviewStore = defineStore("review", () => {
getReviewByIssue,
fetchReviewByIssue,
approveReview,
+ rejectReview,
+ requestReview,
regenerateReview,
};
});
diff --git a/frontend/src/types/review.ts b/frontend/src/types/review.ts
index 4fa9300bab..c217071bc6 100644
--- a/frontend/src/types/review.ts
+++ b/frontend/src/types/review.ts
@@ -6,7 +6,7 @@ import type {
} from "./proto/v1/review_service";
export type ApprovalEvent = {
- status: "APPROVED";
+ status: "APPROVED" | "REJECTED" | "PENDING";
};
export type ReviewFlow = {
@@ -18,7 +18,7 @@ export type ReviewFlow = {
export type WrappedReviewStep = {
index: number;
step: ApprovalStep;
- status: "DONE" | "CURRENT" | "PENDING";
+ status: "APPROVED" | "REJECTED" | "CURRENT" | "PENDING";
approver: User | undefined;
candidates: User[];
};
diff --git a/frontend/src/utils/pipeline.ts b/frontend/src/utils/pipeline.ts
index 57f035436c..5a33713af2 100644
--- a/frontend/src/utils/pipeline.ts
+++ b/frontend/src/utils/pipeline.ts
@@ -61,7 +61,11 @@ export function lastTask(pipeline: Pipeline): Task {
return empty("TASK") as Task;
}
-export function findTaskById(pipeline: Pipeline, taskId: TaskId): Task {
+export function findTaskById(
+ pipeline: Pipeline | undefined,
+ taskId: TaskId
+): Task {
+ if (!pipeline) return unknown("TASK");
for (const stage of pipeline.stageList) {
for (const task of stage.taskList) {
if (task.id == taskId) {
@@ -72,7 +76,11 @@ export function findTaskById(pipeline: Pipeline, taskId: TaskId): Task {
return unknown("TASK") as Task;
}
-export function findStageById(pipeline: Pipeline, stageId: StageId): Stage {
+export function findStageById(
+ pipeline: Pipeline | undefined,
+ stageId: StageId
+): Stage {
+ if (!pipeline) return unknown("STAGE");
return pipeline.stageList.find((s) => s.id === stageId) ?? unknown("STAGE");
}