Skip to content

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

refactor(frontend): improve IssueReviewView sidebar structure and maintainability (#18905)

boojacka42d57a3b77d
diff --git a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalFlowSection.vue b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalFlowSection.vue
index 8ee7b780b7..d1788344c7 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalFlowSection.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalFlowSection.vue
@@ -2,6 +2,12 @@
<div>
<div class="w-full flex flex-row items-center gap-2">
<h3 class="textlabel">{{ $t("issue.approval-flow.self") }}</h3>
+ <span
+ v-if="approvalTemplate?.title?.trim()"
+ class="text-sm text-control-placeholder"
+ >
+ · {{ approvalTemplate.title }}
+ </span>
<FeatureBadge :feature="PlanFeature.FEATURE_APPROVAL_WORKFLOW" />
<RiskLevelIcon :risk-level="issue.riskLevel" />
</div>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalStepItem.vue b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalStepItem.vue
index ba68e0f837..ca972c79d9 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalStepItem.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalStepItem.vue
@@ -5,121 +5,80 @@
class="p-1 rounded-full flex items-center justify-center z-10"
:class="iconClass"
>
- <template v-if="status === 'approved'">
- <ThumbsUp class="w-4 h-4 text-white" />
- </template>
- <template v-else-if="status === 'rejected'">
- <X class="w-4 h-4 text-white" />
- </template>
- <template v-else-if="status === 'current'">
- <User class="w-4 h-4 text-white" />
- </template>
- <template v-else>
- <div class="flex w-4 h-4 justify-center items-center">
- <span class="text-sm font-medium text-gray-600">{{
- stepNumber
- }}</span>
- </div>
- </template>
+ <ThumbsUp v-if="status === 'approved'" class="w-4 h-4 text-white" />
+ <X v-else-if="status === 'rejected'" class="w-4 h-4 text-white" />
+ <User v-else-if="status === 'current'" class="w-4 h-4 text-white" />
+ <div v-else class="flex w-4 h-4 justify-center items-center">
+ <span class="text-sm font-medium text-gray-600">{{ stepNumber }}</span>
+ </div>
</div>
</template>
+
<div>
<div class="text-sm font-medium text-gray-900">
{{ roleName }}
</div>
+
<div class="mt-1 text-sm text-gray-600">
- <template v-if="status === 'approved'">
+ <!-- Approved -->
+ <div v-if="status === 'approved'" class="flex flex-col items-start gap-1">
+ <span class="text-xs">
+ {{ $t("custom-approval.issue-review.approved-by") }}
+ </span>
+ <ApprovalUserView
+ v-if="stepApprover"
+ :candidate="stepApprover.principal"
+ />
+ </div>
+
+ <!-- Rejected -->
+ <div v-else-if="status === 'rejected'" class="flex flex-col gap-1">
<div class="flex flex-col items-start gap-1">
- <span class="text-xs">{{
- $t("custom-approval.issue-review.approved-by")
- }}</span>
+ <span class="text-xs">
+ {{ $t("custom-approval.issue-review.rejected-by") }}
+ </span>
<ApprovalUserView
v-if="stepApprover"
:candidate="stepApprover.principal"
/>
</div>
- </template>
- <template v-else-if="status === 'rejected'">
- <div class="flex flex-col gap-1">
- <div class="flex flex-col items-start gap-1">
- <span class="text-xs">{{
- $t("custom-approval.issue-review.rejected-by")
- }}</span>
- <ApprovalUserView
- v-if="stepApprover"
- :candidate="stepApprover.principal"
- />
- </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'">
- <div class="flex flex-col gap-1">
- <PotentialApprovers :users="potentialApprovers" />
- <div
- v-if="showSelfApprovalTip"
- class="px-1 py-0.5 border rounded-sm text-xs bg-yellow-50 border-yellow-600 text-yellow-600"
+ <div v-if="canReRequest" class="mt-1">
+ <NButton
+ size="tiny"
+ :loading="reRequesting"
+ @click="handleReRequestReview"
>
- {{ $t("custom-approval.issue-review.self-approval-not-allowed") }}
- </div>
+ <template #icon>
+ <RotateCcwIcon class="w-3 h-3" />
+ </template>
+ {{ $t("custom-approval.issue-review.re-request-review") }}
+ </NButton>
+ </div>
+ </div>
+
+ <!-- Current -->
+ <div v-else-if="status === 'current'" class="flex flex-col gap-1">
+ <PotentialApprovers :users="potentialApprovers" />
+ <div
+ v-if="showSelfApprovalTip"
+ class="px-1 py-0.5 border rounded-sm text-xs bg-yellow-50 border-yellow-600 text-yellow-600"
+ >
+ {{ $t("custom-approval.issue-review.self-approval-not-allowed") }}
</div>
- </template>
+ </div>
</div>
</div>
</NTimelineItem>
</template>
<script setup lang="ts">
-import { create } from "@bufbuild/protobuf";
-import { computedAsync } from "@vueuse/core";
-import { uniq } from "lodash-es";
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 { useIssueContext } from "@/components/IssueV1";
-import { tryUsePlanContext } from "@/components/Plan/logic";
-import { issueServiceClientConnect } from "@/connect";
-import {
- pushNotification,
- useCurrentProjectV1,
- useCurrentUserV1,
- useGroupStore,
- useProjectIamPolicyStore,
- useRoleStore,
- useUserStore,
-} from "@/store";
-import { userNamePrefix } from "@/store/modules/v1/common";
-import { groupBindingPrefix, PresetRoleType, SYSTEM_BOT_EMAIL } from "@/types";
-import { State } from "@/types/proto-es/v1/common_pb";
-import type {
- Issue,
- Issue_Approver,
-} 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,
- isBindingPolicyExpired,
- memberMapToRolesInProjectIAM,
-} from "@/utils";
+import { computed, toRef } from "vue";
+import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
import ApprovalUserView from "./ApprovalUserView.vue";
import PotentialApprovers from "./PotentialApprovers.vue";
+import { useApprovalStep } from "./useApprovalStep";
const props = defineProps<{
step: string;
@@ -128,95 +87,21 @@ const props = defineProps<{
issue: Issue;
}>();
-const { t } = useI18n();
-const { project } = useCurrentProjectV1();
-
-// Try to get plan context, fallback to issue context if not available (legacy layout)
-const planContext = tryUsePlanContext();
-const issueContext = planContext ? undefined : useIssueContext();
-const currentUser = useCurrentUserV1();
-const userStore = useUserStore();
-const roleStore = useRoleStore();
-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
- if (planContext) {
- planContext.events.emit("status-changed", { eager: true });
- } else {
- issueContext?.events.emit("status-changed", { eager: true });
- }
-
- 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 step
-const stepApprover = computed(
- (): Issue_Approver | undefined => props.issue.approvers[props.stepIndex]
+const {
+ status,
+ stepApprover,
+ roleName,
+ canReRequest,
+ reRequesting,
+ handleReRequestReview,
+ potentialApprovers,
+ showSelfApprovalTip,
+} = useApprovalStep(
+ toRef(props, "issue"),
+ toRef(props, "step"),
+ toRef(props, "stepIndex")
);
-const status = computed((): "approved" | "rejected" | "current" | "pending" => {
- if (stepApprover.value?.status === Issue_Approver_Status.APPROVED) {
- return "approved";
- }
-
- if (stepApprover.value?.status === Issue_Approver_Status.REJECTED) {
- return "rejected";
- }
-
- // Check if all previous steps are approved
- for (let i = 0; i < props.stepIndex; i++) {
- const prevApprover = props.issue.approvers[i];
- if (
- !prevApprover ||
- (prevApprover.status !== Issue_Approver_Status.APPROVED &&
- prevApprover.status !== Issue_Approver_Status.REJECTED)
- ) {
- return "pending";
- }
- // If any previous step is rejected, subsequent steps are pending
- if (prevApprover.status === Issue_Approver_Status.REJECTED) {
- return "pending";
- }
- }
-
- return "current";
-});
-
const timelineItemType = computed(() => {
switch (status.value) {
case "approved":
@@ -242,127 +127,4 @@ const iconClass = computed(() => {
return "bg-gray-200";
}
});
-
-const roleName = computed((): string => {
- // Get role name from the step (which is now a role string)
- if (props.step) {
- const role = props.step;
- if (role === PresetRoleType.PROJECT_OWNER) {
- return t("role.project-owner.self");
- } else if (role === PresetRoleType.WORKSPACE_DBA) {
- return t("role.workspace-dba.self");
- } else if (role === PresetRoleType.WORKSPACE_ADMIN) {
- return t("role.workspace-admin.self");
- }
- const customRole = roleStore.getRoleByName(role);
- if (customRole) {
- return customRole.title;
- }
- }
- return t("custom-approval.approval-flow.node.approver");
-});
-
-const stepRoles = computed(() => {
- return [props.step].filter((role) => !!role);
-});
-
-watchEffect(async () => {
- const groupNames: string[] = [];
-
- for (const role of stepRoles.value) {
- const policy = projectIamPolicyStore.getProjectIamPolicy(
- project.value.name
- );
- for (const binding of policy.bindings) {
- if (binding.role !== role || isBindingPolicyExpired(binding)) {
- continue;
- }
- for (const member of binding.members) {
- if (member.startsWith(groupBindingPrefix)) {
- groupNames.push(member);
- }
- }
- }
- }
-
- await groupStore.batchGetOrFetchGroups(groupNames);
-});
-
-// Get candidates for this approval step
-const candidateEmails = computed(() => {
- const candidates: string[] = [];
-
- for (const role of stepRoles.value) {
- // Get users with this role from project IAM policy
- const policy = projectIamPolicyStore.getProjectIamPolicy(
- project.value.name
- );
- const memberMap = memberMapToRolesInProjectIAM(policy, role);
- candidates.push(...memberMap.keys());
- }
-
- // Filter and deduplicate
- return uniq(
- candidates.filter((user) => {
- // Exclude system bot
- if (user === `${userNamePrefix}${SYSTEM_BOT_EMAIL}`) return false;
- return true;
- })
- );
-});
-
-// Check if current user would be excluded due to self-approval settings
-const isCurrentUserInCandidates = computed(() => {
- const currentUserPrincipal = `users/${currentUserEmail.value}`;
- return candidateEmails.value.includes(currentUserPrincipal);
-});
-
-// Filter candidates based on self-approval settings
-const filteredCandidateEmails = computed(() => {
- if (
- !project.value.allowSelfApproval &&
- props.issue.creator === `users/${currentUserEmail.value}`
- ) {
- // Remove current user from candidates if self-approval is not allowed and they are the creator
- const currentUserPrincipal = `users/${currentUserEmail.value}`;
- return candidateEmails.value.filter(
- (email) => email !== currentUserPrincipal
- );
- }
- return candidateEmails.value;
-});
-
-// Show tip when self-approval is disabled and current user is in candidates but excluded
-const showSelfApprovalTip = computed(() => {
- return (
- status.value === "current" &&
- !project.value.allowSelfApproval &&
- props.issue.creator === `users/${currentUserEmail.value}` &&
- isCurrentUserInCandidates.value
- );
-});
-
-// Fetch user objects for candidates
-const potentialApprovers = computedAsync(async () => {
- if (
- status.value !== "current" ||
- filteredCandidateEmails.value.length === 0
- ) {
- return [];
- }
-
- const users = await userStore.batchGetOrFetchUsers(
- filteredCandidateEmails.value.map(ensureUserFullName)
- );
- // Sort to put current user first if they're in the list
- return (
- users.filter((user) => {
- return user && user.state === State.ACTIVE;
- }) as UserType[]
- ).sort((a, b) => {
- if (a.email === currentUserEmail.value) return -1;
- if (b.email === currentUserEmail.value) return 1;
- return a.title.localeCompare(b.title);
- });
-}, []);
</script>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/useApprovalStep.ts b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/useApprovalStep.ts
new file mode 100644
index 0000000000..b585922cea
--- /dev/null
+++ b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/useApprovalStep.ts
@@ -0,0 +1,249 @@
+import { create } from "@bufbuild/protobuf";
+import { computedAsync } from "@vueuse/core";
+import { uniq } from "lodash-es";
+import type { Ref } from "vue";
+import { computed, ref, watchEffect } from "vue";
+import { useI18n } from "vue-i18n";
+import { useIssueContext } from "@/components/IssueV1";
+import { tryUsePlanContext } from "@/components/Plan/logic";
+import { issueServiceClientConnect } from "@/connect";
+import {
+ pushNotification,
+ useCurrentProjectV1,
+ useCurrentUserV1,
+ useGroupStore,
+ useProjectIamPolicyStore,
+ useRoleStore,
+ useUserStore,
+} from "@/store";
+import { userNamePrefix } from "@/store/modules/v1/common";
+import { groupBindingPrefix, PresetRoleType, SYSTEM_BOT_EMAIL } from "@/types";
+import { State } from "@/types/proto-es/v1/common_pb";
+import type {
+ Issue,
+ Issue_Approver,
+} 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,
+ isBindingPolicyExpired,
+ memberMapToRolesInProjectIAM,
+} from "@/utils";
+
+export type ApprovalStepStatus =
+ | "approved"
+ | "rejected"
+ | "current"
+ | "pending";
+
+export function useApprovalStep(
+ issue: Ref<Issue>,
+ step: Ref<string>,
+ stepIndex: Ref<number>
+) {
+ const { t } = useI18n();
+ const { project } = useCurrentProjectV1();
+ const planContext = tryUsePlanContext();
+ const issueContext = planContext ? undefined : useIssueContext();
+ const currentUser = useCurrentUserV1();
+ const userStore = useUserStore();
+ const roleStore = useRoleStore();
+ const groupStore = useGroupStore();
+ const projectIamPolicyStore = useProjectIamPolicyStore();
+
+ const currentUserEmail = computed(() => currentUser.value.email);
+ const reRequesting = ref(false);
+
+ // Get the approver for this specific step
+ const stepApprover = computed(
+ (): Issue_Approver | undefined => issue.value.approvers[stepIndex.value]
+ );
+
+ const status = computed((): ApprovalStepStatus => {
+ if (stepApprover.value?.status === Issue_Approver_Status.APPROVED) {
+ return "approved";
+ }
+ if (stepApprover.value?.status === Issue_Approver_Status.REJECTED) {
+ return "rejected";
+ }
+ // Check if all previous steps are approved
+ for (let i = 0; i < stepIndex.value; i++) {
+ const prevApprover = issue.value.approvers[i];
+ if (
+ !prevApprover ||
+ (prevApprover.status !== Issue_Approver_Status.APPROVED &&
+ prevApprover.status !== Issue_Approver_Status.REJECTED)
+ ) {
+ return "pending";
+ }
+ if (prevApprover.status === Issue_Approver_Status.REJECTED) {
+ return "pending";
+ }
+ }
+ return "current";
+ });
+
+ const canReRequest = computed(() => {
+ const isCreator = issue.value.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: issue.value.name,
+ });
+ await issueServiceClientConnect.requestIssue(request);
+ if (planContext) {
+ planContext.events.emit("status-changed", { eager: true });
+ } else {
+ issueContext?.events.emit("status-changed", { eager: true });
+ }
+
+ 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;
+ }
+ };
+
+ const roleName = computed((): string => {
+ if (step.value) {
+ const role = step.value;
+ if (role === PresetRoleType.PROJECT_OWNER) {
+ return t("role.project-owner.self");
+ } else if (role === PresetRoleType.WORKSPACE_DBA) {
+ return t("role.workspace-dba.self");
+ } else if (role === PresetRoleType.WORKSPACE_ADMIN) {
+ return t("role.workspace-admin.self");
+ }
+ const customRole = roleStore.getRoleByName(role);
+ if (customRole) {
+ return customRole.title;
+ }
+ }
+ return t("custom-approval.approval-flow.node.approver");
+ });
+
+ const stepRoles = computed(() => {
+ return [step.value].filter((role) => !!role);
+ });
+
+ // Pre-fetch groups for the step
+ watchEffect(async () => {
+ const groupNames: string[] = [];
+ for (const role of stepRoles.value) {
+ const policy = projectIamPolicyStore.getProjectIamPolicy(
+ project.value.name
+ );
+ for (const binding of policy.bindings) {
+ if (binding.role !== role || isBindingPolicyExpired(binding)) {
+ continue;
+ }
+ for (const member of binding.members) {
+ if (member.startsWith(groupBindingPrefix)) {
+ groupNames.push(member);
+ }
+ }
+ }
+ }
+ await groupStore.batchGetOrFetchGroups(groupNames);
+ });
+
+ // Get candidates for this approval step
+ const candidateEmails = computed(() => {
+ const candidates: string[] = [];
+ for (const role of stepRoles.value) {
+ const policy = projectIamPolicyStore.getProjectIamPolicy(
+ project.value.name
+ );
+ const memberMap = memberMapToRolesInProjectIAM(policy, role);
+ candidates.push(...memberMap.keys());
+ }
+ return uniq(
+ candidates.filter((user) => {
+ if (user === `${userNamePrefix}${SYSTEM_BOT_EMAIL}`) return false;
+ return true;
+ })
+ );
+ });
+
+ const isCurrentUserInCandidates = computed(() => {
+ const currentUserPrincipal = `users/${currentUserEmail.value}`;
+ return candidateEmails.value.includes(currentUserPrincipal);
+ });
+
+ const filteredCandidateEmails = computed(() => {
+ if (
+ !project.value.allowSelfApproval &&
+ issue.value.creator === `users/${currentUserEmail.value}`
+ ) {
+ const currentUserPrincipal = `users/${currentUserEmail.value}`;
+ return candidateEmails.value.filter(
+ (email) => email !== currentUserPrincipal
+ );
+ }
+ return candidateEmails.value;
+ });
+
+ const showSelfApprovalTip = computed(() => {
+ return (
+ status.value === "current" &&
+ !project.value.allowSelfApproval &&
+ issue.value.creator === `users/${currentUserEmail.value}` &&
+ isCurrentUserInCandidates.value
+ );
+ });
+
+ const potentialApprovers = computedAsync(async () => {
+ if (
+ status.value !== "current" ||
+ filteredCandidateEmails.value.length === 0
+ ) {
+ return [];
+ }
+
+ const users = await userStore.batchGetOrFetchUsers(
+ filteredCandidateEmails.value.map(ensureUserFullName)
+ );
+ return (
+ users.filter((user) => {
+ return user && user.state === State.ACTIVE;
+ }) as UserType[]
+ ).sort((a, b) => {
+ if (a.email === currentUserEmail.value) return -1;
+ if (b.email === currentUserEmail.value) return 1;
+ return a.title.localeCompare(b.title);
+ });
+ }, []);
+
+ return {
+ status,
+ stepApprover,
+ roleName,
+ canReRequest,
+ reRequesting,
+ handleReRequestReview,
+ potentialApprovers,
+ showSelfApprovalTip,
+ };
+}
diff --git a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ChecksSection.vue b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ChecksSection.vue
new file mode 100644
index 0000000000..32294616d1
--- /dev/null
+++ b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ChecksSection.vue
@@ -0,0 +1,104 @@
+<template>
+ <div class="flex flex-col gap-y-1">
+ <div class="flex items-center justify-between">
+ <h3 class="textlabel">
+ {{ $t("plan.navigator.checks") }}
+ </h3>
+ <NButton
+ v-if="allowRunChecks"
+ size="tiny"
+ :loading="isRunningChecks"
+ @click="runChecks"
+ >
+ <template #icon>
+ <PlayIcon class="w-4 h-4" />
+ </template>
+ {{ $t("common.run") }}
+ </NButton>
+ </div>
+ <div class="flex items-center gap-2">
+ <PlanCheckStatusCount
+ :plan="plan"
+ clickable
+ @click="selectedResultStatus = $event"
+ />
+ <span v-if="!hasAnyChecks" class="text-sm text-control-placeholder">
+ {{ $t("plan.overview.no-checks") }}
+ </span>
+ </div>
+
+ <ChecksDrawer
+ v-if="selectedResultStatus"
+ :status="selectedResultStatus"
+ @close="selectedResultStatus = undefined"
+ />
+ </div>
+</template>
+
+<script setup lang="ts">
+import { create } from "@bufbuild/protobuf";
+import type { ConnectError } from "@connectrpc/connect";
+import { PlayIcon } from "lucide-vue-next";
+import { NButton } from "naive-ui";
+import { computed, ref } from "vue";
+import { planServiceClientConnect } from "@/connect";
+import {
+ extractUserId,
+ pushNotification,
+ useCurrentProjectV1,
+ useCurrentUserV1,
+} from "@/store";
+import { RunPlanChecksRequestSchema } from "@/types/proto-es/v1/plan_service_pb";
+import { Advice_Level } from "@/types/proto-es/v1/sql_service_pb";
+import { hasProjectPermissionV2 } from "@/utils";
+import { usePlanCheckStatus, usePlanContext } from "../../../logic";
+import { useResourcePoller } from "../../../logic/poller";
+import ChecksDrawer from "../../ChecksView/ChecksDrawer.vue";
+import PlanCheckStatusCount from "../../PlanCheckStatusCount.vue";
+
+const currentUser = useCurrentUserV1();
+const { plan } = usePlanContext();
+const { project } = useCurrentProjectV1();
+const { refreshResources } = useResourcePoller();
+const { hasAnyStatus: hasAnyChecks } = usePlanCheckStatus(plan);
+
+const isRunningChecks = ref(false);
+const selectedResultStatus = ref<Advice_Level | undefined>(undefined);
+
+const allowRunChecks = computed(() => {
+ const me = currentUser.value;
+ if (extractUserId(plan.value.creator) === me.email) {
+ return true;
+ }
+ return hasProjectPermissionV2(project.value, "bb.planCheckRuns.run");
+});
+
+const runChecks = async () => {
+ if (!plan.value.name) return;
+
+ isRunningChecks.value = true;
+ try {
+ const request = create(RunPlanChecksRequestSchema, {
+ name: plan.value.name,
+ });
+ await planServiceClientConnect.runPlanChecks(request);
+
+ refreshResources(["plan", "planCheckRuns"], true);
+
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: "Plan checks started",
+ });
+ } catch (error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: "Failed to run plan checks",
+ description: (error as ConnectError).message,
+ });
+ } finally {
+ isRunningChecks.value = false;
+ }
+};
+</script>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/DatabaseChangeSection.vue b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/DatabaseChangeSection.vue
deleted file mode 100644
index f6eef0341a..0000000000
--- a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/DatabaseChangeSection.vue
+++ /dev/null
@@ -1,188 +0,0 @@
-<template>
- <template v-if="shouldShowSection">
- <!-- Stages -->
- <div v-if="rollout" class="flex flex-col gap-y-1">
- <h3 class="textlabel">
- {{ $t("rollout.stage.self", 2) }}
- </h3>
- <div class="flex flex-wrap items-center gap-y-1">
- <template v-if="rollout.stages.length > 0">
- <template
- v-for="(stage, index) in rollout.stages"
- :key="stage.name"
- >
- <div
- class="flex items-center gap-1 cursor-pointer hover:opacity-80 transition-opacity"
- @click="navigateToStage(stage.name)"
- >
- <TaskStatus
- :status="getStageStatus(stage)"
- size="small"
- disabled
- />
- <EnvironmentV1Name
- :environment="getEnvironmentEntity(stage.environment)"
- :link="false"
- :null-environment-placeholder="'Null'"
- />
- </div>
- <span
- v-if="index < rollout.stages.length - 1"
- class="mx-2 text-control-placeholder"
- >
- →
- </span>
- </template>
- </template>
- <span v-else class="text-sm text-control-placeholder">
- {{ $t("common.no-data") }}
- </span>
- </div>
- </div>
-
- <!-- SQL Checks -->
- <div class="flex flex-col gap-y-1">
- <div class="flex items-center justify-between">
- <h3 class="textlabel">
- {{ $t("plan.navigator.checks") }}
- </h3>
- <NButton
- v-if="allowRunChecks"
- size="tiny"
- :loading="isRunningChecks"
- @click="runChecks"
- >
- <template #icon>
- <PlayIcon class="w-4 h-4" />
- </template>
- {{ $t("common.run") }}
- </NButton>
- </div>
- <div class="flex items-center gap-2">
- <PlanCheckStatusCount
- :plan="plan"
- clickable
- @click="selectedResultStatus = $event"
- />
- <span v-if="!hasAnyChecks" class="text-sm text-control-placeholder">
- {{ $t("plan.overview.no-checks") }}
- </span>
- </div>
- </div>
-
- <NDivider class="my-0!" />
-
- <ChecksDrawer
- v-if="selectedResultStatus"
- :status="selectedResultStatus"
- @close="selectedResultStatus = undefined"
- />
- </template>
-</template>
-
-<script setup lang="ts">
-import { create } from "@bufbuild/protobuf";
-import type { ConnectError } from "@connectrpc/connect";
-import { PlayIcon } from "lucide-vue-next";
-import { NButton, NDivider } from "naive-ui";
-import { computed, ref } from "vue";
-import { useRouter } from "vue-router";
-import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
-import { EnvironmentV1Name } from "@/components/v2";
-import { planServiceClientConnect } from "@/connect";
-import { PROJECT_V1_ROUTE_PLAN_ROLLOUT_STAGE } from "@/router/dashboard/projectV1";
-import {
- extractUserId,
- pushNotification,
- useCurrentProjectV1,
- useCurrentUserV1,
- useEnvironmentV1Store,
-} from "@/store";
-import { Issue_Type } from "@/types/proto-es/v1/issue_service_pb";
-import { RunPlanChecksRequestSchema } from "@/types/proto-es/v1/plan_service_pb";
-import { Advice_Level } from "@/types/proto-es/v1/sql_service_pb";
-import {
- extractPlanUIDFromRolloutName,
- extractProjectResourceName,
- getStageStatus,
- hasProjectPermissionV2,
-} from "@/utils";
-import { usePlanCheckStatus, usePlanContext } from "../../../logic";
-import { useResourcePoller } from "../../../logic/poller";
-import ChecksDrawer from "../../ChecksView/ChecksDrawer.vue";
-import PlanCheckStatusCount from "../../PlanCheckStatusCount.vue";
-
-const currentUser = useCurrentUserV1();
-const { plan, rollout, issue } = usePlanContext();
-const environmentStore = useEnvironmentV1Store();
-const router = useRouter();
-const { project } = useCurrentProjectV1();
-const { refreshResources } = useResourcePoller();
-const { hasAnyStatus: hasAnyChecks } = usePlanCheckStatus(plan);
-
-const isRunningChecks = ref(false);
-const selectedResultStatus = ref<Advice_Level | undefined>(undefined);
-
-const allowRunChecks = computed(() => {
- const me = currentUser.value;
- if (extractUserId(plan.value.creator) === me.email) {
- return true;
- }
- return hasProjectPermissionV2(project.value, "bb.planCheckRuns.run");
-});
-
-const shouldShowSection = computed(() => {
- return issue.value?.type === Issue_Type.DATABASE_CHANGE || rollout?.value;
-});
-
-const getEnvironmentEntity = (environmentName: string) => {
- return environmentStore.getEnvironmentByName(environmentName);
-};
-
-const navigateToStage = (stageName: string) => {
- if (!rollout?.value) return;
-
- const planId = extractPlanUIDFromRolloutName(rollout.value.name);
- const stageId = stageName.split("/").pop();
-
- if (!planId || !stageId) return;
-
- router.push({
- name: PROJECT_V1_ROUTE_PLAN_ROLLOUT_STAGE,
- params: {
- projectId: extractProjectResourceName(project.value.name),
- planId,
- stageId,
- },
- });
-};
-
-const runChecks = async () => {
- if (!plan.value.name) return;
-
- isRunningChecks.value = true;
- try {
- const request = create(RunPlanChecksRequestSchema, {
- name: plan.value.name,
- });
- await planServiceClientConnect.runPlanChecks(request);
-
- refreshResources(["plan", "planCheckRuns"], true);
-
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: "Plan checks started",
- });
- } catch (error) {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: "Failed to run plan checks",
- description: (error as ConnectError).message,
- });
- } finally {
- isRunningChecks.value = false;
- }
-};
-</script>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/IssueStatusSection.vue b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/IssueStatusSection.vue
deleted file mode 100644
index 79327950e7..0000000000
--- a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/IssueStatusSection.vue
+++ /dev/null
@@ -1,68 +0,0 @@
-<template>
- <div v-if="issueStatusText" class="w-full flex flex-row justify-between items-center gap-2">
- <h3 class="textlabel">
- {{ $t("common.status") }}
- </h3>
- <NTag :type="issueStatusTagType" size="medium" round>
- {{ issueStatusText }}
- </NTag>
- </div>
-</template>
-
-<script setup lang="ts">
-import { NTag } from "naive-ui";
-import { computed } from "vue";
-import { useI18n } from "vue-i18n";
-import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
-import {
- Issue_ApprovalStatus,
- Issue_Approver_Status,
- IssueStatus,
-} from "@/types/proto-es/v1/issue_service_pb";
-
-const props = defineProps<{
- issue: Issue;
-}>();
-
-const { t } = useI18n();
-
-const isRejected = computed(() =>
- props.issue.approvers.some(
- (app) => app.status === Issue_Approver_Status.REJECTED
- )
-);
-
-const issueStatusText = computed(() => {
- const issueValue = props.issue;
- if (issueValue.status !== IssueStatus.OPEN) {
- return "";
- }
-
- // Issue is rollout-ready if approved, skipped, or has no approval required (empty flow)
- const roles = issueValue.approvalTemplate?.flow?.roles ?? [];
- const noApprovalRequired = roles.length === 0;
- const rolloutReady =
- issueValue.approvalStatus === Issue_ApprovalStatus.APPROVED ||
- issueValue.approvalStatus === Issue_ApprovalStatus.SKIPPED ||
- noApprovalRequired;
- if (rolloutReady) {
- return t("issue.review.approved");
- }
- if (isRejected.value) {
- return t("issue.review.rejected");
- }
- return t("issue.review.under-review");
-});
-
-const issueStatusTagType = computed(() => {
- const issueValue = props.issue;
- if (issueValue.status !== IssueStatus.OPEN) {
- return "default";
- }
-
- if (isRejected.value) {
- return "error";
- }
- return "success";
-});
-</script>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/Sidebar.vue b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/Sidebar.vue
index e0fa6ead74..8dea0d16aa 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/Sidebar.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/Sidebar.vue
@@ -1,11 +1,15 @@
<template>
<div class="w-full flex flex-col p-4 gap-4">
- <DatabaseChangeSection v-if="isDatabaseChangePlan" />
+ <!-- 1. Stages - Progress indicator -->
+ <StagesSection v-if="isDatabaseChangePlan" />
- <IssueStatusSection v-if="issue.approvalTemplate" :issue="issue" />
+ <!-- 2. Checks - Health status -->
+ <ChecksSection v-if="isDatabaseChangePlan" />
+ <!-- 3. Approval Flow - Reviewers -->
<ApprovalFlowSection :issue="issue" />
+ <!-- 4. Labels - Metadata -->
<IssueLabels
:project="project"
:value="issue.labels || []"
@@ -35,8 +39,8 @@ import {
import { hasProjectPermissionV2 } from "@/utils";
import { usePlanContextWithIssue } from "../../../logic/context";
import ApprovalFlowSection from "./ApprovalFlowSection/ApprovalFlowSection.vue";
-import DatabaseChangeSection from "./DatabaseChangeSection.vue";
-import IssueStatusSection from "./IssueStatusSection.vue";
+import ChecksSection from "./ChecksSection.vue";
+import StagesSection from "./StagesSection.vue";
const { t } = useI18n();
const { plan, issue } = usePlanContextWithIssue();
diff --git a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/StagesSection.vue b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/StagesSection.vue
new file mode 100644
index 0000000000..cfc69c8be2
--- /dev/null
+++ b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/StagesSection.vue
@@ -0,0 +1,74 @@
+<template>
+ <div v-if="rollout" class="flex flex-col gap-y-1">
+ <h3 class="textlabel">
+ {{ $t("rollout.stage.self", 2) }}
+ </h3>
+ <div class="flex flex-wrap items-center gap-y-1">
+ <template v-if="rollout.stages.length > 0">
+ <template v-for="(stage, index) in rollout.stages" :key="stage.name">
+ <div
+ class="flex items-center gap-1 cursor-pointer hover:opacity-80 transition-opacity"
+ @click="navigateToStage(stage.name)"
+ >
+ <TaskStatus :status="getStageStatus(stage)" size="small" disabled />
+ <EnvironmentV1Name
+ :environment="getEnvironmentEntity(stage.environment)"
+ :link="false"
+ :null-environment-placeholder="'Null'"
+ />
+ </div>
+ <span
+ v-if="index < rollout.stages.length - 1"
+ class="mx-2 text-control-placeholder"
+ >
+ →
+ </span>
+ </template>
+ </template>
+ <span v-else class="text-sm text-control-placeholder">
+ {{ $t("common.no-data") }}
+ </span>
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { useRouter } from "vue-router";
+import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
+import { EnvironmentV1Name } from "@/components/v2";
+import { PROJECT_V1_ROUTE_PLAN_ROLLOUT_STAGE } from "@/router/dashboard/projectV1";
+import { useCurrentProjectV1, useEnvironmentV1Store } from "@/store";
+import {
+ extractPlanUIDFromRolloutName,
+ extractProjectResourceName,
+ getStageStatus,
+} from "@/utils";
+import { usePlanContext } from "../../../logic";
+
+const { rollout } = usePlanContext();
+const environmentStore = useEnvironmentV1Store();
+const router = useRouter();
+const { project } = useCurrentProjectV1();
+
+const getEnvironmentEntity = (environmentName: string) => {
+ return environmentStore.getEnvironmentByName(environmentName);
+};
+
+const navigateToStage = (stageName: string) => {
+ if (!rollout?.value) return;
+
+ const planId = extractPlanUIDFromRolloutName(rollout.value.name);
+ const stageId = stageName.split("/").pop();
+
+ if (!planId || !stageId) return;
+
+ router.push({
+ name: PROJECT_V1_ROUTE_PLAN_ROLLOUT_STAGE,
+ params: {
+ projectId: extractProjectResourceName(project.value.name),
+ planId,
+ stageId,
+ },
+ });
+};
+</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index a1c9b7d5b6..9074e5825c 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1148,9 +1148,6 @@
},
"review": {
"self": "Review",
- "approved": "Approved",
- "rejected": "Rejected",
- "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"
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 82d7bf1800..831acaec66 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1148,9 +1148,6 @@
},
"review": {
"self": "Revisar",
- "approved": "Aprobado",
- "rejected": "Rechazado",
- "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"
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 9a2cdd6b2c..1734e77149 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1148,9 +1148,6 @@
},
"review": {
"self": "レビュー",
- "approved": "承認された",
- "rejected": "拒否",
- "under-review": "審査中",
"comment-description": "承認なしで一般的なフィードバックを送信する",
"approve-description": "フィードバックを送信してこの問題を承認する",
"reject-description": "フィードバックを送信して変更をリクエストする"
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index cf8b6496cf..38c4a4c14d 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1148,9 +1148,6 @@
},
"review": {
"self": "Ôn tập",
- "approved": "Tán thành",
- "rejected": "Vật bị loại bỏ",
- "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"
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 3d61f7ae91..9be4f0bfb8 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1148,9 +1148,6 @@
},
"review": {
"self": "审批",
- "approved": "已批准",
- "rejected": "已驳回",
- "under-review": "等待审批",
"comment-description": "提交反馈,不进行批准操作",
"approve-description": "提交反馈并批准此工单",
"reject-description": "提交反馈并要求修改"