Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): add unified issue review button with popover (#18622)
boojackefd3130a870b
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vueindex 1620dc09f6..ade85db431 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue@@ -16,6 +16,26 @@</div></template>+ <!-- Show IssueReviewButton when review actions are available -->+ <template v-else-if="showReviewButton">+ <div class="flex items-center gap-x-2">+ <IssueReviewButton+ :can-approve="canApprove"+ :can-reject="canReject"+ :disabled="actionsDisabled"+ :disabled-tooltip="disabledTooltip"+ />+ <!-- Secondary actions dropdown (excluding review actions) -->+ <UnifiedActionGroup+ v-if="nonReviewSecondaryActions.length > 0"+ :secondary-actions="nonReviewSecondaryActions"+ :disabled="actionsDisabled"+ :disabled-tooltip="disabledTooltip"+ @perform-action="handlePerformAction"+ />+ </div>+ </template>+<!-- Show unified actions for other plan states --><template v-else><UnifiedActionGroup@@ -29,10 +49,6 @@<!-- Panels --><template v-if="issue">- <IssueReviewActionPanel- :action="pendingReviewAction"- @close="pendingReviewAction = undefined"- /><IssueStatusActionPanel:action="pendingStatusAction"@close="pendingStatusAction = undefined"@@ -84,10 +100,10 @@ import {isValidPlanName,} from "@/utils";import { CreateButton, CreateIssueButton } from "./create";-import { IssueReviewActionPanel, IssueStatusActionPanel } from "./panels";+import { IssueStatusActionPanel } from "./panels";import {type ActionConfig,- type IssueReviewAction,+ IssueReviewButton,type IssueStatusAction,type PlanAction,type RolloutAction,@@ -104,7 +120,7 @@ const { project } = useCurrentProjectV1();const { isCreating, plan, issue, rollout, events } = usePlanContext();const planStore = usePlanStore();const editorState = useEditorState();-const { availableActions } = usePlanAction();+const { availableActions, canApprove, canReject } = usePlanAction();const creatingRollout = ref(false);// Computed property for actions disabled state.@@ -121,7 +137,6 @@ const disabledTooltip = computed(() => {});// Panel visibility state-const pendingReviewAction = ref<IssueReviewAction | undefined>(undefined);const pendingStatusAction = ref<IssueStatusAction | undefined>(undefined);const pendingRolloutAction = ref<RolloutAction | undefined>(undefined);@@ -152,6 +167,18 @@ const showCreateIssueButton = computed(() => {return !isIssueOnly.value && availableActions.value.includes("ISSUE_CREATE");});+// Show the unified review button when ISSUE_REVIEW is available+const showReviewButton = computed(() => {+ return availableActions.value.includes("ISSUE_REVIEW");+});++// Secondary actions excluding review action (for when review button is shown)+const nonReviewSecondaryActions = computed((): ActionConfig[] => {+ return secondaryActions.value.filter(+ (config) => config.action !== "ISSUE_REVIEW"+ );+});+const primaryAction = computed((): ActionConfig | undefined => {const actions = availableActions.value;@@ -165,13 +192,8 @@ const primaryAction = computed((): ActionConfig | undefined => {return { action: "ISSUE_STATUS_REOPEN" };}- // ISSUE_REVIEW_APPROVE and ISSUE_REVIEW_RE_REQUEST are primary actions- if (actions.includes("ISSUE_REVIEW_APPROVE")) {- return { action: "ISSUE_REVIEW_APPROVE" };- }- if (actions.includes("ISSUE_REVIEW_RE_REQUEST")) {- return { action: "ISSUE_REVIEW_RE_REQUEST" };- }+ // ISSUE_REVIEW is handled by IssueReviewButton, not UnifiedActionGroup+ // So we skip it here and let showReviewButton handle it// ISSUE_STATUS_RESOLVE is primary when issue can be resolvedif (actions.includes("ISSUE_STATUS_RESOLVE")) {@@ -195,9 +217,7 @@ const secondaryActions = computed((): ActionConfig[] => {const actions = availableActions.value;const secondary: ActionConfig[] = [];- if (actions.includes("ISSUE_REVIEW_REJECT")) {- secondary.push({ action: "ISSUE_REVIEW_REJECT" });- }+ // ISSUE_REVIEW is handled by IssueReviewButton, not in secondary actionsif (actions.includes("ROLLOUT_CREATE")) {secondary.push({ action: "ROLLOUT_CREATE" });}@@ -217,11 +237,7 @@ const secondaryActions = computed((): ActionConfig[] => {const handlePerformAction = async (action: UnifiedAction) => {switch (action) {- case "ISSUE_REVIEW_APPROVE":- case "ISSUE_REVIEW_REJECT":- case "ISSUE_REVIEW_RE_REQUEST":- pendingReviewAction.value = action as IssueReviewAction;- break;+ // ISSUE_REVIEW is handled directly by IssueReviewButtoncase "ISSUE_STATUS_CLOSE":case "ISSUE_STATUS_REOPEN":case "ISSUE_STATUS_RESOLVE":diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueReviewActionPanel.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueReviewActionPanel.vuedeleted file mode 100644index 5f3a5b385e..0000000000--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueReviewActionPanel.vue+++ /dev/null@@ -1,308 +0,0 @@-<template>- <CommonDrawer- :show="action !== undefined"- :title="title"- :loading="state.loading"- @show="resetState"- @close="$emit('close')"- >- <template #default>- <div v-if="action" class="flex flex-col gap-y-4 px-1">- <div class="flex flex-col gap-y-1">- <div class="font-medium text-control">- {{ $t("common.issue") }}- </div>- <div class="textinfolabel">- {{ issue.title }}- </div>- </div>-- <div class="flex flex-col gap-y-1">- <p class="font-medium text-control">- {{ $t("common.comment") }}- <RequiredStar v-show="props.action === 'ISSUE_REVIEW_REJECT'" />- </p>- <NInput- v-model:value="comment"- type="textarea"- :placeholder="$t('issue.leave-a-comment')"- :autosize="{- minRows: 3,- maxRows: 10,- }"- />- </div>- </div>- </template>- <template #footer>- <div- v-if="action"- class="w-full flex flex-row justify-between items-center gap-2"- >- <div>- <NCheckbox- v-if="showPerformActionAnyway"- v-model:checked="performActionAnyway"- >- {{- $t("issue.action-anyway", {- action: actionDisplayName(action),- })- }}- </NCheckbox>- </div>- <div class="flex justify-end gap-x-2">- <NButton quaternary @click="$emit('close')">- {{ $t("common.close") }}- </NButton>-- <NTooltip :disabled="confirmErrors.length === 0" placement="top">- <template #trigger>- <NButton- type="primary"- :disabled="confirmErrors.length > 0"- v-bind="confirmButtonProps"- @click="handleConfirm"- >- {{ $t("common.confirm") }}- </NButton>- </template>- <template #default>- <ErrorList :errors="confirmErrors" />- </template>- </NTooltip>- </div>- </div>- </template>- </CommonDrawer>-</template>--<script setup lang="ts">-import { create } from "@bufbuild/protobuf";-import { NButton, NCheckbox, NInput, NTooltip } from "naive-ui";-import { computed, nextTick, reactive, ref } from "vue";-import { useI18n } from "vue-i18n";-import { useRouter } from "vue-router";-import { ErrorList } from "@/components/IssueV1/components/common";-import CommonDrawer from "@/components/IssueV1/components/Panel/CommonDrawer.vue";-import { usePlanContextWithIssue } from "@/components/Plan/logic";-import RequiredStar from "@/components/RequiredStar.vue";-import { issueServiceClientConnect } from "@/grpcweb";-import {- PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,- PROJECT_V1_ROUTE_ROLLOUT_DETAIL,-} from "@/router/dashboard/projectV1";-import { pushNotification } from "@/store";-import {- ApproveIssueRequestSchema,- RejectIssueRequestSchema,- RequestIssueRequestSchema,-} from "@/types/proto-es/v1/issue_service_pb";-import { PlanCheckRun_Status } from "@/types/proto-es/v1/plan_service_pb";-import { Task_Type } from "@/types/proto-es/v1/rollout_service_pb";-import {- extractIssueUID,- extractProjectResourceName,- extractRolloutUID,- flattenTaskV1List,-} from "@/utils";-import type { IssueReviewAction } from "../unified";--type LocalState = {- loading: boolean;-};--const props = defineProps<{- action?: IssueReviewAction;-}>();-const emit = defineEmits<{- (event: "close"): void;-}>();--const { t } = useI18n();-const router = useRouter();-const state = reactive<LocalState>({- loading: false,-});-const { issue, rollout, planCheckRuns, events } = usePlanContextWithIssue();-const comment = ref("");-const performActionAnyway = ref(false);--const title = computed(() => {- switch (props.action) {- case "ISSUE_REVIEW_APPROVE":- return t("custom-approval.issue-review.approve-issue");- case "ISSUE_REVIEW_REJECT":- return t("custom-approval.issue-review.send-back-issue");- case "ISSUE_REVIEW_RE_REQUEST":- return t("custom-approval.issue-review.re-request-review-issue");- }- return ""; // Make linter happy-});--const actionDisplayName = (action: IssueReviewAction): string => {- switch (action) {- case "ISSUE_REVIEW_APPROVE":- return t("common.approve");- case "ISSUE_REVIEW_REJECT":- return t("custom-approval.issue-review.send-back");- case "ISSUE_REVIEW_RE_REQUEST":- return t("custom-approval.issue-review.re-request-review");- }-};--const showPerformActionAnyway = computed(() => {- return planCheckErrors.value.length > 0;-});--const planCheckErrors = computed(() => {- const errors: string[] = [];- if (props.action === "ISSUE_REVIEW_APPROVE") {- // Check plan check runs for errors- const failedRuns = planCheckRuns.value.filter(- (run) => run.status === PlanCheckRun_Status.FAILED- );- const runningRuns = planCheckRuns.value.filter(- (run) => run.status === PlanCheckRun_Status.RUNNING- );-- if (failedRuns.length > 0) {- errors.push(- t(- "custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"- )- );- }- if (runningRuns.length > 0) {- errors.push(- t(- "custom-approval.issue-review.disallow-approve-reason.some-task-checks-are-still-running"- )- );- }- }-- return errors;-});--const confirmErrors = computed(() => {- const errors: string[] = [];- if (props.action === "ISSUE_REVIEW_REJECT" && comment.value === "") {- errors.push(- t(- "custom-approval.issue-review.disallow-approve-reason.x-field-is-required",- {- field: t("common.comment"),- }- )- );- }- if (planCheckErrors.value.length > 0 && !performActionAnyway.value) {- errors.push(...planCheckErrors.value);- }- return errors;-});--const confirmButtonProps = computed(() => {- if (!props.action) return {};-- switch (props.action) {- case "ISSUE_REVIEW_APPROVE":- return { type: "primary" as const };- case "ISSUE_REVIEW_REJECT":- return { type: "primary" as const };- default:- return {};- }-});--const handleConfirm = async () => {- const { action } = props;- if (!action) return;- state.loading = true;- try {- if (action === "ISSUE_REVIEW_APPROVE") {- const request = create(ApproveIssueRequestSchema, {- name: issue.value.name,- comment: comment.value,- });- await issueServiceClientConnect.approveIssue(request);- } else if (action === "ISSUE_REVIEW_REJECT") {- const request = create(RejectIssueRequestSchema, {- name: issue.value.name,- comment: comment.value,- });- await issueServiceClientConnect.rejectIssue(request);- } else if (action === "ISSUE_REVIEW_RE_REQUEST") {- const request = create(RequestIssueRequestSchema, {- name: issue.value.name,- comment: comment.value,- });- await issueServiceClientConnect.requestIssue(request);- }-- // Emit event to trigger polling- events.emit("perform-issue-review-action", { action });- } finally {- state.loading = false;- emit("close");-- const shouldRedirect = flattenTaskV1List(rollout.value).every(- (task) =>- task.type !== Task_Type.DATABASE_CREATE &&- task.type !== Task_Type.DATABASE_EXPORT- );- if (!shouldRedirect) {- return;- }-- // For ISSUE_REVIEW_APPROVE, check if this is the last approval needed- if (action === "ISSUE_REVIEW_APPROVE") {- const { approvalTemplate, approvers } = issue.value;- const roles = approvalTemplate?.flow?.roles ?? [];-- // Check if this approval will complete the review process- const isLastApproval =- roles.length > 0 && approvers.length + 1 >= roles.length;-- if (rollout.value && isLastApproval) {- // Rollout exists, redirect to rollout page- // Show success notification for final approval- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("issue.approval.approved-and-waiting-for-rollout"),- });-- nextTick(() => {- router.push({- name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,- params: {- projectId: extractProjectResourceName(issue.value.name),- rolloutId: extractRolloutUID(rollout.value!.name),- },- });- });- return;- }- }-- // For other actions, redirect to issue page immediately- nextTick(() => {- router.push({- name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,- params: {- projectId: extractProjectResourceName(issue.value.name),- issueId: extractIssueUID(issue.value.name),- },- hash: `#issue-comment-editor`,- });- });- }-};--const resetState = () => {- comment.value = "";- performActionAnyway.value = false;-};-</script>diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/index.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/index.tsindex 4f99fb32fd..4faff460a0 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/index.ts+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/index.ts@@ -1,2 +1 @@-export { default as IssueReviewActionPanel } from "./IssueReviewActionPanel.vue";export { default as IssueStatusActionPanel } from "./IssueStatusActionPanel.vue";diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/IssueReviewButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/IssueReviewButton.vuenew file mode 100644index 0000000000..45d316ac95--- /dev/null+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/IssueReviewButton.vue@@ -0,0 +1,386 @@+<template>+ <NPopover+ trigger="click"+ placement="bottom-end"+ :show="showPopover"+ @update:show="showPopover = $event"+ >+ <template #trigger>+ <NTooltip :disabled="errors.length === 0" placement="top">+ <template #trigger>+ <NButton+ type="primary"+ size="medium"+ tag="div"+ :disabled="errors.length > 0 || loading || disabled"+ icon-placement="right"+ >+ {{ $t("issue.review.self") }}+ <template #icon>+ <ChevronDownIcon class="w-4 h-4" />+ </template>+ </NButton>+ </template>+ <template #default>+ <ErrorList :errors="errors" />+ </template>+ </NTooltip>+ </template>++ <template #default>+ <div class="w-128 flex flex-col gap-y-4 p-1">+ <!-- Comment editor -->+ <MarkdownEditor+ mode="editor"+ :content="comment"+ :project="project"+ :maxlength="65536"+ @change="(val: string) => (comment = val)"+ />++ <!-- Review action radio group -->+ <NRadioGroup+ v-model:value="selectedAction"+ :disabled="loading"+ class="flex! flex-col gap-y-2"+ >+ <!-- Comment option (always available) -->+ <NRadio value="COMMENT">+ <div class="flex items-start gap-2">+ <MessageCircleIcon class="w-4 h-4 mt-0.5 text-gray-600 shrink-0" />+ <div class="flex flex-col">+ <span class="font-medium">{{ $t("common.comment") }}</span>+ <span class="text-control-light text-xs">+ {{ $t("issue.review.comment-description") }}+ </span>+ </div>+ </div>+ </NRadio>++ <!-- Approve option -->+ <NRadio v-if="canApprove" value="APPROVE">+ <div class="flex items-start gap-2">+ <CheckIcon class="w-4 h-4 mt-0.5 text-green-600 shrink-0" />+ <div class="flex flex-col">+ <span class="font-medium">{{ $t("common.approve") }}</span>+ <span class="text-control-light text-xs">+ {{ $t("issue.review.approve-description") }}+ </span>+ </div>+ </div>+ </NRadio>++ <!-- Reject option -->+ <NRadio v-if="canReject" value="REJECT">+ <div class="flex items-start gap-2">+ <XIcon class="w-4 h-4 mt-0.5 text-red-600 shrink-0" />+ <div class="flex flex-col">+ <span class="font-medium">{{ $t("common.reject") }}</span>+ <span class="text-control-light text-xs">+ {{ $t("issue.review.reject-description") }}+ </span>+ </div>+ </div>+ </NRadio>+ </NRadioGroup>++ <!-- Plan check warnings -->+ <NAlert+ v-if="+ selectedAction === 'APPROVE' &&+ planCheckWarnings.length > 0+ "+ type="warning"+ size="small"+ >+ <ul class="text-sm">+ <li+ v-for="(warning, index) in planCheckWarnings"+ :key="index"+ class="list-disc list-inside"+ >+ {{ warning }}+ </li>+ </ul>+ <NCheckbox+ v-model:checked="performActionAnyway"+ class="mt-2"+ size="small"+ >+ {{+ $t("issue.action-anyway", {+ action: $t("common.approve"),+ })+ }}+ </NCheckbox>+ </NAlert>++ <!-- Footer -->+ <div class="flex justify-end gap-x-2">+ <NButton quaternary @click="showPopover = false">+ {{ $t("common.cancel") }}+ </NButton>+ <NTooltip :disabled="confirmErrors.length === 0" placement="top">+ <template #trigger>+ <NButton+ type="primary"+ :disabled="confirmErrors.length > 0 || loading"+ :loading="loading"+ @click="handleSubmit"+ >+ {{ $t("common.submit") }}+ </NButton>+ </template>+ <template #default>+ <ErrorList :errors="confirmErrors" />+ </template>+ </NTooltip>+ </div>+ </div>+ </template>+ </NPopover>+</template>++<script setup lang="ts">+import { create } from "@bufbuild/protobuf";+import {+ CheckIcon,+ ChevronDownIcon,+ MessageCircleIcon,+ XIcon,+} from "lucide-vue-next";+import {+ NAlert,+ NButton,+ NCheckbox,+ NPopover,+ NRadio,+ NRadioGroup,+ NTooltip,+} from "naive-ui";+import { computed, nextTick, ref, watch } from "vue";+import { useI18n } from "vue-i18n";+import { useRouter } from "vue-router";+import MarkdownEditor from "@/components/MarkdownEditor";+import { ErrorList } from "@/components/Plan/components/common";+import { usePlanContext } from "@/components/Plan/logic";+import { issueServiceClientConnect } from "@/grpcweb";+import {+ PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL,+} from "@/router/dashboard/projectV1";+import {+ pushNotification,+ useCurrentProjectV1,+ useIssueCommentStore,+} from "@/store";+import {+ ApproveIssueRequestSchema,+ RejectIssueRequestSchema,+} from "@/types/proto-es/v1/issue_service_pb";+import { PlanCheckRun_Status } from "@/types/proto-es/v1/plan_service_pb";+import { Task_Type } from "@/types/proto-es/v1/rollout_service_pb";+import {+ extractIssueUID,+ extractProjectResourceName,+ extractRolloutUID,+ flattenTaskV1List,+} from "@/utils";++// Internal action type for the review button+type ReviewAction = "APPROVE" | "REJECT" | "COMMENT";++defineProps<{+ canApprove: boolean;+ canReject: boolean;+ disabled?: boolean;+}>();++const { t } = useI18n();+const router = useRouter();+const { project } = useCurrentProjectV1();+const { issue, rollout, planCheckRuns, events } = usePlanContext();+const issueCommentStore = useIssueCommentStore();++const loading = ref(false);+const showPopover = ref(false);+const comment = ref("");+const selectedAction = ref<ReviewAction>("COMMENT");+const performActionAnyway = ref(false);++// No errors that disable the main button currently+const errors: string[] = [];++// Reset state when popover opens+watch(showPopover, (show) => {+ if (show) {+ comment.value = "";+ selectedAction.value = "COMMENT";+ performActionAnyway.value = false;+ }+});++// Plan check warnings for approve action+const planCheckWarnings = computed(() => {+ const warnings: string[] = [];+ if (!planCheckRuns.value) return warnings;++ const failedRuns = planCheckRuns.value.filter(+ (run) => run.status === PlanCheckRun_Status.FAILED+ );+ const runningRuns = planCheckRuns.value.filter(+ (run) => run.status === PlanCheckRun_Status.RUNNING+ );++ if (failedRuns.length > 0) {+ warnings.push(+ t(+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"+ )+ );+ }+ if (runningRuns.length > 0) {+ warnings.push(+ t(+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-are-still-running"+ )+ );+ }++ return warnings;+});++// Errors that disable the confirm button+const confirmErrors = computed(() => {+ const list: string[] = [];++ // Comment is required for comment action+ if (selectedAction.value === "COMMENT" && !comment.value.trim()) {+ list.push(+ t(+ "custom-approval.issue-review.disallow-approve-reason.x-field-is-required",+ { field: t("common.comment") }+ )+ );+ }++ // Plan check warnings block approve unless acknowledged+ if (+ selectedAction.value === "APPROVE" &&+ planCheckWarnings.value.length > 0 &&+ !performActionAnyway.value+ ) {+ list.push(...planCheckWarnings.value);+ }++ return list;+});++const handleSubmit = async () => {+ if (loading.value) return;+ if (confirmErrors.value.length > 0) return;++ const issueValue = issue?.value;+ if (!issueValue) return;++ loading.value = true;++ try {+ const action = selectedAction.value;++ if (action === "APPROVE") {+ const request = create(ApproveIssueRequestSchema, {+ name: issueValue.name,+ comment: comment.value,+ });+ await issueServiceClientConnect.approveIssue(request);+ } else if (action === "REJECT") {+ const request = create(RejectIssueRequestSchema, {+ name: issueValue.name,+ comment: comment.value,+ });+ await issueServiceClientConnect.rejectIssue(request);+ } else if (action === "COMMENT") {+ await issueCommentStore.createIssueComment({+ issueName: issueValue.name,+ comment: comment.value,+ });+ }++ // Emit event to refresh issue and comments+ events.emit("perform-issue-review-action", { action: "ISSUE_REVIEW" });++ showPopover.value = false;++ // Handle navigation after action+ handlePostActionNavigation(action, issueValue);+ } catch (error) {+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: t("common.failed"),+ description: String(error),+ });+ } finally {+ loading.value = false;+ }+};++const handlePostActionNavigation = (+ action: ReviewAction,+ issueValue: NonNullable<typeof issue.value>+) => {+ // No navigation for comment-only action+ if (action === "COMMENT") return;++ const rolloutValue = rollout?.value;+ if (!rolloutValue) return;++ // Skip redirect for database create/export tasks+ const hasSpecialTasks = flattenTaskV1List(rolloutValue).some(+ (task) =>+ task.type === Task_Type.DATABASE_CREATE ||+ task.type === Task_Type.DATABASE_EXPORT+ );+ if (hasSpecialTasks) return;++ // For APPROVE, check if this is the last approval needed+ if (action === "APPROVE") {+ const { approvalTemplate, approvers } = issueValue;+ const roles = approvalTemplate?.flow?.roles ?? [];+ const isLastApproval =+ roles.length > 0 && approvers.length + 1 >= roles.length;++ if (isLastApproval) {+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("issue.approval.approved-and-waiting-for-rollout"),+ });++ nextTick(() => {+ router.push({+ name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,+ params: {+ projectId: extractProjectResourceName(issueValue.name),+ rolloutId: extractRolloutUID(rolloutValue.name),+ },+ });+ });+ return;+ }+ }++ // For APPROVE (not last) and REJECT, redirect to issue page+ nextTick(() => {+ router.push({+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,+ params: {+ projectId: extractProjectResourceName(issueValue.name),+ issueId: extractIssueUID(issueValue.name),+ },+ hash: "#issue-comment-editor",+ });+ });+};+</script>diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vueindex 2571f3bc5c..0e31ce7827 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue@@ -36,7 +36,7 @@ const { actionDisplayName } = usePlanAction();const actionButtonProps = (action: UnifiedAction) => {switch (action) {- case "ISSUE_REVIEW_APPROVE":+ case "ISSUE_REVIEW":case "ISSUE_CREATE":case "ROLLOUT_START":return {@@ -46,13 +46,12 @@ const actionButtonProps = (action: UnifiedAction) => {return {type: "success" as const,};- case "ISSUE_REVIEW_RE_REQUEST":case "ISSUE_STATUS_REOPEN":- case "ISSUE_REVIEW_REJECT":case "ISSUE_STATUS_CLOSE":case "PLAN_CLOSE":case "PLAN_REOPEN":case "ROLLOUT_CANCEL":+ case "ROLLOUT_CREATE":return {type: "default" as const,};diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/action.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/action.tsindex 3c2836e594..25bbaeac86 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/action.ts+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/action.ts@@ -36,12 +36,72 @@ export const usePlanAction = () => {hasRunning: hasRunningPlanChecks,} = usePlanCheckStatus(plan);+ // Check if user can approve (is a candidate for current approval step)+ const canApprove = computed(() => {+ const issueValue = issue?.value;+ if (!issueValue) return false;++ const issueApproved =+ issueValue.approvalStatus === Issue_ApprovalStatus.APPROVED ||+ issueValue.approvalStatus === Issue_ApprovalStatus.SKIPPED;+ if (issueApproved) return false;++ const { approvers, approvalTemplate } = issueValue;+ const hasRejection = approvers.some(+ (app) => app.status === Issue_Approver_Status.REJECTED+ );+ // Cannot approve if already rejected+ if (hasRejection) return false;++ const roles = approvalTemplate?.flow?.roles ?? [];+ if (roles.length === 0) return false;++ const currentRoleIndex = approvers.length;+ const currentRole = roles[currentRoleIndex];+ if (!currentRole) return false;++ const candidates = candidatesOfApprovalStepV1(issueValue, currentRole);+ return isUserIncludedInList(currentUser.value.email, candidates);+ });++ // Check if user can reject (same as approve, but only if no rejection yet)+ const canReject = computed(() => {+ const issueValue = issue?.value;+ if (!issueValue) return false;++ const issueApproved =+ issueValue.approvalStatus === Issue_ApprovalStatus.APPROVED ||+ issueValue.approvalStatus === Issue_ApprovalStatus.SKIPPED;+ if (issueApproved) return false;++ const { approvers, approvalTemplate } = issueValue;+ const hasRejection = approvers.some(+ (app) => app.status === Issue_Approver_Status.REJECTED+ );+ // Cannot reject if already rejected+ if (hasRejection) return false;++ const roles = approvalTemplate?.flow?.roles ?? [];+ if (roles.length === 0) return false;++ const rejectedIndex = approvers.findIndex(+ (ap) => ap.status === Issue_Approver_Status.REJECTED+ );+ const currentRoleIndex =+ rejectedIndex >= 0 ? rejectedIndex : approvers.length;+ const currentRole = roles[currentRoleIndex];+ if (!currentRole) return false;++ const candidates = candidatesOfApprovalStepV1(issueValue, currentRole);+ return isUserIncludedInList(currentUser.value.email, candidates);+ });+/*** Compute available actions based on issue state and user permissions.** Action priority order:* 1. Plan-level actions (for draft plans): PLAN_REOPEN, PLAN_CLOSE, ISSUE_CREATE- * 2. Issue review actions: ISSUE_REVIEW_APPROVE, ISSUE_REVIEW_REJECT, ISSUE_REVIEW_RE_REQUEST+ * 2. Issue review action: ISSUE_REVIEW (unified approve/reject/comment)* 3. Issue status actions: ISSUE_STATUS_RESOLVE, ISSUE_STATUS_CLOSE, ISSUE_STATUS_REOPEN* 4. Rollout actions: ROLLOUT_START, ROLLOUT_CANCEL*@@ -101,7 +161,6 @@ export const usePlanAction = () => {const issueValue = issue?.value;// Should not reach here.if (!issueValue) return actions;- const issueCreator = extractUserId(issueValue.creator);const isCanceled = issueValue.status === IssueStatus.CANCELED;const isDone = issueValue.status === IssueStatus.DONE;const canUpdateIssue = hasProjectPermissionV2(@@ -125,47 +184,13 @@ export const usePlanAction = () => {return actions;}- // Check for review actions+ // Check for review action - show unified review button if user can approve or rejectconst issueApproved =issueValue.approvalStatus === Issue_ApprovalStatus.APPROVED ||issueValue.approvalStatus === Issue_ApprovalStatus.SKIPPED;if (!issueApproved) {- const { approvers, approvalTemplate } = issueValue;-- // Check if issue has been rejected- const hasRejection = approvers.some(- (app) => app.status === Issue_Approver_Status.REJECTED- );-- // RE_REQUEST is only available to the issue creator when rejected- if (hasRejection && currentUserEmail === issueCreator) {- actions.push("ISSUE_REVIEW_RE_REQUEST");- } else {- // Check if user can approve/reject- const roles = approvalTemplate?.flow?.roles ?? [];- if (roles.length > 0) {- const rejectedIndex = approvers.findIndex(- (ap) => ap.status === Issue_Approver_Status.REJECTED- );- const currentRoleIndex =- rejectedIndex >= 0 ? rejectedIndex : approvers.length;- const currentRole = roles[currentRoleIndex];-- if (currentRole) {- const candidates = candidatesOfApprovalStepV1(- issueValue,- currentRole- );- if (isUserIncludedInList(currentUserEmail, candidates)) {- actions.push("ISSUE_REVIEW_APPROVE");-- // Only show REJECT if no one has rejected yet.- if (!hasRejection) {- actions.push("ISSUE_REVIEW_REJECT");- }- }- }- }+ if (canApprove.value || canReject.value) {+ actions.push("ISSUE_REVIEW");}}@@ -276,12 +301,8 @@ export const usePlanAction = () => {const actionDisplayName = (action: UnifiedAction): string => {switch (action) {- case "ISSUE_REVIEW_APPROVE":- return t("common.approve");- case "ISSUE_REVIEW_REJECT":- return t("custom-approval.issue-review.send-back");- case "ISSUE_REVIEW_RE_REQUEST":- return t("custom-approval.issue-review.re-request-review");+ case "ISSUE_REVIEW":+ return t("issue.review.self");case "ISSUE_STATUS_CLOSE":return t("issue.batch-transition.close");case "ISSUE_STATUS_REOPEN":@@ -305,6 +326,8 @@ export const usePlanAction = () => {return {availableActions,+ canApprove,+ canReject,actionDisplayName,};};diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/index.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/index.tsindex 944b49c168..5187c5b849 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/index.ts+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/index.ts@@ -1,4 +1,5 @@export { usePlanAction } from "./action";+export { default as IssueReviewButton } from "./IssueReviewButton.vue";export { default as UnifiedActionButton } from "./UnifiedActionButton.vue";export { default as UnifiedActionGroup } from "./UnifiedActionGroup.vue";export * from "./types";diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/types.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/types.tsindex b7c9fcb0a0..f196520c66 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/types.ts+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/types.ts@@ -1,7 +1,4 @@-export type IssueReviewAction =- | "ISSUE_REVIEW_APPROVE"- | "ISSUE_REVIEW_REJECT"- | "ISSUE_REVIEW_RE_REQUEST";+export type IssueReviewAction = "ISSUE_REVIEW";export type IssueStatusAction =| "ISSUE_STATUS_CLOSE"diff --git a/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentList.vue b/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentList.vueindex 44af563c46..0f5be4cb2f 100644--- a/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentList.vue+++ b/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentList.vue@@ -77,6 +77,7 @@ import { NButton } from "naive-ui";import { computed, onMounted, watch, watchEffect } from "vue";import { useRoute } from "vue-router";import MarkdownEditor from "@/components/MarkdownEditor";+import { usePlanContext } from "@/components/Plan/logic";import UserAvatar from "@/components/User/UserAvatar.vue";import { useCurrentProjectV1, useIssueCommentStore } from "@/store";import { ListIssueCommentsRequestSchema } from "@/types/proto-es/v1/issue_service_pb";@@ -90,6 +91,7 @@ import IssueDescriptionComment from "./IssueCommentView/IssueDescriptionComment.const route = useRoute();const { project } = useCurrentProjectV1();+const { events } = usePlanContext();const issueCommentStore = useIssueCommentStore();const commentEdit = useCommentEdit(project);@@ -114,6 +116,9 @@ const fetchIssueComments = async () => {watchEffect(fetchIssueComments);+// Refresh comments when a review action is performed (approve/reject/re-request)+events.on("perform-issue-review-action", fetchIssueComments);+const issueComments = computed(() => {if (!issueName.value) return [];const list = issueCommentStore.getIssueComments(issueName.value);diff --git a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalStepItem.vue b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalStepItem.vueindex ae019ae3d8..9ffe01b2d6 100644--- a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalStepItem.vue+++ b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalStepItem.vue@@ -41,15 +41,30 @@</div></template><template v-else-if="status === 'rejected'">- <div class="flex items-center gap-1">- <span class="text-xs">{{- $t("custom-approval.issue-review.rejected-by")- }}</span>- <ApprovalUserView- v-if="stepApprover"- :candidate="stepApprover.principal"- size="tiny"- />+ <div class="flex flex-col gap-1">+ <div class="flex items-center gap-1">+ <span class="text-xs">{{+ $t("custom-approval.issue-review.rejected-by")+ }}</span>+ <ApprovalUserView+ v-if="stepApprover"+ :candidate="stepApprover.principal"+ size="tiny"+ />+ </div>+ <!-- Re-request review button for issue creator -->+ <div v-if="canReRequest" class="mt-1">+ <NButton+ size="tiny"+ :loading="reRequesting"+ @click="handleReRequestReview"+ >+ <template #icon>+ <RotateCcwIcon class="w-3 h-3" />+ </template>+ {{ $t("custom-approval.issue-review.re-request-review") }}+ </NButton>+ </div></div></template><template v-else-if="status === 'current'">@@ -69,13 +84,17 @@</template><script setup lang="ts">+import { create } from "@bufbuild/protobuf";import { computedAsync } from "@vueuse/core";import { uniq } from "lodash-es";-import { ThumbsUp, User, X } from "lucide-vue-next";-import { NTimelineItem } from "naive-ui";-import { computed, watchEffect } from "vue";+import { RotateCcwIcon, ThumbsUp, User, X } from "lucide-vue-next";+import { NButton, NTimelineItem } from "naive-ui";+import { computed, ref, watchEffect } from "vue";import { useI18n } from "vue-i18n";+import { usePlanContext } from "@/components/Plan/logic";+import { issueServiceClientConnect } from "@/grpcweb";import {+ pushNotification,useCurrentProjectV1,useCurrentUserV1,useGroupStore,@@ -90,7 +109,10 @@ import type {Issue,Issue_Approver,} from "@/types/proto-es/v1/issue_service_pb";-import { Issue_Approver_Status } from "@/types/proto-es/v1/issue_service_pb";+import {+ Issue_Approver_Status,+ RequestIssueRequestSchema,+} from "@/types/proto-es/v1/issue_service_pb";import type { User as UserType } from "@/types/proto-es/v1/user_service_pb";import {ensureUserFullName,@@ -109,6 +131,7 @@ const props = defineProps<{const { t } = useI18n();const { project } = useCurrentProjectV1();+const { events } = usePlanContext();const currentUser = useCurrentUserV1();const userStore = useUserStore();const roleStore = useRoleStore();@@ -116,6 +139,46 @@ const groupStore = useGroupStore();const projectIamPolicyStore = useProjectIamPolicyStore();const currentUserEmail = computed(() => currentUser.value.email);+const reRequesting = ref(false);++// Check if current user can re-request review (must be issue creator and step is rejected)+const canReRequest = computed(() => {+ const isCreator = props.issue.creator === `users/${currentUserEmail.value}`;+ const stepIsRejected =+ stepApprover.value?.status === Issue_Approver_Status.REJECTED;+ return isCreator && stepIsRejected;+});++const handleReRequestReview = async () => {+ if (reRequesting.value) return;++ reRequesting.value = true;+ try {+ const request = create(RequestIssueRequestSchema, {+ name: props.issue.name,+ });+ await issueServiceClientConnect.requestIssue(request);++ // Emit event to trigger issue refresh+ events.emit("perform-issue-review-action", { action: "ISSUE_REVIEW" });++ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("custom-approval.issue-review.re-request-review-success"),+ });+ } catch (error) {+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: t("common.failed"),+ description: String(error),+ });+ } finally {+ reRequesting.value = false;+ }+};+// Get the approver for this specific stepconst stepApprover = computed((): Issue_Approver | undefined => props.issue.approvers[props.stepIndex]diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 4527342108..2b4101e74b 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -219,6 +219,7 @@"resources": "Resources","closed": "Closed","refresh": "Refresh",+ "reject": "Reject","rollback": "Rollback","rows": {"self": "rows",@@ -1151,9 +1152,13 @@"description": "The selected database(s) has schema drift. Please make sure the drift is expected and safe to apply."},"review": {+ "self": "Review","approved": "Approved","rejected": "Rejected",- "under-review": "Under review"+ "under-review": "Under review",+ "comment-description": "Submit general feedback without approval",+ "approve-description": "Submit feedback and approve this issue",+ "reject-description": "Submit feedback and request changes"},"approval": {"rejected-error": "Issue approval has been rejected.",@@ -2720,6 +2725,7 @@"send-back-issue": "Send back issue?","re-request-review": "Re-request review","re-request-review-issue": "Re-request review issue?",+ "re-request-review-success": "Review re-requested successfully","sent-back-issue": "Sent back issue","re-requested-review": "re-requested issue review","approved-by": "Approved by",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex d6737d3fb0..fe3d948eac 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -219,6 +219,7 @@"resources": "Recursos","closed": "Cerrado","refresh": "Actualizar",+ "reject": "Rechazar","rollback": "Retroceder","rows": {"self": "filas",@@ -1151,9 +1152,13 @@"description": "Las bases de datos seleccionadas presentan una desviación de esquema. Asegúrese de que la desviación sea la esperada y de que sea segura para su aplicación."},"review": {+ "self": "Revisar","approved": "Aprobado","rejected": "Rechazado",- "under-review": "Bajo revisión"+ "under-review": "Bajo revisión",+ "comment-description": "Enviar comentarios generales sin aprobación",+ "approve-description": "Enviar comentarios y aprobar este problema",+ "reject-description": "Envíe comentarios y solicite cambios"},"approval": {"rejected-error": "Se ha rechazado la aprobación del problema.",@@ -2720,6 +2725,7 @@"send-back-issue": "¿Devolver el problema?","re-request-review": "Volver a solicitar revisión","re-request-review-issue": "¿Volver a solicitar revisión?",+ "re-request-review-success": "Revisión solicitada nuevamente con éxito","sent-back-issue": "Problema devuelto","re-requested-review": "revisión de problema nuevamente solicitada","approved-by": "Aprobado por",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex ec4e6fa06b..33d21c4f78 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -219,6 +219,7 @@"resources": "リソース","closed": "閉まっている","refresh": "リフレッシュ",+ "reject": "拒否する","rollback": "ロールバック","rows": {"self": "行",@@ -1151,9 +1152,13 @@"description": "選択したデータベースにはスキーマドリフトがあります。ドリフトが想定どおりであり、適用しても安全であることを確認してください。"},"review": {+ "self": "レビュー","approved": "承認された","rejected": "拒否",- "under-review": "審査中"+ "under-review": "審査中",+ "comment-description": "承認なしで一般的なフィードバックを送信する",+ "approve-description": "フィードバックを送信してこの問題を承認する",+ "reject-description": "フィードバックを送信して変更をリクエストする"},"approval": {"rejected-error": "問題の承認が拒否されました。",@@ -2720,6 +2725,7 @@"send-back-issue": "イシューを却下しますか?","re-request-review": "再度承認をリクエストする","re-request-review-issue": "イシューの承認を再度リクエストしますか?",+ "re-request-review-success": "レビューの再リクエストが完了しました","sent-back-issue": "イシューを却下する","re-requested-review": "イシューの承認を再度リクエストします","approved-by": "承認者",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 6bb9e59d6c..43b7d9c243 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -219,6 +219,7 @@"resources": "Tài nguyên","closed": "Đã đóng","refresh": "Làm mới",+ "reject": "Từ chối","rollback": "Hoàn tác","rows": {"self": "dòng",@@ -1151,9 +1152,13 @@"description": "Cơ sở dữ liệu được chọn có sự trôi dạt lược đồ. Vui lòng đảm bảo rằng sự trôi dạt này được mong đợi và an toàn để áp dụng."},"review": {+ "self": "Ôn tập","approved": "Tán thành","rejected": "Vật bị loại bỏ",- "under-review": "Đang xem xét"+ "under-review": "Đang xem xét",+ "comment-description": "Gửi phản hồi chung mà không cần phê duyệt",+ "approve-description": "Gửi phản hồi và phê duyệt vấn đề này.",+ "reject-description": "Gửi phản hồi và yêu cầu thay đổi"},"approval": {"rejected-error": "Đã từ chối phê duyệt vấn đề.",@@ -2720,6 +2725,7 @@"send-back-issue": "Gửi lại vấn đề?","re-request-review": "Yêu cầu xem xét lại","re-request-review-issue": "Yêu cầu xem xét lại vấn đề?",+ "re-request-review-success": "Yêu cầu xem xét lại đã được thực hiện thành công.","sent-back-issue": "Đã gửi lại vấn đề","re-requested-review": "đã yêu cầu xem xét lại vấn đề","approved-by": "Được chấp thuận bởi",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 778cc4dcb2..20a2806da3 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -219,6 +219,7 @@"resources": "资源","closed": "已关闭","refresh": "刷新",+ "reject": "驳回","rollback": "回滚","rows": {"self": "行",@@ -1151,9 +1152,13 @@"description": "所选数据库存在 Schema 偏差,请在变更前确保该偏差符合预期。"},"review": {+ "self": "审批","approved": "已批准",- "rejected": "已拒绝",- "under-review": "等待审批"+ "rejected": "已驳回",+ "under-review": "等待审批",+ "comment-description": "提交反馈,不进行批准操作",+ "approve-description": "提交反馈并批准此工单",+ "reject-description": "提交反馈并要求修改"},"approval": {"rejected-error": "此工单已被退回。",@@ -2720,6 +2725,7 @@"send-back-issue": "退回工单?","re-request-review": "请求再次审批","re-request-review-issue": "请求再次审批工单?",+ "re-request-review-success": "已成功请求再次审批","sent-back-issue": "退回工单","re-requested-review": "再次请求审批工单","approved-by": "已批准",