Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: stage page (#16801)
boojackf78e87801dca
diff --git a/frontend/src/components/Plan/components/ChecksView/ChecksView.vue b/frontend/src/components/Plan/components/ChecksView/ChecksView.vueindex 8dc939544a..c9f076fdff 100644--- a/frontend/src/components/Plan/components/ChecksView/ChecksView.vue+++ b/frontend/src/components/Plan/components/ChecksView/ChecksView.vue@@ -122,14 +122,11 @@:class="getStatusColor(result.status)"/>- <div class="flex-1 min-w-0">+ <div class="flex-1 min-w-0 space-y-1"><div class="text-sm font-medium text-main">- {{ result.title }}+ {{ getResultTitle(result) }}</div>- <div- v-if="result.content"- class="text-xs text-control-light mt-1"- >+ <div v-if="result.content" class="text-xs text-control">{{ result.content }}</div><div@@ -164,10 +161,12 @@ import {} from "lucide-vue-next";import { computed, ref } from "vue";import { useI18n } from "vue-i18n";+import { getRuleLocalization } from "@/types";import {PlanCheckRun_Result_Status,PlanCheckRun_Type,type PlanCheckRun,+ type PlanCheckRun_Result,} from "@/types/proto-es/v1/plan_service_pb";import { humanizeTs } from "@/utils";import { usePlanContext } from "../../logic/context";@@ -326,4 +325,28 @@ const formatTime = (timestamp: Timestamp | undefined): string => {new Date(Number(timestamp.seconds) * 1000).getTime() / 1000);};++const messageWithCode = (message: string, code: number | undefined): string => {+ if (code !== undefined && code !== 0) {+ return `${message} #${code}`;+ }+ return message;+};++const getResultTitle = (result: PlanCheckRun_Result): string => {+ let title = result.title;+ if (title === "OK" || title === "Syntax error") {+ return title;+ }+ // Only apply SQL review localization if this is a SQL review report+ if (result.report?.case === "sqlReviewReport") {+ // Convert dots to hyphens in the rule key to match the expected format+ const normalizedKey = title.replace(/\./g, "-");+ // Use getRuleLocalization to get the title+ const localization = getRuleLocalization(normalizedKey);+ title = localization.title;+ }+ // Add error code if present+ return messageWithCode(title, result.code);+};</script>diff --git a/frontend/src/components/Plan/components/Configuration/Configuration.vue b/frontend/src/components/Plan/components/Configuration/Configuration.vueindex 9caa853cbc..20c1b6733f 100644--- a/frontend/src/components/Plan/components/Configuration/Configuration.vue+++ b/frontend/src/components/Plan/components/Configuration/Configuration.vue@@ -14,7 +14,7 @@import { computed } from "vue";import { useCurrentProjectV1 } from "@/store";import { usePlanContext } from "../../logic";-import { usePlanSpecContext } from "../SpecDetailView/context";+import { useSelectedSpec } from "../SpecDetailView/context";import GhostSection from "./GhostSection";import { provideGhostSettingContext } from "./GhostSection/context";import PreBackupSection from "./PreBackupSection";@@ -22,7 +22,7 @@ import { providePreBackupSettingContext } from "./PreBackupSection/context";const { project } = useCurrentProjectV1();const { isCreating, plan, events, issue, rollout } = usePlanContext();-const { selectedSpec } = usePlanSpecContext();+const selectedSpec = useSelectedSpec();const { shouldShow: shouldShowGhostSection, events: ghostEvents } =provideGhostSettingContext({diff --git a/frontend/src/components/Plan/components/Configuration/GhostSection/GhostFlagsPanel.vue b/frontend/src/components/Plan/components/Configuration/GhostSection/GhostFlagsPanel.vueindex 9ef470e6be..8657967be8 100644--- a/frontend/src/components/Plan/components/Configuration/GhostSection/GhostFlagsPanel.vue+++ b/frontend/src/components/Plan/components/Configuration/GhostSection/GhostFlagsPanel.vue@@ -122,15 +122,13 @@ const trySave = async () => {plan: planPatch,updateMask: { paths: ["specs"] },});- const response = await planServiceClientConnect.updatePlan(request);- Object.assign(plan.value, response);-+ await planServiceClientConnect.updatePlan(request);+ events.emit("update");pushNotification({module: "bytebase",style: "SUCCESS",title: t("common.updated"),});- events.emit("update");}close();};diff --git a/frontend/src/components/Plan/components/Configuration/GhostSection/GhostSwitch.vue b/frontend/src/components/Plan/components/Configuration/GhostSection/GhostSwitch.vueindex 8851857fe9..fb7b4b58c8 100644--- a/frontend/src/components/Plan/components/Configuration/GhostSection/GhostSwitch.vue+++ b/frontend/src/components/Plan/components/Configuration/GhostSection/GhostSwitch.vue@@ -155,15 +155,13 @@ const toggleChecked = async (on: boolean) => {plan: planPatch,updateMask: { paths: ["specs"] },});- const response = await planServiceClientConnect.updatePlan(request);- Object.assign(plan.value, response);-+ await planServiceClientConnect.updatePlan(request);+ events.emit("update");pushNotification({module: "bytebase",style: "SUCCESS",title: t("common.updated"),});- events.emit("update");}};</script>diff --git a/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts b/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.tsindex 420690f92d..ce4d03cd10 100644--- a/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts+++ b/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts@@ -56,7 +56,7 @@ export const providePreBackupSettingContext = (refs: {const { isCreating, project, plan, selectedSpec, issue, rollout } = refs;const events = new Emittery<{- update: boolean;+ update: never;}>();const databases = computed(() => {@@ -149,10 +149,10 @@ export const providePreBackupSettingContext = (refs: {}} else {const planPatch = cloneDeep(unref(plan));- const spec = (planPatch?.specs || []).find((s) => {+ const spec = planPatch.specs.find((s) => {return s.id === selectedSpec.value?.id;});- if (!planPatch || !spec || spec.config?.case !== "changeDatabaseConfig") {+ if (!planPatch || !spec || spec.config.case !== "changeDatabaseConfig") {// Should not reach here.throw new Error("Plan or spec is not defined. Cannot update pre-backup setting."@@ -172,7 +172,7 @@ export const providePreBackupSettingContext = (refs: {}// Emit the update event.- events.emit("update", on);+ events.emit("update");};const context = {diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vueindex 8db13967a2..64fcd51533 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue@@ -29,6 +29,7 @@<script setup lang="ts">import { create } from "@bufbuild/protobuf";+import { includes } from "lodash-es";import { NTooltip, NButton } from "naive-ui";import { zindexable as vZindexable } from "vdirs";import { computed, nextTick, ref } from "vue";@@ -44,7 +45,12 @@ import {} from "@/components/Plan/logic";import { usePlanContext } from "@/components/Plan/logic";import { planServiceClientConnect } from "@/grpcweb";-import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "@/router/dashboard/projectV1";+import {+ PROJECT_V1_ROUTE_PLAN_DETAIL,+ PROJECT_V1_ROUTE_PLAN_DETAIL_CHECK_RUNS,+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,+} from "@/router/dashboard/projectV1";import { useCurrentProjectV1, useSheetV1Store } from "@/store";import { CreatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";import { type Plan_ChangeDatabaseConfig } from "@/types/proto-es/v1/plan_service_pb";@@ -93,8 +99,24 @@ const doCreatePlan = async () => {if (!createdPlan) return;nextTick(() => {+ let routeName = router.currentRoute.value.name;+ if (routeName === PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL) {+ routeName = PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS;+ }+ if (+ !includes(+ [+ PROJECT_V1_ROUTE_PLAN_DETAIL,+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,+ PROJECT_V1_ROUTE_PLAN_DETAIL_CHECK_RUNS,+ ],+ routeName+ )+ ) {+ routeName = PROJECT_V1_ROUTE_PLAN_DETAIL;+ }router.replace({- name: PROJECT_V1_ROUTE_PLAN_DETAIL,+ name: routeName,params: {projectId: extractProjectResourceName(createdPlan.name),planId: extractPlanUID(createdPlan.name),diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vueindex 33fa9c2168..fe0e3e5ec2 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue@@ -8,17 +8,17 @@<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("plan.self") }}</div>- <div class="textinfolabel">+ <div class="text-control">{{ $t("plan.self") }}</div>+ <div class="font-medium">{{ plan.title }}</div></div><div class="flex flex-col gap-y-1">- <div class="font-medium text-control">+ <div class="text-control">{{ $t("common.description") }}</div>- <div class="textinfolabel">+ <div class="textlabel">{{ plan.description || "No description" }}</div></div>@@ -30,7 +30,7 @@class="w-full flex flex-row justify-end items-center gap-2"><div class="flex justify-end gap-x-3">- <NButton @click="$emit('close')">+ <NButton @click="$emit('close')" quaternary>{{ $t("common.cancel") }}</NButton>@@ -41,7 +41,7 @@:disabled="confirmErrors.length > 0"@click="handleConfirm">- {{ $t("common.create") }}+ {{ $t("common.confirm") }}</NButton></template><template #default>diff --git a/frontend/src/components/Plan/components/Overview.vue b/frontend/src/components/Plan/components/Overview.vueindex 63e60efea5..fa49984090 100644--- a/frontend/src/components/Plan/components/Overview.vue+++ b/frontend/src/components/Plan/components/Overview.vue@@ -52,7 +52,7 @@v-if="statistics.checkStatus.error > 0"class="flex items-center gap-1">- <XCircleIcon class="w-6 h-6 text-error" />+ <XCircleIcon class="w-5 h-5 text-error" /><span class="text-xl font-semibold text-error">{{statistics.checkStatus.error}}</span>@@ -61,7 +61,7 @@v-if="statistics.checkStatus.warning > 0"class="flex items-center gap-1">- <AlertCircleIcon class="w-6 h-6 text-warning" />+ <AlertCircleIcon class="w-5 h-5 text-warning" /><span class="text-xl font-semibold text-warning">{{statistics.checkStatus.warning}}</span>@@ -70,7 +70,7 @@v-if="statistics.checkStatus.success > 0"class="flex items-center gap-1">- <CheckCircleIcon class="w-6 h-6 text-success" />+ <CheckCircleIcon class="w-5 h-5 text-success" /><span class="text-xl font-semibold text-success">{{statistics.checkStatus.success}}</span>@@ -191,16 +191,20 @@ const statistics = computed(() => {const checkStatus = {total: 0,success:- plan.value.planCheckRunStatusCount[PlanCheckRun_Result_Status.SUCCESS] ||- 0,+ plan.value.planCheckRunStatusCount[+ PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.SUCCESS]+ ] || 0,warning:- plan.value.planCheckRunStatusCount[PlanCheckRun_Result_Status.WARNING] ||- 0,+ plan.value.planCheckRunStatusCount[+ PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.WARNING]+ ] || 0,error:- plan.value.planCheckRunStatusCount[PlanCheckRun_Result_Status.ERROR] || 0,+ plan.value.planCheckRunStatusCount[+ PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.ERROR]+ ] || 0,};checkStatus.total =- checkStatus.success + checkStatus.warning + checkStatus.error || 0;+ checkStatus.success + checkStatus.warning + checkStatus.error;for (const spec of plan.value.specs) {totalTargets += targetsForSpec(spec).length;}diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vueindex a0cd9cb38e..b41c640d16 100644--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue@@ -81,12 +81,12 @@ import { planSpecHasPlanChecks } from "../../logic";import { usePlanContext } from "../../logic/context";import { useResourcePoller } from "../../logic/poller";import ChecksDrawer from "../ChecksView/ChecksDrawer.vue";-import { usePlanSpecContext } from "../SpecDetailView/context";+import { useSelectedSpec } from "../SpecDetailView/context";const currentUser = useCurrentUserV1();const { project } = useCurrentProjectV1();const { plan } = usePlanContext();-const { selectedSpec } = usePlanSpecContext();+const selectedSpec = useSelectedSpec();const { requestEnhancedPolling } = useResourcePoller();const isRunningChecks = ref(false);diff --git a/frontend/src/components/Plan/components/RolloutView/RolloutView.vue b/frontend/src/components/Plan/components/RolloutView/RolloutView.vueindex d466e9551d..6075902945 100644--- a/frontend/src/components/Plan/components/RolloutView/RolloutView.vue+++ b/frontend/src/components/Plan/components/RolloutView/RolloutView.vue@@ -47,9 +47,9 @@ import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";import StagesView from "./StagesView.vue";import TaskFilter from "./TaskFilter.vue";import TaskTableView from "./TaskTableView.vue";-import { provideRolloutViewContext } from "./context";+import { useRolloutViewContext } from "./context";-const { rollout, mergedStages } = provideRolloutViewContext();+const { rollout, mergedStages } = useRolloutViewContext();const isTableView = ref(false);const taskStatusFilter = ref<Task_Status[]>([]);diff --git a/frontend/src/components/Plan/components/RolloutView/StageCard.vue b/frontend/src/components/Plan/components/RolloutView/StageCard.vueindex beacde8e47..c55c751d08 100644--- a/frontend/src/components/Plan/components/RolloutView/StageCard.vue+++ b/frontend/src/components/Plan/components/RolloutView/StageCard.vue@@ -11,7 +11,11 @@class="w-full flex flex-row justify-between items-center gap-2 px-2 pt-2 pb-1"><div class="flex items-center space-x-1">- <span class="text-base font-medium">+ <span+ class="text-base font-medium"+ :class="[isCreated && 'cursor-pointer hover:underline']"+ @click="handleClickStageTitle"+ >{{ environmentStore.getEnvironmentByName(stage.environment).title }}</span><NTag v-if="!isCreated" round size="tiny">{{@@ -103,7 +107,10 @@ import { useRouter } from "vue-router";import { semanticTaskType } from "@/components/IssueV1";import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";import { rolloutServiceClientConnect } from "@/grpcweb";-import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL } from "@/router/dashboard/projectV1";+import {+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,+} from "@/router/dashboard/projectV1";import {useCurrentProjectV1,useEnvironmentV1Store,@@ -235,4 +242,24 @@ const createRolloutToStage = async () => {});}};++const handleClickStageTitle = () => {+ // Only navigate if the stage is created+ if (!isCreated.value) return;++ const rolloutId = rollout.value.name.split("/").pop();+ const stageId = props.stage.name.split("/").pop();++ if (!rolloutId || !stageId) return;++ // Navigate to the stage detail route+ router.push({+ name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,+ params: {+ projectId: extractProjectResourceName(project.value.name),+ rolloutId,+ stageId,+ },+ });+};</script>diff --git a/frontend/src/components/Plan/components/RolloutView/StageView.vue b/frontend/src/components/Plan/components/RolloutView/StageView.vuenew file mode 100644index 0000000000..26ec01f284--- /dev/null+++ b/frontend/src/components/Plan/components/RolloutView/StageView.vue@@ -0,0 +1,99 @@+<template>+ <div v-if="stage" class="w-full h-full flex flex-col">+ <div class="px-4">+ <!-- Stage Header -->+ <div class="w-full flex flex-row pt-2 pb-4 gap-2">+ <NTag round>{{ $t("common.stage") }}</NTag>+ <span class="font-medium text-lg">{{ environmentTitle }}</span>+ </div>++ <!-- Task Filter -->+ <TaskFilter+ :rollout="rollout || emptyRollout"+ :task-status-list="taskStatusFilter"+ :stage="stage"+ @update:task-status-list="taskStatusFilter = $event"+ />+ </div>++ <!-- Tasks Table View -->+ <div class="flex-1 min-h-0">+ <TaskTableView :task-status-filter="taskStatusFilter" :stage="stage" />+ </div>+ </div>+</template>++<script setup lang="ts">+import { create } from "@bufbuild/protobuf";+import { NTag } from "naive-ui";+import { computed, ref, watchEffect } from "vue";+import { useI18n } from "vue-i18n";+import { useRoute } from "vue-router";+import { rolloutServiceClientConnect } from "@/grpcweb";+import { useCurrentProjectV1, useEnvironmentV1Store } from "@/store";+import type { Stage, Rollout } from "@/types/proto-es/v1/rollout_service_pb";+import {+ GetRolloutRequestSchema,+ RolloutSchema,+ Task_Status,+} from "@/types/proto-es/v1/rollout_service_pb";+import TaskFilter from "./TaskFilter.vue";+import TaskTableView from "./TaskTableView.vue";++const props = defineProps<{+ rolloutId: string;+ stageId: string;+}>();++const { t: _t } = useI18n();+const route = useRoute();+const { project } = useCurrentProjectV1();+const environmentStore = useEnvironmentV1Store();++const rolloutRef = ref<Rollout>();+const routeStageRef = ref<Stage>();+const taskStatusFilter = ref<Task_Status[]>([]);++// Create an empty rollout for TaskFilter when rollout is not available+const emptyRollout = create(RolloutSchema, {});++// Get the stage - either from props or from fetched rollout+const stage = computed(() => {+ if (routeStageRef.value) return routeStageRef.value;+ return undefined;+});++// Get rollout+const rollout = computed(() => rolloutRef.value);++// Fetch rollout and stage when in route mode+watchEffect(async () => {+ const rolloutId = props.rolloutId || (route.params.rolloutId as string);+ const stageId = props.stageId || (route.params.stageId as string);++ if (!rolloutId || !stageId) return;++ try {+ const rolloutName = `projects/${project.value.name.split("/")[1]}/rollouts/${rolloutId}`;+ const request = create(GetRolloutRequestSchema, { name: rolloutName });+ const rollout = await rolloutServiceClientConnect.getRollout(request);+ rolloutRef.value = rollout;++ // Find the specific stage+ for (const rolloutStage of rollout.stages) {+ if (rolloutStage.name.endsWith(`/${stageId}`)) {+ routeStageRef.value = rolloutStage;+ return;+ }+ }+ } catch (error) {+ console.error("Failed to fetch rollout:", error);+ }+});++// Stage environment info+const environmentTitle = computed(() => {+ if (!stage.value) return "";+ return environmentStore.getEnvironmentByName(stage.value.environment).title;+});+</script>diff --git a/frontend/src/components/Plan/components/RolloutView/TaskFilter.vue b/frontend/src/components/Plan/components/RolloutView/TaskFilter.vueindex ea20141721..90c6144ad0 100644--- a/frontend/src/components/Plan/components/RolloutView/TaskFilter.vue+++ b/frontend/src/components/Plan/components/RolloutView/TaskFilter.vue@@ -1,7 +1,7 @@<template><div class="flex flex-row justify-start items-center gap-4"><div class="flex items-center justify-between">- <h3 class="text-base font-medium">+ <h3 class="text-base">{{ $t("common.tasks") }}</h3></div>@@ -48,14 +48,16 @@ import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";import type {Rollout,Task_Status,+ Stage,} from "@/types/proto-es/v1/rollout_service_pb";import { Task_Status as TaskStatusEnum } from "@/types/proto-es/v1/rollout_service_pb";import { stringifyTaskStatus } from "@/utils";import { useRolloutViewContext } from "./context";-defineProps<{+const props = defineProps<{rollout: Rollout;taskStatusList: Task_Status[];+ stage?: Stage;}>();const emit = defineEmits<{@@ -75,6 +77,11 @@ const TASK_STATUS_FILTERS: Task_Status[] = [];const allTasks = computed(() => {+ if (props.stage) {+ // If a specific stage is provided, use only its tasks+ return props.stage.tasks;+ }+ // Otherwise, use all tasks from all stagesreturn flatten(mergedStages.value.map((stage) => stage.tasks));});diff --git a/frontend/src/components/Plan/components/RolloutView/TaskTable.vue b/frontend/src/components/Plan/components/RolloutView/TaskTable.vueindex de772c1da6..d3aba162b8 100644--- a/frontend/src/components/Plan/components/RolloutView/TaskTable.vue+++ b/frontend/src/components/Plan/components/RolloutView/TaskTable.vue@@ -28,7 +28,11 @@ import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";import { InstanceV1EngineIcon } from "@/components/v2";import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL } from "@/router/dashboard/projectV1";import { useCurrentProjectV1, useEnvironmentV1Store } from "@/store";-import type { Task, Task_Status } from "@/types/proto-es/v1/rollout_service_pb";+import type {+ Task,+ Task_Status,+ Stage,+} from "@/types/proto-es/v1/rollout_service_pb";import { databaseForTask } from "@/utils";import {extractProjectResourceName,@@ -40,6 +44,7 @@ const props = withDefaults(defineProps<{taskStatusFilter: Task_Status[];selectedTasks?: Task[];+ stage?: Stage;}>(),{selectedTasks: () => [],@@ -58,7 +63,15 @@ const environmentStore = useEnvironmentV1Store();const { rollout, mergedStages } = useRolloutViewContext();const taskList = computed(() => {- const allTasks = flatten(rollout.value.stages.map((stage) => stage.tasks));+ let allTasks: Task[];+ if (props.stage) {+ // If a specific stage is provided, use only its tasks+ allTasks = props.stage.tasks;+ } else {+ // Otherwise, use all tasks from all stages+ allTasks = flatten(rollout.value.stages.map((stage) => stage.tasks));+ }+if (props.taskStatusFilter.length === 0) {return allTasks;}@@ -152,21 +165,26 @@ const columnList = computed((): DataTableColumn<Task>[] => {return <TaskStatus status={task.status} size="small" />;},},- {- key: "stage",- title: t("common.stage"),- width: 120,- render: (task) => {- const stage = stageMap.value.get(task.name);- if (stage) {- const environment = environmentStore.getEnvironmentByName(- stage.environment- );- return environment.title;- }- return "-";- },- },+ // Only show stage column if not already filtering by stage+ ...(!props.stage+ ? [+ {+ key: "stage",+ title: t("common.stage"),+ width: 120,+ render: (task: Task) => {+ const stage = stageMap.value.get(task.name);+ if (stage) {+ const environment = environmentStore.getEnvironmentByName(+ stage.environment+ );+ return environment.title;+ }+ return "-";+ },+ },+ ]+ : []),{key: "type",width: 120,diff --git a/frontend/src/components/Plan/components/RolloutView/TaskTableView.vue b/frontend/src/components/Plan/components/RolloutView/TaskTableView.vueindex d6101f352e..9dd20a9941 100644--- a/frontend/src/components/Plan/components/RolloutView/TaskTableView.vue+++ b/frontend/src/components/Plan/components/RolloutView/TaskTableView.vue@@ -11,8 +11,9 @@<!-- Task Table --><div class="flex-1 overflow-hidden"><TaskTable- :task-status-filter="taskStatusFilter"+ :task-status-filter="props.taskStatusFilter":selected-tasks="selectedTasks"+ :stage="props.stage"@update:selected-tasks="handleSelectedTasksUpdate"@refresh="handleRefresh"/>@@ -22,13 +23,18 @@<script setup lang="ts">import { ref } from "vue";-import type { Task, Task_Status } from "@/types/proto-es/v1/rollout_service_pb";+import type {+ Task,+ Task_Status,+ Stage,+} from "@/types/proto-es/v1/rollout_service_pb";import { usePlanContextWithRollout } from "../../logic";import TaskOperations from "./TaskOperations.vue";import TaskTable from "./TaskTable.vue";-defineProps<{+const props = defineProps<{taskStatusFilter: Task_Status[];+ stage?: Stage;}>();const { rollout, events } = usePlanContextWithRollout();diff --git a/frontend/src/components/Plan/components/RolloutView/TaskView.vue b/frontend/src/components/Plan/components/RolloutView/TaskView.vueindex d3b0711b3d..79afa38a41 100644--- a/frontend/src/components/Plan/components/RolloutView/TaskView.vue+++ b/frontend/src/components/Plan/components/RolloutView/TaskView.vue@@ -102,11 +102,9 @@ import TaskRunTable from "./TaskRunTable.vue";import TaskStatusActions from "./TaskStatusActions.vue";const props = defineProps<{- task?: Task;- // Route parameters for when used in router- stageId?: string;- taskId?: string;- rolloutId?: string;+ rolloutId: string;+ stageId: string;+ taskId: string;}>();const { t: _t } = useI18n();@@ -117,22 +115,14 @@ const taskRunsRef = ref<TaskRun[]>([]);const rolloutRef = ref<Rollout>();const routeTaskRef = ref<Task>();-// Determine if we're in route mode or prop mode-const isRouteMode = computed(- () => !props.task && (props.stageId || props.taskId)-);-// Get the task - either from props or from fetched rolloutconst task = computed(() => {- if (props.task) return props.task;if (routeTaskRef.value) return routeTaskRef.value;return unknownTask();});// Fetch rollout and task when in route modewatchEffect(async () => {- if (!isRouteMode.value) return;-const rolloutId = props.rolloutId || (route.params.rolloutId as string);const stageId = props.stageId || (route.params.stageId as string);const taskId = props.taskId || (route.params.taskId as string);@@ -230,33 +220,30 @@ const handleTaskActionCompleted = async () => {}}- // Refresh rollout data in route mode- if (isRouteMode.value) {- const rolloutId = props.rolloutId || (route.params.rolloutId as string);- const stageId = props.stageId || (route.params.stageId as string);- const taskId = props.taskId || (route.params.taskId as string);-- if (rolloutId && stageId && taskId) {- try {- const rolloutName = `projects/${project.value.name.split("/")[1]}/rollouts/${rolloutId}`;- const request = create(GetRolloutRequestSchema, { name: rolloutName });- const rollout = await rolloutServiceClientConnect.getRollout(request);- rolloutRef.value = rollout;+ const rolloutId = props.rolloutId || (route.params.rolloutId as string);+ const stageId = props.stageId || (route.params.stageId as string);+ const taskId = props.taskId || (route.params.taskId as string);- // Update the task reference- for (const stage of rollout.stages) {- if (stage.name.endsWith(`/${stageId}`)) {- for (const stageTask of stage.tasks) {- if (stageTask.name.endsWith(`/${taskId}`)) {- routeTaskRef.value = stageTask;- return;- }+ if (rolloutId && stageId && taskId) {+ try {+ const rolloutName = `projects/${project.value.name.split("/")[1]}/rollouts/${rolloutId}`;+ const request = create(GetRolloutRequestSchema, { name: rolloutName });+ const rollout = await rolloutServiceClientConnect.getRollout(request);+ rolloutRef.value = rollout;++ // Update the task reference+ for (const stage of rollout.stages) {+ if (stage.name.endsWith(`/${stageId}`)) {+ for (const stageTask of stage.tasks) {+ if (stageTask.name.endsWith(`/${taskId}`)) {+ routeTaskRef.value = stageTask;+ return;}}}- } catch (error) {- console.error("Failed to refresh rollout:", error);}+ } catch (error) {+ console.error("Failed to refresh rollout:", error);}}};diff --git a/frontend/src/components/Plan/components/SQLCheckV1Section/SQLCheckV1Section.vue b/frontend/src/components/Plan/components/SQLCheckV1Section/SQLCheckV1Section.vueindex 9b28ccec58..74157a2f42 100644--- a/frontend/src/components/Plan/components/SQLCheckV1Section/SQLCheckV1Section.vue+++ b/frontend/src/components/Plan/components/SQLCheckV1Section/SQLCheckV1Section.vue@@ -131,11 +131,11 @@ import { Advice_Status, type Advice } from "@/types/proto-es/v1/sql_service_pb";import { getSheetStatement, isNullOrUndefined } from "@/utils";import { usePlanContext } from "../../logic/context";import { targetsForSpec } from "../../logic/plan";-import { usePlanSpecContext } from "../SpecDetailView/context";+import { useSelectedSpec } from "../SpecDetailView/context";import DatabaseDisplay from "../common/DatabaseDisplay.vue";const { plan } = usePlanContext();-const { selectedSpec } = usePlanSpecContext();+const selectedSpec = useSelectedSpec();const isRunningChecks = ref(false);const drawerVisible = ref(false);diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vueindex b4620805b9..b32be7b484 100644--- a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue@@ -13,12 +13,26 @@</template><script setup lang="ts">+import type { Ref } from "vue";+import { useCurrentProjectV1 } from "@/store";+import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";import { usePlanContext } from "../../logic/context";import Configuration from "../Configuration";import PlanCheckSection from "../PlanCheckSection";+import { providePlanSQLCheckContext } from "../SQLCheckSection";import SQLCheckV1Section from "../SQLCheckV1Section";import StatementSection from "../StatementSection";import TargetListSection from "./TargetListSection.vue";+import { useSelectedSpec } from "./context";-const { isCreating } = usePlanContext();+const { project } = useCurrentProjectV1();+const { isCreating, plan } = usePlanContext();++const selectedSpec = useSelectedSpec();++providePlanSQLCheckContext({+ project,+ plan,+ selectedSpec: selectedSpec as Ref<Plan_Spec>,+});</script>diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vueindex bee65f864b..943cb6c72c 100644--- a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue@@ -136,7 +136,7 @@ import { usePlanContext } from "../../logic/context";import { targetsForSpec } from "../../logic/plan";import AllTargetsDrawer from "./AllTargetsDrawer.vue";import TargetsSelectorDrawer from "./TargetsSelectorDrawer.vue";-import { usePlanSpecContext } from "./context";+import { useSelectedSpec } from "./context";interface TargetRow {target: string;@@ -153,8 +153,8 @@ const DEFAULT_VISIBLE_TARGETS = 20;const { t } = useI18n();const router = useRouter();-const { plan, isCreating, events } = usePlanContext();-const { selectedSpec } = usePlanSpecContext();+const { plan, isCreating } = usePlanContext();+const selectedSpec = useSelectedSpec();const instanceStore = useInstanceV1Store();const databaseStore = useDatabaseV1Store();const dbGroupStore = useDBGroupStore();@@ -283,9 +283,6 @@ const handleUpdateTargets = async (targets: string[]) => {});const response = await planServiceClientConnect.updatePlan(request);Object.assign(plan.value, response);- events.emit("status-changed", {- eager: true,- });pushNotification({module: "bytebase",style: "SUCCESS",diff --git a/frontend/src/components/Plan/components/SpecDetailView/context.ts b/frontend/src/components/Plan/components/SpecDetailView/context.tsindex 1b482ce558..a4a809e862 100644--- a/frontend/src/components/Plan/components/SpecDetailView/context.ts+++ b/frontend/src/components/Plan/components/SpecDetailView/context.ts@@ -1,29 +1,11 @@import { head } from "lodash-es";-import {- computed,- inject,- provide,- watchEffect,- type InjectionKey,- type Ref,-} from "vue";-import { useRoute, useRouter } from "vue-router";-import { type Plan } from "@/types/proto-es/v1/plan_service_pb";-import { gotoSpec } from "../common/utils";+import { computed } from "vue";+import { useRoute } from "vue-router";+import { usePlanContext } from "../../logic";-const KEY = Symbol("bb.plan.spec.detail") as InjectionKey<PlanSpecContext>;--export const usePlanSpecContext = () => {- return inject(KEY)!;-};--export const providePlanSpecContext = (refs: {- isCreating: Ref<boolean>;- plan: Ref<Plan>;-}) => {+export const useSelectedSpec = () => {const route = useRoute();- const router = useRouter();- const { plan } = refs;+ const { plan } = usePlanContext();const selectedSpec = computed(() => {if (plan.value.specs.length === 0) {@@ -42,27 +24,5 @@ export const providePlanSpecContext = (refs: {return foundSpec;});- // Auto-redirect if the specId in the route does not match any spec in the plan.- watchEffect(() => {- const specNotFound = !plan.value.specs.some(- (spec) => spec.id === route.params.specId- );- if (specNotFound) {- const foundSpec = head(plan.value.specs);- if (!foundSpec) {- throw new Error("No specs available in the plan to redirect to.");- }- gotoSpec(router, foundSpec.id);- }- });-- const context = {- selectedSpec,- };-- provide(KEY, context);-- return context;+ return selectedSpec;};--type PlanSpecContext = ReturnType<typeof providePlanSpecContext>;diff --git a/frontend/src/components/Plan/components/SpecsView.vue b/frontend/src/components/Plan/components/SpecsView.vuedeleted file mode 100644index 5245cba092..0000000000--- a/frontend/src/components/Plan/components/SpecsView.vue+++ /dev/null@@ -1,29 +0,0 @@-<template>- <div class="w-full flex-1 flex pt-2 pb-4">- <SpecDetailView :key="selectedSpec.id" />- </div>-</template>--<script setup lang="ts">-import { type Ref } from "vue";-import { useCurrentProjectV1 } from "@/store";-import { type Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";-import { usePlanContext } from "../logic/context";-import { providePlanSQLCheckContext } from "./SQLCheckSection";-import SpecDetailView from "./SpecDetailView";-import { providePlanSpecContext } from "./SpecDetailView/context";--const { project } = useCurrentProjectV1();-const { isCreating, plan } = usePlanContext();--const { selectedSpec } = providePlanSpecContext({- isCreating,- plan,-});--providePlanSQLCheckContext({- project,- plan,- selectedSpec: selectedSpec as Ref<Plan_Spec>,-});-</script>diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vueindex 16c82f86b5..11f92b3f7f 100644--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue@@ -166,7 +166,7 @@<script setup lang="ts">import { create } from "@bufbuild/protobuf";-import { cloneDeep, head, includes, isEmpty } from "lodash-es";+import { cloneDeep, includes, isEmpty } from "lodash-es";import { ExpandIcon } from "lucide-vue-next";import { NButton, NTooltip, useDialog } from "naive-ui";import { v1 as uuidv1 } from "uuid";@@ -202,12 +202,13 @@ import {setSheetStatement,useInstanceV1EditorLanguage,} from "@/utils";-import { usePlanSpecContext } from "../../SpecDetailView/context";+import { useSelectedSpec } from "../../SpecDetailView/context";import { useSQLAdviceMarkers } from "../useSQLAdviceMarkers";-import type { EditState } from "./useTempEditState";-import { useTempEditState } from "./useTempEditState";+import { useSpecSheet } from "../useSpecSheet";-type LocalState = EditState & {+type LocalState = {+ isEditing: boolean;+ statement: string;showEditorModal: boolean;isUploadingFile: boolean;};@@ -215,8 +216,8 @@ type LocalState = EditState & {const { t } = useI18n();const dialog = useDialog();const { project } = useCurrentProjectV1();-const { isCreating, plan, events, planCheckRuns, rollout } = usePlanContext();-const { selectedSpec } = usePlanSpecContext();+const { isCreating, plan, planCheckRuns, rollout, events } = usePlanContext();+const selectedSpec = useSelectedSpec();const monacoEditorRef = ref<InstanceType<typeof MonacoEditor>>();const state = reactive<LocalState>({@@ -266,13 +267,9 @@ const isEditorReadonly = computed(() => {return !state.isEditing || isSheetOversize.value || false;});-const {- sheet,- sheetName,- sheetReady,- sheetStatement,- reset: resetTempEditState,-} = useTempEditState(state);+const { sheet, sheetName, sheetReady, sheetStatement } = useSpecSheet(+ selectedSpec.value+);const isSheetOversize = computed(() => {if (isCreating.value) return false;@@ -345,7 +342,6 @@ const beginEdit = () => {const saveEdit = async () => {try {await updateStatement(state.statement);- resetTempEditState();} finally {state.isEditing = false;}@@ -399,7 +395,6 @@ const handleUpdateStatement = async (statement: string, filename: string) => {if (sheet.value) {sheet.value.title = filename;}- resetTempEditState();} finally {state.isUploadingFile = false;}@@ -407,13 +402,22 @@ const handleUpdateStatement = async (statement: string, filename: string) => {const updateStatement = async (statement: string) => {const planPatch = cloneDeep(plan.value);- if (!planPatch) {- return;- }- const specsToPatch = planPatch.specs.filter(+ const specToPatch = planPatch.specs.find((spec) => spec.id === selectedSpec.value.id);- const specEngine = await databaseEngineForSpec(head(specsToPatch));+ if (!specToPatch) {+ throw new Error(+ `Cannot find spec to patch for plan update ${JSON.stringify(+ selectedSpec.value+ )}`+ );+ }+ if (specToPatch.config.case !== "changeDatabaseConfig") {+ throw new Error(+ `Unsupported spec type for plan update ${JSON.stringify(specToPatch)}`+ );+ }+ const specEngine = await databaseEngineForSpec(specToPatch);const sheet = create(SheetSchema, {...createEmptyLocalSheet(),title: plan.value.title,@@ -424,27 +428,15 @@ const updateStatement = async (statement: string) => {project.value.name,sheet);-- for (const spec of specsToPatch) {- if (spec.config?.case === "changeDatabaseConfig") {- spec.config.value.sheet = createdSheet.name;- } else if (spec.config?.case === "exportDataConfig") {- spec.config.value.sheet = createdSheet.name;- } else {- throw new Error(- `Unsupported spec type for plan update ${JSON.stringify(spec)}`- );- }- }-+ specToPatch.config.value.sheet = createdSheet.name;const request = create(UpdatePlanRequestSchema, {plan: planPatch,updateMask: { paths: ["specs"] },});- const response = await planServiceClientConnect.updatePlan(request);-- Object.assign(plan.value, response);- events.emit("status-changed", { eager: true });+ await planServiceClientConnect.updatePlan(request);+ events.emit("status-changed", {+ eager: true,+ });pushNotification({module: "bytebase",style: "SUCCESS",@@ -479,10 +471,4 @@ watch(isCreating, (curr, prev) => {state.isEditing = false;}});--defineExpose({- get editor() {- return monacoEditorRef.value;- },-});</script>diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/useTempEditState.ts b/frontend/src/components/Plan/components/StatementSection/EditorView/useTempEditState.tsdeleted file mode 100644index fdbe3f36a9..0000000000--- a/frontend/src/components/Plan/components/StatementSection/EditorView/useTempEditState.ts+++ /dev/null@@ -1,119 +0,0 @@-import { computed, nextTick, ref, watch } from "vue";-import { UNKNOWN_ID } from "@/types";-import { usePlanContext } from "../../../logic";-import { usePlanSpecContext } from "../../SpecDetailView/context";-import { useSpecSheet } from "../useSpecSheet";--export type EditState = {- isEditing: boolean;- statement: string;-};--export const useTempEditState = (state: EditState) => {- const { isCreating } = usePlanContext();- const { selectedSpec } = usePlanSpecContext();- const { sheet, sheetName, sheetReady, sheetStatement } = useSpecSheet(- selectedSpec.value- );-- let stopWatching = () => {- // noop- };-- const startWatching = () => {- const tempEditStateMap = new Map<string, EditState>();- const isSwitchingSpec = ref(false);-- const selectedSpecId = computed((): string => {- if (isCreating.value) return String(UNKNOWN_ID);- return selectedSpec.value.id;- });-- watch(selectedSpecId, () => {- // When switching spec id, set the switch flag to true- // to temporarily disable change listeners.- isSwitchingSpec.value = true;- nextTick(() => {- isSwitchingSpec.value = false;- });- });-- const handleEditChange = () => {- // When we are switching between specs, this will also be triggered.- // But we shouldn't update the temp store.- if (isSwitchingSpec.value) {- return;- }- // Save the temp edit state before switching spec.- tempEditStateMap.set(selectedSpecId.value, {- isEditing: state.isEditing,- statement: state.statement,- });- };-- const afterSpecIdChange = (id: string) => {- // Try to restore the saved temp edit state after switching spec.- const storedState = tempEditStateMap.get(id);- if (storedState) {- // If found the stored temp edit state, restore it.- Object.assign(state, storedState);- } else {- // Restore to the spec's default state otherwise.- state.isEditing = false;- state.statement = sheetStatement.value;- }- };-- // Save the temp editing state before switching specs- const stopWatchBeforeChange = watch(- [() => state.isEditing, () => state.statement],- handleEditChange,- { immediate: true }- );- const stopWatchAfterChange = watch(- selectedSpecId,- afterSpecIdChange,- { flush: "post" } // Listen to the event AFTER selectedSpecId changed- );-- return () => {- tempEditStateMap.clear();- stopWatchBeforeChange();- stopWatchAfterChange();- };- };-- watch(- isCreating,- () => {- if (!isCreating.value) {- // If we are opening an existed plan, we should listen and store the- // temp editing states.- stopWatching = startWatching();- } else {- // If we are creating an plan, we don't need the temp editing state- // feature since all specs are still in editing mode.- if (stopWatching) {- stopWatching();- }- }- },- { immediate: true }- );-- const reset = () => {- stopWatching();-- if (!isCreating.value) {- stopWatching = startWatching();- }- };-- return {- reset,- sheet,- sheetName,- sheetReady,- sheetStatement,- };-};diff --git a/frontend/src/components/Plan/components/StatementSection/ReleaseView/ReleaseView.vue b/frontend/src/components/Plan/components/StatementSection/ReleaseView/ReleaseView.vueindex 0799e5776e..6d796688b3 100644--- a/frontend/src/components/Plan/components/StatementSection/ReleaseView/ReleaseView.vue+++ b/frontend/src/components/Plan/components/StatementSection/ReleaseView/ReleaseView.vue@@ -162,10 +162,10 @@ import { isValidReleaseName, getDateForPbTimestampProtoEs } from "@/types";import { VCSType } from "@/types/proto-es/v1/common_pb";import { ReleaseFileType } from "@/types/proto-es/v1/release_service_pb";import { Release_File_ChangeType } from "@/types/proto-es/v1/release_service_pb";-import { usePlanSpecContext } from "../../SpecDetailView/context";+import { useSelectedSpec } from "../../SpecDetailView/context";const { t } = useI18n();-const { selectedSpec } = usePlanSpecContext();+const selectedSpec = useSelectedSpec();const releaseName = computed(() => {if (selectedSpec.value?.config?.case === "changeDatabaseConfig") {diff --git a/frontend/src/components/Plan/components/StatementSection/StatementSection.vue b/frontend/src/components/Plan/components/StatementSection/StatementSection.vueindex e70023a65b..fac79a86b7 100644--- a/frontend/src/components/Plan/components/StatementSection/StatementSection.vue+++ b/frontend/src/components/Plan/components/StatementSection/StatementSection.vue@@ -1,30 +1,29 @@<template><div v-if="viewMode !== 'NONE'" class="px-4 flex flex-col gap-y-2">- <EditorView v-if="viewMode === 'EDITOR'" />+ <EditorView v-if="viewMode === 'EDITOR'" :key="selectedSpec.id" /><ReleaseView v-else-if="viewMode === 'RELEASE'" /></div></template><script setup lang="ts">import { computed } from "vue";-import { usePlanSpecContext } from "../SpecDetailView/context";+import { useSelectedSpec } from "../SpecDetailView/context";import EditorView from "./EditorView";import ReleaseView from "./ReleaseView";-const { selectedSpec } = usePlanSpecContext();+const selectedSpec = useSelectedSpec();const viewMode = computed((): "NONE" | "EDITOR" | "RELEASE" => {if (selectedSpec.value) {const spec = selectedSpec.value;- // Check if this is a release-based spec (has release but no sheet)+ // Check if this is a release-based spec first.if (spec.config?.case === "changeDatabaseConfig" &&- spec.config.value.release &&- !spec.config.value.sheet+ spec.config.value.release) {return "RELEASE";}- // Otherwise, it's a sheet-based spec+ // Otherwise, it's a sheet-based spec.return "EDITOR";}return "NONE";diff --git a/frontend/src/components/Plan/components/common/DatabaseDisplay.vue b/frontend/src/components/Plan/components/common/DatabaseDisplay.vueindex ad5b1b9ac8..bfd1e6c44f 100644--- a/frontend/src/components/Plan/components/common/DatabaseDisplay.vue+++ b/frontend/src/components/Plan/components/common/DatabaseDisplay.vue@@ -9,7 +9,7 @@{{ instanceDisplayName }}</span><ChevronRightIcon- class="inline opacity-60 text-gray-600 w-4 h-4 shrink-0 mx-0.5"+ class="inline opacity-60 text-gray-600 w-4 h-4 shrink-0"/><span class="truncate text-gray-800">{{ databaseDisplayName }}diff --git a/frontend/src/components/Plan/logic/context.ts b/frontend/src/components/Plan/logic/context.tsindex 6c046a0ea1..664b16aeb9 100644--- a/frontend/src/components/Plan/logic/context.ts+++ b/frontend/src/components/Plan/logic/context.ts@@ -68,17 +68,7 @@ export const usePlanContextWithRollout = () => {};};-export const providePlanContext = (- context: Partial<PlanContext>,- root = false-) => {- if (!root) {- const parent = usePlanContext();- context = {- ...parent,- ...context,- };- }+export const providePlanContext = (context: Partial<PlanContext>) => {provide(KEY, context as PlanContext);return context as PlanContext;};diff --git a/frontend/src/components/Plan/logic/initialize/index.ts b/frontend/src/components/Plan/logic/initialize/index.tsindex bd32e9afb0..ea11ab1e07 100644--- a/frontend/src/components/Plan/logic/initialize/index.ts+++ b/frontend/src/components/Plan/logic/initialize/index.ts@@ -190,7 +190,14 @@ export function useInitializePlan({ immediate: true });- return { isCreating, plan, planCheckRuns, issue, rollout, isInitializing };+ return {+ isCreating,+ plan,+ planCheckRuns,+ issue,+ rollout,+ isInitializing,+ };}export const convertRouterQuery = (query: LocationQuery) => {diff --git a/frontend/src/components/Plan/logic/poller/poller.ts b/frontend/src/components/Plan/logic/poller/poller.tsindex e00b3ba490..92b109ef65 100644--- a/frontend/src/components/Plan/logic/poller/poller.ts+++ b/frontend/src/components/Plan/logic/poller/poller.ts@@ -122,7 +122,7 @@ export const provideResourcePoller = () => {routeName)) {- return ["issue", "rollout"];+ return ["rollout"];}// Default to polling all resourcesdiff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.tsindex 9fcd43f416..aadf622387 100644--- a/frontend/src/router/dashboard/projectV1.ts+++ b/frontend/src/router/dashboard/projectV1.ts@@ -35,7 +35,8 @@ export const PROJECT_V1_ROUTE_RELEASES = `${PROJECT_V1_ROUTE_DASHBOARD}.release`export const PROJECT_V1_ROUTE_RELEASE_DETAIL = `${PROJECT_V1_ROUTE_DASHBOARD}.release.detail`;export const PROJECT_V1_ROUTE_ROLLOUTS = `${PROJECT_V1_ROUTE_DASHBOARD}.rollout`;export const PROJECT_V1_ROUTE_ROLLOUT_DETAIL = `${PROJECT_V1_ROUTE_ROLLOUTS}.detail`;-export const PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL = `${PROJECT_V1_ROUTE_ROLLOUT_DETAIL}.task.detail`;+export const PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL = `${PROJECT_V1_ROUTE_ROLLOUT_DETAIL}.stage.detail`;+export const PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL = `${PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL}.task.detail`;const cicdRoutes: RouteRecordRaw[] = [{@@ -58,7 +59,7 @@ const cicdRoutes: RouteRecordRaw[] = [{path: "specs",name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,- component: () => import("@/views/project/PlanSpecDetailView.vue"),+ component: () => import("@/views/project/PlanSpecsView.vue"),},{path: "specs/:specId",@@ -86,17 +87,28 @@ const cicdRoutes: RouteRecordRaw[] = [meta: {title: () => t("common.rollout"),},+ component: () => import("@/views/project/RolloutDetailLayout.vue"),props: true,children: [{path: "",name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,- component: () => import("@/views/project/RolloutDetailView.vue"),+ component: () =>+ import(+ "@/components/Plan/components/RolloutView/RolloutView.vue"+ ),props: true,meta: {requiredPermissionList: () => ["bb.rollouts.get"],},},+ {+ path: "stages/:stageId",+ name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,+ component: () =>+ import("@/components/Plan/components/RolloutView/StageView.vue"),+ props: true,+ },{path: "stages/:stageId/tasks/:taskId",name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,diff --git a/frontend/src/views/project/CICDLayout.vue b/frontend/src/views/project/CICDLayout.vueindex 7c2de29606..efe8baf7b5 100644--- a/frontend/src/views/project/CICDLayout.vue+++ b/frontend/src/views/project/CICDLayout.vue@@ -12,6 +12,7 @@><NTabv-for="tab in availableTabs"+ class="select-none":key="tab":name="tab":tab="tabRender(tab)"@@ -41,7 +42,6 @@<script lang="tsx" setup>import { useTitle } from "@vueuse/core";-import { head } from "lodash-es";import { NSpin, NTab, NTabs } from "naive-ui";import { computed, toRef } from "vue";import { useI18n } from "vue-i18n";@@ -65,6 +65,7 @@ import {PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,PROJECT_V1_ROUTE_ROLLOUT_DETAIL,+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,} from "@/router/dashboard/projectV1";import {@@ -109,17 +110,14 @@ const ready = computed(() => {const route = useRoute();const router = useRouter();-providePlanContext(- {- isCreating,- plan,- planCheckRuns,- issue,- rollout,- ...planBaseContext,- },- true /* root */-);+providePlanContext({+ isCreating,+ plan,+ planCheckRuns,+ issue,+ rollout,+ ...planBaseContext,+});provideIssueReviewContext(issue);@@ -148,6 +146,7 @@ const tabKey = computed(() => {} else if ([PROJECT_V1_ROUTE_ROLLOUT_DETAIL,+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,].includes(routeName)) {@@ -244,24 +243,11 @@ const handleTabChange = (tab: TabKey) => {query: query,});} else if (tab === TabKey.Specifications) {- // Auto select the first spec when switching to Specifications tab.- const spec = head(plan.value.specs);- if (spec) {- router.push({- name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,- params: {- ...params,- specId: spec.id,- },- query: query,- });- } else {- router.push({- name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,- params: params,- query: query,- });- }+ router.push({+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,+ params: params,+ query: query,+ });} else if (tab === TabKey.Checks) {router.push({name: PROJECT_V1_ROUTE_PLAN_DETAIL_CHECK_RUNS,diff --git a/frontend/src/views/project/PlanSpecDetailView.vue b/frontend/src/views/project/PlanSpecDetailView.vueindex 87773028aa..c015b2fd35 100644--- a/frontend/src/views/project/PlanSpecDetailView.vue+++ b/frontend/src/views/project/PlanSpecDetailView.vue@@ -1,7 +1,15 @@<template>- <SpecsView />+ <div class="w-full flex-1 flex pt-2 pb-4">+ <SpecDetailView v-if="specId" :key="specId" />+ </div></template><script lang="ts" setup>-import SpecsView from "@/components/Plan/components/SpecsView.vue";+import { computed } from "vue";+import { useRoute } from "vue-router";+import { SpecDetailView } from "@/components/Plan/components";++const route = useRoute();++const specId = computed(() => route.params.specId as string | undefined);</script>diff --git a/frontend/src/views/project/PlanSpecsView.vue b/frontend/src/views/project/PlanSpecsView.vuenew file mode 100644index 0000000000..a74f044314--- /dev/null+++ b/frontend/src/views/project/PlanSpecsView.vue@@ -0,0 +1,34 @@+<script lang="ts" setup>+import { head } from "lodash-es";+import { useRoute, useRouter } from "vue-router";+import { usePlanContext } from "@/components/Plan";+import {+ PROJECT_V1_ROUTE_PLAN_DETAIL,+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,+} from "@/router/dashboard/projectV1";++const route = useRoute();+const router = useRouter();+const { plan } = usePlanContext();++const spec = head(plan.value.specs);++// Redirect to the first spec if it exists, otherwise redirect to the plan page.+if (!spec) {+ // If there are no specs, redirect to the plan page.+ router.replace({+ name: PROJECT_V1_ROUTE_PLAN_DETAIL,+ params: route.params,+ query: route.query,+ });+} else {+ router.replace({+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,+ params: {+ ...route.params,+ specId: spec.id,+ },+ query: route.query,+ });+}+</script>diff --git a/frontend/src/views/project/RolloutDetailLayout.vue b/frontend/src/views/project/RolloutDetailLayout.vuenew file mode 100644index 0000000000..9d03f5dc15--- /dev/null+++ b/frontend/src/views/project/RolloutDetailLayout.vue@@ -0,0 +1,93 @@+<template>+ <div class="w-full flex flex-col">+ <!-- Breadcrumb - only show on stage and task routes -->+ <NBreadcrumb v-if="showBreadcrumb" class="px-4 pt-2">+ <NBreadcrumbItem @click="navigateToRollout">+ {{ $t("common.rollout") }}+ </NBreadcrumbItem>+ <NBreadcrumbItem v-if="stageId" @click="navigateToStage">+ {{ stageTitle }}+ </NBreadcrumbItem>+ <NBreadcrumbItem v-if="taskId" :clickable="false">+ {{ $t("common.task") }} #{{ taskId }}+ </NBreadcrumbItem>+ </NBreadcrumb>++ <!-- Main content -->+ <div class="flex-1 min-h-0">+ <router-view />+ </div>+ </div>+</template>++<script lang="ts" setup>+import { NBreadcrumb, NBreadcrumbItem } from "naive-ui";+import { computed } from "vue";+import { useRoute, useRouter } from "vue-router";+import { provideRolloutViewContext } from "@/components/Plan/components/RolloutView/context";+import {+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL,+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,+} from "@/router/dashboard/projectV1";+import { useCurrentProjectV1, useEnvironmentV1Store } from "@/store";+import { extractProjectResourceName } from "@/utils";++const route = useRoute();+const router = useRouter();+const { project } = useCurrentProjectV1();+const environmentStore = useEnvironmentV1Store();+const { mergedStages } = provideRolloutViewContext();++// Route parameters+const rolloutId = computed(() => route.params.rolloutId as string);+const stageId = computed(() => route.params.stageId as string);+const taskId = computed(() => route.params.taskId as string);++// Only show breadcrumb on stage and task routes+const showBreadcrumb = computed(() => {+ return Boolean(stageId.value || taskId.value);+});++// Get stage title from environment+const stageTitle = computed(() => {+ if (!stageId.value) return "";++ // Find the stage in merged stages+ const stage = mergedStages.value.find((s) =>+ s.name.endsWith(`/${stageId.value}`)+ );++ if (stage) {+ const environment = environmentStore.getEnvironmentByName(+ stage.environment+ );+ return environment.title;+ }++ return stageId.value;+});++// Navigation handlers+const navigateToRollout = () => {+ router.push({+ name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,+ params: {+ projectId: extractProjectResourceName(project.value.name),+ rolloutId: rolloutId.value,+ },+ });+};++const navigateToStage = () => {+ if (!stageId.value) return;++ router.push({+ name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,+ params: {+ projectId: extractProjectResourceName(project.value.name),+ rolloutId: rolloutId.value,+ stageId: stageId.value,+ },+ });+};+</script>diff --git a/frontend/src/views/project/RolloutDetailView.vue b/frontend/src/views/project/RolloutDetailView.vuedeleted file mode 100644index cc2d280d19..0000000000--- a/frontend/src/views/project/RolloutDetailView.vue+++ /dev/null@@ -1,7 +0,0 @@-<template>- <RolloutView />-</template>--<script lang="ts" setup>-import { RolloutView } from "@/components/Plan/components/RolloutView";-</script>