Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): merge Plan and Issue into unified page for database changes (#18704)
boojack7d9aab6a04ac
diff --git a/frontend/src/components/Plan/components/Configuration/Configuration.vue b/frontend/src/components/Plan/components/Configuration/Configuration.vueindex f74c64ea6f..8a1f4b2a26 100644--- a/frontend/src/components/Plan/components/Configuration/Configuration.vue+++ b/frontend/src/components/Plan/components/Configuration/Configuration.vue@@ -1,5 +1,5 @@<template>- <div class="py-3 flex flex-col gap-y-3">+ <div class="flex flex-col gap-y-3 py-3"><h3 class="text-base">{{ $t("plan.options.self") }}</h3><div v-if="shouldShow" class="flex flex-col gap-y-3"><InstanceRoleSection v-if="shouldShowInstanceRoleSection" />@@ -34,99 +34,38 @@ const { project } = useCurrentProjectV1();const { isCreating, plan, events, issue, readonly } = usePlanContext();const { selectedSpec } = useSelectedSpec();-const {- shouldShow: shouldShowTransactionModeSection,- events: transactionModeEvents,-} = provideTransactionModeSettingContext({+const providerArgs = {project,plan,selectedSpec,isCreating,issue,readonly,-});--const {- shouldShow: shouldShowInstanceRoleSection,- events: instanceRoleEvents,-} = provideInstanceRoleSettingContext({- project,- plan,- selectedSpec,- isCreating,- issue,- readonly,-});--const {- shouldShow: shouldShowIsolationLevelSection,- events: isolationLevelEvents,-} = provideIsolationLevelSettingContext({- project,- plan,- selectedSpec,- isCreating,- issue,- readonly,-});+};+const { shouldShow: shouldShowTransactionModeSection, events: txEvents } =+ provideTransactionModeSettingContext(providerArgs);+const { shouldShow: shouldShowInstanceRoleSection, events: roleEvents } =+ provideInstanceRoleSettingContext(providerArgs);+const { shouldShow: shouldShowIsolationLevelSection, events: isoEvents } =+ provideIsolationLevelSettingContext(providerArgs);const { shouldShow: shouldShowGhostSection, events: ghostEvents } =- provideGhostSettingContext({- project,- plan,- selectedSpec,- isCreating,- issue,- readonly,- });--const { shouldShow: shouldShowPreBackupSection, events: preBackupEvents } =- providePreBackupSettingContext({- project,- plan,- selectedSpec,- isCreating,- issue,- readonly,- });+ provideGhostSettingContext(providerArgs);+const { shouldShow: shouldShowPreBackupSection, events: backupEvents } =+ providePreBackupSettingContext(providerArgs);-const shouldShow = computed(() => {- return (+const shouldShow = computed(+ () =>shouldShowTransactionModeSection.value ||shouldShowIsolationLevelSection.value ||shouldShowInstanceRoleSection.value ||shouldShowGhostSection.value ||shouldShowPreBackupSection.value- );-});--transactionModeEvents.on("update", () => {- events.emit("status-changed", {- eager: true,- });-});--instanceRoleEvents.on("update", () => {- events.emit("status-changed", {- eager: true,- });-});--isolationLevelEvents.on("update", () => {- events.emit("status-changed", {- eager: true,- });-});--preBackupEvents.on("update", () => {- events.emit("status-changed", {- eager: true,- });-});+);-ghostEvents.on("update", () => {- events.emit("status-changed", {- eager: true,- });-});+// Forward all setting updates to plan context+const emitStatusChanged = () => events.emit("status-changed", { eager: true });+[txEvents, roleEvents, isoEvents, ghostEvents, backupEvents].forEach((e) =>+ e.on("update", emitStatusChanged)+);</script>diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/DatabaseChangeView.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/DatabaseChangeView.vuenew file mode 100644index 0000000000..91eb5353fd--- /dev/null+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/DatabaseChangeView.vue@@ -0,0 +1,56 @@+<template>+ <div class="w-full flex flex-col">+ <!-- Spec Tabs with integrated content -->+ <SpecTabs v-model:selected-spec-id="selectedSpecId">+ <div v-if="selectedSpec" class="flex flex-col gap-2">+ <TargetListSection />+ <div class="h-72 flex flex-col">+ <StatementSection />+ </div>+ <OptionsSection />+ </div>+ </SpecTabs>+ </div>+</template>++<script setup lang="ts">+import { computed, ref, watch } from "vue";+import { usePlanContext } from "../../../logic";+import { provideSelectedSpec } from "../../SpecDetailView/context";+import TargetListSection from "../../SpecDetailView/TargetListSection.vue";+import StatementSection from "../../StatementSection/StatementSection.vue";+import OptionsSection from "./OptionsSection.vue";+import SpecTabs from "./SpecTabs.vue";++const { plan } = usePlanContext();++// Local state for selected spec (not route-based)+const selectedSpecId = ref<string>(plan.value.specs[0]?.id ?? "");++// Computed selected spec+const selectedSpec = computed(() => {+ return plan.value.specs.find((spec) => spec.id === selectedSpecId.value);+});++// Provide selected spec for child components+provideSelectedSpec(+ computed(() => {+ const spec = selectedSpec.value;+ if (!spec) {+ throw new Error("No spec selected");+ }+ return spec;+ })+);++// Update selected spec when specs change+watch(+ () => plan.value.specs,+ (specs) => {+ if (specs.length > 0 && !specs.find((s) => s.id === selectedSpecId.value)) {+ selectedSpecId.value = specs[0].id;+ }+ },+ { immediate: true }+);+</script>diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/OptionsSection.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/OptionsSection.vuenew file mode 100644index 0000000000..b46c7b7f69--- /dev/null+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/OptionsSection.vue@@ -0,0 +1,89 @@+<template>+ <div v-if="shouldShow" class="flex flex-col gap-1">+ <span class="text-base">{{ $t("plan.options.self") }}</span>+ <div class="flex flex-wrap items-center gap-x-4 sm:gap-x-6 gap-y-1">+ <div v-if="shouldShowInstanceRoleSection" class="flex items-center gap-1">+ <span class="text-sm text-control-light">{{ $t("common.role.self") }}</span>+ <InstanceRoleSelect />+ </div>+ <div v-if="shouldShowTransactionModeSection" class="flex items-center gap-1">+ <span class="text-sm text-control-light">{{+ $t("issue.transaction-mode.label")+ }}</span>+ <TransactionModeSwitch />+ </div>+ <div v-if="shouldShowIsolationLevelSection" class="flex items-center gap-1">+ <span class="text-sm text-control-light">{{+ $t("plan.isolation-level.self")+ }}</span>+ <IsolationLevelSelect />+ </div>+ <div v-if="shouldShowPreBackupSection" class="flex items-center gap-1">+ <span class="text-sm text-control-light">{{ $t("task.prior-backup") }}</span>+ <PreBackupSwitch />+ </div>+ <div v-if="shouldShowGhostSection" class="flex items-center gap-1">+ <span class="text-sm text-control-light">{{+ $t("task.online-migration.self")+ }}</span>+ <GhostSwitch />+ </div>+ </div>+ </div>+</template>++<script setup lang="ts">+import { computed } from "vue";+import { useCurrentProjectV1 } from "@/store";+import { usePlanContext } from "../../../logic";+import { provideGhostSettingContext } from "../../Configuration/GhostSection/context";+import GhostSwitch from "../../Configuration/GhostSection/GhostSwitch.vue";+import { provideInstanceRoleSettingContext } from "../../Configuration/InstanceRoleSection/context";+import InstanceRoleSelect from "../../Configuration/InstanceRoleSection/InstanceRoleSelect.vue";+import { provideIsolationLevelSettingContext } from "../../Configuration/IsolationLevelSection/context";+import IsolationLevelSelect from "../../Configuration/IsolationLevelSection/IsolationLevelSelect.vue";+import { providePreBackupSettingContext } from "../../Configuration/PreBackupSection/context";+import PreBackupSwitch from "../../Configuration/PreBackupSection/PreBackupSwitch.vue";+import { provideTransactionModeSettingContext } from "../../Configuration/TransactionModeSection/context";+import TransactionModeSwitch from "../../Configuration/TransactionModeSection/TransactionModeSwitch.vue";+import { useSelectedSpec } from "../../SpecDetailView/context";++const { project } = useCurrentProjectV1();+const { isCreating, plan, events, issue, readonly } = usePlanContext();+const { selectedSpec } = useSelectedSpec();++const providerArgs = {+ project,+ plan,+ selectedSpec,+ isCreating,+ issue,+ readonly,+};++const { shouldShow: shouldShowTransactionModeSection, events: txEvents } =+ provideTransactionModeSettingContext(providerArgs);+const { shouldShow: shouldShowInstanceRoleSection, events: roleEvents } =+ provideInstanceRoleSettingContext(providerArgs);+const { shouldShow: shouldShowIsolationLevelSection, events: isoEvents } =+ provideIsolationLevelSettingContext(providerArgs);+const { shouldShow: shouldShowGhostSection, events: ghostEvents } =+ provideGhostSettingContext(providerArgs);+const { shouldShow: shouldShowPreBackupSection, events: backupEvents } =+ providePreBackupSettingContext(providerArgs);++const shouldShow = computed(+ () =>+ shouldShowTransactionModeSection.value ||+ shouldShowIsolationLevelSection.value ||+ shouldShowInstanceRoleSection.value ||+ shouldShowGhostSection.value ||+ shouldShowPreBackupSection.value+);++// Forward all setting updates to plan context+const emitStatusChanged = () => events.emit("status-changed", { eager: true });+[txEvents, roleEvents, isoEvents, ghostEvents, backupEvents].forEach((e) =>+ e.on("update", emitStatusChanged)+);+</script>diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/SpecTabs.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/SpecTabs.vuenew file mode 100644index 0000000000..2232bbbf81--- /dev/null+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/SpecTabs.vue@@ -0,0 +1,203 @@+<template>+ <div>+ <!-- Tab Bar -->+ <div class="flex items-center justify-between border-b border-control-border">+ <div class="flex items-center">+ <button+ v-for="(spec, index) in specs"+ :key="spec.id"+ class="flex items-center gap-1 px-3 py-1.5 -mb-px text-sm border rounded-t-md cursor-pointer transition-colors"+ :class="+ selectedSpecId === spec.id+ ? 'font-medium text-main bg-white border-control-border border-b-white'+ : 'text-control-light bg-transparent border-transparent hover:text-control'+ "+ @click="$emit('update:selectedSpecId', spec.id)"+ >+ <span class="opacity-60">#{{ index + 1 }}</span>+ <span>{{ getSpecTitle(spec) }}</span>+ <NTooltip v-if="isSpecEmpty(spec)">+ <template #trigger>+ <span class="text-error">*</span>+ </template>+ {{ $t("plan.navigator.statement-empty") }}+ </NTooltip>+ <NDropdown+ v-if="canModifySpecs && specs.length > 1"+ :options="getDropdownOptions()"+ trigger="click"+ placement="bottom-end"+ size="small"+ @select="(key) => handleDropdownSelect(key, spec)"+ >+ <NButton @click.stop text size="tiny">+ <template #icon>+ <MoreVerticalIcon :size="14" class="text-control-light" />+ </template>+ </NButton>+ </NDropdown>+ </button>+ </div>++ <NButton+ v-if="canModifySpecs"+ type="default"+ size="small"+ @click="showAddSpecDrawer = true"+ >+ {{ $t("plan.add-spec") }}+ </NButton>+ </div>++ <!-- Content Area -->+ <div class="bg-white border-x border-b border-control-border rounded-b-lg py-2 px-3">+ <slot />+ </div>+ </div>++ <AddSpecDrawer v-model:show="showAddSpecDrawer" @created="handleSpecCreated" />+</template>++<script setup lang="ts">+import { create } from "@bufbuild/protobuf";+import { MoreVerticalIcon, TrashIcon } from "lucide-vue-next";+import type { DropdownOption } from "naive-ui";+import { NButton, NDropdown, NTooltip, useDialog } from "naive-ui";+import { computed, h, ref } from "vue";+import { useI18n } from "vue-i18n";+import { planServiceClientConnect } from "@/grpcweb";+import {+ pushNotification,+ useCurrentProjectV1,+ useSheetV1Store,+} from "@/store";+import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";+import { UpdatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";+import { extractSheetUID } from "@/utils";+import { getLocalSheetByName, usePlanContext } from "../../../logic";+import { getSpecTitle } from "../../../logic/utils";+import AddSpecDrawer from "../../AddSpecDrawer.vue";+import { useSpecsValidation } from "../../common";++const props = defineProps<{ selectedSpecId: string }>();+const emit = defineEmits<{ "update:selectedSpecId": [specId: string] }>();++const dialog = useDialog();+const { t } = useI18n();+const { plan, isCreating } = usePlanContext();+const sheetStore = useSheetV1Store();+const { project } = useCurrentProjectV1();++const specs = computed(() => plan.value.specs);+const { isSpecEmpty } = useSpecsValidation(specs);+const showAddSpecDrawer = ref(false);+const canModifySpecs = computed(+ () => isCreating.value || !plan.value.hasRollout+);++const getDropdownOptions = (): DropdownOption[] =>+ specs.value.length > 1+ ? [+ {+ key: "delete",+ label: t("common.delete"),+ icon: () => h(TrashIcon, { size: 16 }),+ },+ ]+ : [];++const handleDropdownSelect = (key: string, spec: Plan_Spec) => {+ if (key === "delete") handleDeleteSpec(spec);+};++// Helper to update plan on server with optimistic update rollback on failure+const updatePlanSpecs = async (onError: () => void) => {+ const request = create(UpdatePlanRequestSchema, {+ plan: plan.value,+ updateMask: { paths: ["specs"] },+ });+ try {+ const response = await planServiceClientConnect.updatePlan(request);+ Object.assign(plan.value, response);+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("common.updated"),+ });+ return true;+ } catch (error) {+ onError();+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: t("common.error"),+ description: String(error),+ });+ return false;+ }+};++const handleSpecCreated = async (spec: Plan_Spec) => {+ // For existing plans, create sheet on server first if needed+ if (!isCreating.value) {+ const config = spec.config;+ if (+ config.case === "changeDatabaseConfig" ||+ config.case === "exportDataConfig"+ ) {+ const uid = extractSheetUID(config.value.sheet);+ if (uid.startsWith("-")) {+ const createdSheet = await sheetStore.createSheet(+ project.value.name,+ getLocalSheetByName(config.value.sheet)+ );+ config.value.sheet = createdSheet.name;+ }+ }+ plan.value.specs.push(spec);+ const success = await updatePlanSpecs(() => {+ const idx = plan.value.specs.findIndex((s) => s.id === spec.id);+ if (idx >= 0) plan.value.specs.splice(idx, 1);+ });+ if (!success) return;+ } else {+ plan.value.specs.push(spec);+ }+ emit("update:selectedSpecId", spec.id);+};++const handleDeleteSpec = (spec: Plan_Spec) => {+ dialog.warning({+ title: t("plan.spec.delete-change.title"),+ content: t("plan.spec.delete-change.content"),+ positiveText: t("common.delete"),+ negativeText: t("common.cancel"),+ onPositiveClick: async () => {+ if (specs.value.length <= 1) {+ pushNotification({+ module: "bytebase",+ style: "WARN",+ title: "Cannot delete last spec",+ });+ return;+ }++ const specIndex = plan.value.specs.findIndex((s) => s.id === spec.id);+ if (specIndex < 0) return;++ const removedSpec = plan.value.specs.splice(specIndex, 1)[0];++ if (!isCreating.value) {+ const success = await updatePlanSpecs(() => {+ plan.value.specs.splice(specIndex, 0, removedSpec);+ });+ if (!success) return;+ }++ if (props.selectedSpecId === spec.id && specs.value.length > 0) {+ emit("update:selectedSpecId", specs.value[0].id);+ }+ },+ });+};+</script>diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/index.ts b/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/index.tsnew file mode 100644index 0000000000..3b08af7bb5--- /dev/null+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/index.ts@@ -0,0 +1 @@+export { default as DatabaseChangeView } from "./DatabaseChangeView.vue";diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vueindex 3c5b35b4bf..3dc69a8646 100644--- a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue@@ -5,7 +5,7 @@class="w-full flex-1 flex flex-col lg:flex-row px-4 gap-4 overflow-hidden"><!-- Left: Targets + Statement -->- <div class="flex-1 flex flex-col min-w-0 overflow-y-auto">+ <div class="flex-1 flex flex-col min-w-0 overflow-y-auto py-3"><TargetListSection /><DataExportOptionsSection v-if="isDataExportPlan" /><FailedTaskRunsSection v-if="!isCreating && rollout" />diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vueindex 055f11cbe3..4d8bcd35c0 100644--- a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue@@ -1,67 +1,45 @@<template>- <div class="flex flex-col gap-y-2 py-3">- <div class="flex items-center justify-between gap-2">+ <div class="flex flex-col gap-y-1">+ <div class="flex items-center justify-between"><div class="flex items-center gap-1">- <h3 class="text-base">{{ $t("plan.targets.title") }}</h3>- <span class="text-control-light" v-if="targets.length > 1"+ <span class="text-base">{{ $t("plan.targets.title") }}</span>+ <span class="text-sm text-control-light" v-if="targets.length > 1">({{ targets.length }})</span></div>- <div class="flex items-center gap-1">- <NButton- v-if="allowEdit"- size="small"- @click="showTargetsSelector = true"- >- {{ $t("common.edit") }}- </NButton>- </div>+ <NButton+ v-if="allowEdit"+ size="small"+ @click="showTargetsSelector = true"+ >+ {{ $t("common.edit") }}+ </NButton></div>- <div class="relative w-full flex-1">+ <div v-if="isLoadingTargets" class="flex items-center justify-center py-2">+ <BBSpin />+ </div>+ <div v-else-if="targets.length > 0" class="flex flex-wrap gap-1.5"><div- v-if="isLoadingTargets"- class="flex items-center justify-center py-8"+ v-for="target in visibleTargets"+ :key="target"+ class="inline-flex items-center px-3 py-2 border rounded text-sm">- <BBSpin />+ <DatabaseDisplay v-if="isValidDatabaseName(target)" :database="target" show-environment />+ <DatabaseGroupTargetDisplay v-else-if="isValidDatabaseGroupName(target)" :target="target" />+ <span v-else>{{ target }}</span></div>- <div- v-else-if="targets.length > 0"- class="w-full flex flex-wrap gap-2 overflow-y-auto"+ <NButton+ v-if="targets.length > DEFAULT_VISIBLE_TARGETS"+ size="small"+ quaternary+ @click="showAllTargetsDrawer = true">- <div- v-for="target in visibleTargets"- :key="target"- class="inline-flex items-center gap-x-1 px-2 py-1 border rounded-lg transition-all cursor-default"- >- <template v-if="isValidDatabaseName(target)">- <DatabaseDisplay :database="target" show-environment />- </template>- <template v-else-if="isValidDatabaseGroupName(target)">- <DatabaseGroupTargetDisplay :target="target" class="px-1 py-1" />- </template>- <template v-else>- <!-- Unknown resource -->- <span class="text-sm">{{ target }}</span>- </template>- </div>-- <NButton- v-if="targets.length > DEFAULT_VISIBLE_TARGETS"- size="small"- quaternary- @click="showAllTargetsDrawer = true"- >- {{- $t("plan.targets.view-all", {- count: targets.length,- })- }}- </NButton>- </div>- <div v-else class="text-center text-control-light py-8">- {{ $t("plan.targets.no-targets-found") }}- </div>+ {{ $t("plan.targets.view-all", { count: targets.length }) }}+ </NButton>+ </div>+ <div v-else class="text-sm text-control-light py-1">+ {{ $t("plan.targets.no-targets-found") }}</div><TargetsSelectorDrawerdiff --git a/frontend/src/components/Plan/components/SpecDetailView/context.ts b/frontend/src/components/Plan/components/SpecDetailView/context.tsindex 5bf4ebfd10..7666702581 100644--- a/frontend/src/components/Plan/components/SpecDetailView/context.ts+++ b/frontend/src/components/Plan/components/SpecDetailView/context.ts@@ -1,38 +1,48 @@import { head, uniq } from "lodash-es";-import { computed } from "vue";+import { computed, type InjectionKey, inject, provide, type Ref } from "vue";import { useRoute } from "vue-router";+import { useDBGroupStore } from "@/store";import { isValidDatabaseGroupName } from "@/types";+import { DatabaseGroupView } from "@/types/proto-es/v1/database_group_service_pb";+import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";import { usePlanContext } from "../../logic";export const DEFAULT_VISIBLE_TARGETS = 20;+export const SELECTED_SPEC_INJECTION_KEY: InjectionKey<Ref<Plan_Spec>> =+ Symbol("selected-spec");++export const provideSelectedSpec = (spec: Ref<Plan_Spec>) => {+ provide(SELECTED_SPEC_INJECTION_KEY, spec);+};+export const useSelectedSpec = () => {const route = useRoute();const { plan } = usePlanContext();+ const dbGroupStore = useDBGroupStore();++ const injectedSpec = inject(SELECTED_SPEC_INJECTION_KEY, null);const selectedSpec = computed(() => {+ if (injectedSpec?.value) {+ return injectedSpec.value;+ }+if (plan.value.specs.length === 0) {throw new Error("No specs found in the plan.");}const specId = route.params.specId as string | undefined;-- // If no specId in route, check if this is a database export planif (!specId) {- const isExportPlan = plan.value.specs.every(- (spec) => spec.config.case === "exportDataConfig"- );- if (isExportPlan) {- // For export plans, return the first (and typically only) spec+ // For export plans without specId in route, use first spec+ if (plan.value.specs.every((s) => s.config.case === "exportDataConfig")) {return plan.value.specs[0];}-throw new Error("Spec ID is required in the route parameters.");}const foundSpec =- plan.value.specs.find((spec) => spec.id === specId) ||- head(plan.value.specs);+ plan.value.specs.find((s) => s.id === specId) ?? head(plan.value.specs);if (!foundSpec) {throw new Error(`Spec with ID ${specId} not found in the plan.`);}@@ -40,45 +50,36 @@ export const useSelectedSpec = () => {});const targets = computed(() => {- if (!selectedSpec.value) return [];+ const config = selectedSpec.value?.config;if (- selectedSpec.value.config.case === "changeDatabaseConfig" ||- selectedSpec.value.config.case === "exportDataConfig"+ config?.case === "changeDatabaseConfig" ||+ config?.case === "exportDataConfig") {- return selectedSpec.value.config.value.targets;+ return config.value.targets;}return [];});- const getDatabasesForGroup = async (groupName: string): Promise<string[]> => {- const { useDBGroupStore } = await import("@/store");- const { DatabaseGroupView } = await import(- "@/types/proto-es/v1/database_group_service_pb"- );- const dbGroupStore = useDBGroupStore();- try {- const dbGroup = await dbGroupStore.getOrFetchDBGroupByName(groupName, {- view: DatabaseGroupView.FULL,- silent: true,- });- return dbGroup.matchedDatabases?.map((db) => db.name) ?? [];- } catch {- return [];- }- };-const getDatabaseTargets = async (- targets: string[]+ targetList: string[]): Promise<{ databaseTargets: string[]; dbGroupTargets: string[] }> => {const databaseTargets: string[] = [];const dbGroupTargets: string[] = [];- for (const target of targets) {+ for (const target of targetList) {if (isValidDatabaseGroupName(target)) {dbGroupTargets.push(target);- // Fetch live databases from the database group- const mappedDatabases = await getDatabasesForGroup(target);- databaseTargets.push(...mappedDatabases);+ try {+ const dbGroup = await dbGroupStore.getOrFetchDBGroupByName(target, {+ view: DatabaseGroupView.FULL,+ silent: true,+ });+ databaseTargets.push(+ ...(dbGroup.matchedDatabases?.map((db) => db.name) ?? [])+ );+ } catch {+ // Ignore errors fetching database group+ }} else {databaseTargets.push(target);}diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vueindex 171cba1ec6..0096b02524 100644--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue@@ -1,16 +1,14 @@<template>- <div class="h-full flex flex-col gap-y-2">+ <div class="h-full flex flex-col gap-y-1"><div class="flex items-center justify-between">- <div class="flex items-center gap-x-4">- <div class="flex items-center gap-x-1 text-sm">- <span- class="text-base"- :class="isEmpty(state.statement) ? 'text-red-600' : ''"- >- {{ statementTitle }}- </span>- <RequiredStar v-if="isEmpty(state.statement)" />- </div>+ <div class="flex items-center gap-x-1">+ <span+ class="text-base"+ :class="isEmpty(state.statement) ? 'text-red-600' : ''"+ >+ {{ statementTitle }}+ </span>+ <RequiredStar v-if="isEmpty(state.statement)" /></div><div class="flex items-center justify-end gap-x-2"><template v-if="isCreating">@@ -113,9 +111,9 @@</template></BBAttention>- <div class="relative flex-1 min-h-64">+ <div class="relative flex-1"><MonacoEditor- class="w-full h-full min-h-[200px] border rounded-sm overflow-hidden"+ class="w-full h-full border rounded-sm overflow-hidden":filename="filename":content="state.statement":language="language"diff --git a/frontend/src/components/Plan/components/StatementSection/useSpecSheet.ts b/frontend/src/components/Plan/components/StatementSection/useSpecSheet.tsindex b84e0f6a66..b1f333a8aa 100644--- a/frontend/src/components/Plan/components/StatementSection/useSpecSheet.ts+++ b/frontend/src/components/Plan/components/StatementSection/useSpecSheet.ts@@ -1,8 +1,8 @@-import { computedAsync } from "@vueuse/core";-import { type ComputedRef, computed, ref } from "vue";+import { type ComputedRef, computed, ref, watch } from "vue";import { getLocalSheetByName } from "@/components/Plan";import { useSheetV1Store } from "@/store";import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";+import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";import {extractSheetUID,getSheetStatement,@@ -14,24 +14,28 @@ export const useSpecSheet = (spec: ComputedRef<Plan_Spec>) => {const sheetStore = useSheetV1Store();const isFetchingSheet = ref(false);+ const sheet = ref<Sheet | undefined>(undefined);const sheetName = computed(() => sheetNameOfSpec(spec.value));const sheetReady = computed(() => {return !isFetchingSheet.value;});- const sheet = computedAsync(- async () => {- const name = sheetName.value;- const uid = extractSheetUID(name);++ const fetchSheet = async () => {+ const name = sheetName.value;+ const uid = extractSheetUID(name);+ isFetchingSheet.value = true;+ try {if (uid.startsWith("-")) {- return getLocalSheetByName(name);+ sheet.value = getLocalSheetByName(name);+ } else {+ sheet.value = await sheetStore.getOrFetchSheetByName(name);}- return sheetStore.getOrFetchSheetByName(name);- },- undefined,- {- evaluating: isFetchingSheet,+ } finally {+ isFetchingSheet.value = false;}- );+ };++ watch(sheetName, fetchSheet, { immediate: true });const sheetStatement = computed({get() {if (!sheetReady.value || !sheet.value) return "";diff --git a/frontend/src/components/Plan/logic/poller/poller.ts b/frontend/src/components/Plan/logic/poller/poller.tsindex a8132948c4..30c539591b 100644--- a/frontend/src/components/Plan/logic/poller/poller.ts+++ b/frontend/src/components/Plan/logic/poller/poller.ts@@ -173,7 +173,7 @@ export const provideResourcePoller = () => {if (includes(planRoutes, routeName)) return ["plan"];if (includes([PROJECT_V1_ROUTE_ISSUE_DETAIL_V1], routeName)) {if (planType.value === "CHANGE_DATABASE") {- return ["issue"];+ return ["plan", "issue"];} else {// For CREATE_DATABASE and EXPORT_DATA plans, we use the issue page to show the rollout and task runs.return ["plan", "issue", "rollout", "taskRuns"];diff --git a/frontend/src/components/Plan/logic/useIssueTabNavigation.tsx b/frontend/src/components/Plan/logic/useIssueTabNavigation.tsxdeleted file mode 100644index 9e6c971bb5..0000000000--- a/frontend/src/components/Plan/logic/useIssueTabNavigation.tsx+++ /dev/null@@ -1,159 +0,0 @@-import { FileDiffIcon, Layers2Icon } from "lucide-vue-next";-import { NTag } from "naive-ui";-import type { Ref } from "vue";-import { computed } from "vue";-import type { ComposerTranslation } from "vue-i18n";-import type { RouteLocationNormalizedLoaded, Router } from "vue-router";-import {- PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,- PROJECT_V1_ROUTE_PLAN_DETAIL,- PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,- PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,-} from "@/router/dashboard/projectV1";-import type { Issue } from "@/types/proto-es/v1/issue_service_pb";-import { Issue_Type } from "@/types/proto-es/v1/issue_service_pb";-import type { Plan } from "@/types/proto-es/v1/plan_service_pb";-import { EMPTY_PLAN_NAME } from "@/types/v1/issue/plan";-import { extractIssueUID, extractPlanUID } from "@/utils";--export enum TabKey {- Plan = "plan",- Issue = "issue",-}--export interface UseIssueTabNavigationOptions {- route: RouteLocationNormalizedLoaded;- router: Router;- plan: Ref<Plan>;- issue: Ref<Issue | undefined>;- isCreating: Ref<boolean>;- enabledNewLayout: Ref<boolean>;- t: ComposerTranslation;-}--export const useIssueTabNavigation = (- options: UseIssueTabNavigationOptions-) => {- const { route, router, plan, issue, isCreating, enabledNewLayout, t } =- options;-- const tabKey = computed(() => {- const routeName = route.name?.toString();- if (!routeName) {- // Default to Issue if no valid plan, otherwise Plan- return plan.value.name === EMPTY_PLAN_NAME ? TabKey.Issue : TabKey.Plan;- }-- if (- [- PROJECT_V1_ROUTE_PLAN_DETAIL,- PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,- PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,- ].includes(routeName)- ) {- return TabKey.Plan;- } else if (routeName === PROJECT_V1_ROUTE_ISSUE_DETAIL_V1) {- return TabKey.Issue;- }- // Fallback: Default to Issue if no valid plan, otherwise Plan- return plan.value.name === EMPTY_PLAN_NAME ? TabKey.Issue : TabKey.Plan;- });-- const availableTabs = computed<TabKey[]>(() => {- const tabs: TabKey[] = [];-- // Show Issue tab if issue exists and new layout is enabled- if (plan.value.issue && enabledNewLayout.value) {- tabs.push(TabKey.Issue);- }-- // Only show Plan tab if we have a valid plan with specs- // Don't show Plan tab for grant requests (they don't have plan specs)- const isGrantRequest = issue.value?.type === Issue_Type.GRANT_REQUEST;- const hasValidPlan =- plan.value.name !== EMPTY_PLAN_NAME && plan.value.specs.length > 0;- if (hasValidPlan && !isGrantRequest) {- tabs.push(TabKey.Plan);- }-- return tabs;- });-- const issueTabContent = computed(() => (- <div class="flex items-center gap-2">- <Layers2Icon size={18} />- <span>{t("common.overview")}</span>- </div>- ));-- const planTabContent = computed(() => (- <div class="flex items-center gap-2">- <FileDiffIcon size={18} />- <span>{t("plan.navigator.changes")}</span>- {(isCreating.value || plan.value.specs.length > 1) && (- <NTag size="tiny" round>- {plan.value.specs.length}- </NTag>- )}- </div>- ));-- const tabRender = (tab: TabKey) => {- switch (tab) {- case TabKey.Issue:- return issueTabContent.value;- case TabKey.Plan:- return planTabContent.value;- default:- return tab;- }- };-- const handleTabChange = (tab: TabKey) => {- if (!route?.params) {- console.error("Cannot navigate: route params are undefined");- return;- }-- const params = { ...route.params };- if (isCreating.value) {- params.planId = "create";- } else {- params.planId = extractPlanUID(plan.value.name);- if (plan.value.issue) {- params.issueId = extractIssueUID(plan.value.issue);- }- }-- const query = route.query || {};-- if (tab === TabKey.Issue) {- router- .push({- name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,- params: params,- query: query,- })- .catch((error) => {- console.error("Failed to navigate to Issue tab:", error);- });- } else if (tab === TabKey.Plan) {- router- .push({- name: PROJECT_V1_ROUTE_PLAN_DETAIL,- params: params,- query: query,- })- .catch((error) => {- console.error("Failed to navigate to Plan tab:", error);- });- }- };-- return {- tabKey,- availableTabs,- tabRender,- handleTabChange,- };-};diff --git a/frontend/src/components/Plan/logic/useRolloutReadyLink.ts b/frontend/src/components/Plan/logic/useRolloutReadyLink.tsindex b8782854ed..9e1b734027 100644--- a/frontend/src/components/Plan/logic/useRolloutReadyLink.ts+++ b/frontend/src/components/Plan/logic/useRolloutReadyLink.ts@@ -30,10 +30,10 @@ const ACTIONABLE_TASK_STATUSES = new Set([/*** Composable that determines whether the "Ready for Rollout" link should be shown.* This link appears when:- * - Issue is open and approved* - Issue is a database change (not export/create)* - User is not already on the rollout tab- * - There are actionable tasks in the rollout+ * - Rollout exists+ * - Issue is DONE, OR issue is OPEN and approved with actionable tasks*/export const useRolloutReadyLink = () => {const route = useRoute();@@ -44,8 +44,7 @@ export const useRolloutReadyLink = () => {});const shouldShow = computed(() => {- // Only show for OPEN issues- if (!issue.value || issue.value.status !== IssueStatus.OPEN) {+ if (!issue.value) {return false;}@@ -54,14 +53,6 @@ export const useRolloutReadyLink = () => {return false;}- // Check if issue is approved- if (- issue.value.approvalStatus !== Issue_ApprovalStatus.APPROVED &&- issue.value.approvalStatus !== Issue_ApprovalStatus.SKIPPED- ) {- return false;- }-// Hide if on rollout tabif (isOnRolloutTab.value) {return false;@@ -83,9 +74,27 @@ export const useRolloutReadyLink = () => {return false;}- // Check if there's any task that needs action- const allTasks = rollout.value.stages.flatMap((stage) => stage.tasks);- return allTasks.some((task) => ACTIONABLE_TASK_STATUSES.has(task.status));+ // For DONE issues with rollout, always show link for navigation+ if (issue.value.status === IssueStatus.DONE) {+ return true;+ }++ // For OPEN issues, check if approved and has actionable tasks+ if (issue.value.status === IssueStatus.OPEN) {+ // Check if issue is approved+ if (+ issue.value.approvalStatus !== Issue_ApprovalStatus.APPROVED &&+ issue.value.approvalStatus !== Issue_ApprovalStatus.SKIPPED+ ) {+ return false;+ }++ // Check if there's any task that needs action+ const allTasks = rollout.value.stages.flatMap((stage) => stage.tasks);+ return allTasks.some((task) => ACTIONABLE_TASK_STATUSES.has(task.status));+ }++ return false;});return {diff --git a/frontend/src/views/project/IssueDetailV1View.vue b/frontend/src/views/project/IssueDetailV1View.vueindex ca4f43613e..430fb86762 100644--- a/frontend/src/views/project/IssueDetailV1View.vue+++ b/frontend/src/views/project/IssueDetailV1View.vue@@ -11,6 +11,9 @@<!-- Grant Request View --><GrantRequestView v-else-if="issueType === IssueType.GRANT_REQUEST" />++ <!-- Database Change View -->+ <DatabaseChangeView v-else-if="issueType === IssueType.DATABASE_CHANGE" /></IssueBaseLayout></template>@@ -19,6 +22,7 @@ import { computed, onMounted, ref } from "vue";import { useRoute, useRouter } from "vue-router";import { BBSpin } from "@/bbkit";import { usePlanContextWithIssue } from "@/components/Plan";+import { DatabaseChangeView } from "@/components/Plan/components/IssueReviewView/DatabaseChangeView";import DatabaseCreateView from "@/components/Plan/components/IssueReviewView/DatabaseCreateView.vue";import DatabaseExportView from "@/components/Plan/components/IssueReviewView/DatabaseExportView.vue";import GrantRequestView from "@/components/Plan/components/IssueReviewView/GrantRequestView.vue";@@ -32,6 +36,7 @@ enum IssueType {CREATE_DATABASE = "CREATE_DATABASE",EXPORT_DATA = "EXPORT_DATA",GRANT_REQUEST = "GRANT_REQUEST",+ DATABASE_CHANGE = "DATABASE_CHANGE",}const props = defineProps<{@@ -46,49 +51,35 @@ const { enabledNewLayout } = useIssueLayoutVersion();const isLoading = ref(true);const issueType = computed(() => {- // Check issue type first for grant requests- if (issue.value.type === Issue_Type.GRANT_REQUEST) {+ if (issue.value.type === Issue_Type.GRANT_REQUEST)return IssueType.GRANT_REQUEST;- }- if (- plan.value.specs.every(- (spec) => spec.config.case === "createDatabaseConfig"- )- ) {+ const specs = plan.value.specs;+ if (specs.every((s) => s.config.case === "createDatabaseConfig"))return IssueType.CREATE_DATABASE;- } else if (- plan.value.specs.every((spec) => spec.config.case === "exportDataConfig")- ) {+ if (specs.every((s) => s.config.case === "exportDataConfig"))return IssueType.EXPORT_DATA;- }+ if (specs.some((s) => s.config.case === "changeDatabaseConfig"))+ return IssueType.DATABASE_CHANGE;return undefined;});onMounted(() => {- const isCreatingDatabasePlan = plan.value.specs.every(- (spec) => spec.config.case === "createDatabaseConfig"- );- const isExportDataPlan = plan.value.specs.every(- (spec) => spec.config.case === "exportDataConfig"- );- const isGrantRequest = issue.value.type === Issue_Type.GRANT_REQUEST;- // Redirect to legacy layout if new layout is disabled and the plan is not a database creation, export data plan, or grant request.- if (- !enabledNewLayout.value &&- !isCreatingDatabasePlan &&- !isExportDataPlan &&- !isGrantRequest- ) {- const legacyIssueSlug = issueV1Slug(- `projects/${props.projectId}/issues/${props.issueId}`,- "issue"- );+ // Redirect to legacy layout for database change issues when new layout is disabled+ const usesNewLayoutOnly =+ issueType.value === IssueType.CREATE_DATABASE ||+ issueType.value === IssueType.EXPORT_DATA ||+ issueType.value === IssueType.GRANT_REQUEST;++ if (!enabledNewLayout.value && !usesNewLayoutOnly) {router.replace({name: PROJECT_V1_ROUTE_ISSUE_DETAIL,params: {projectId: props.projectId,- issueSlug: legacyIssueSlug,+ issueSlug: issueV1Slug(+ `projects/${props.projectId}/issues/${props.issueId}`,+ "issue"+ ),},query: route.query,});diff --git a/frontend/src/views/project/IssueLayout.vue b/frontend/src/views/project/IssueLayout.vueindex 80a2b6c7f0..46fc501d69 100644--- a/frontend/src/views/project/IssueLayout.vue+++ b/frontend/src/views/project/IssueLayout.vue@@ -5,22 +5,6 @@<div class="h-full flex flex-col"><HeaderSection />- <NTabs- v-if="shouldShowNavigation"- type="line"- :value="tabKey"- tab-class="first:ml-4"- @update-value="handleTabChange"- >- <NTab- v-for="tab in availableTabs"- class="select-none"- :key="tab"- :name="tab"- :tab="tabRender(tab)"- />- </NTabs>-<div class="flex-1 flex"><router-view v-slot="{ Component }"><keep-alive :max="3">@@ -39,15 +23,10 @@<script lang="tsx" setup>import { useTitle } from "@vueuse/core";-import { NSpin, NTab, NTabs } from "naive-ui";+import { NSpin } from "naive-ui";import { computed, ref, toRef } from "vue";import { useI18n } from "vue-i18n";-import {- onBeforeRouteLeave,- onBeforeRouteUpdate,- useRoute,- useRouter,-} from "vue-router";+import { onBeforeRouteLeave, onBeforeRouteUpdate } from "vue-router";import {providePlanContext,useBasePlanContext,@@ -55,10 +34,8 @@ import {} from "@/components/Plan";import { HeaderSection } from "@/components/Plan/components";import { provideSidebarContext } from "@/components/Plan/logic/sidebar";-import { useIssueTabNavigation } from "@/components/Plan/logic/useIssueTabNavigation.tsx";import { useNavigationGuard } from "@/components/Plan/logic/useNavigationGuard";import PollerProvider from "@/components/Plan/PollerProvider.vue";-import { useIssueLayoutVersion } from "@/composables/useIssueLayoutVersion";import { useBodyLayoutContext } from "@/layouts/common";const props = defineProps<{@@ -86,7 +63,6 @@ const planBaseContext = useBasePlanContext({plan,issue,});-const { enabledNewLayout } = useIssueLayoutVersion();const containerRef = ref<HTMLElement>();const ready = computed(() => {@@ -94,22 +70,6 @@ const ready = computed(() => {return (!!issue.value || !!plan.value) && !isInitializing.value;});-const shouldShowNavigation = computed(() => {- // Show navigation if we have a valid plan with supported specs and an issue- if (!plan.value) {- return false;- }- return (- !isCreating.value &&- plan.value.specs.some(- (spec) => spec.config.case === "changeDatabaseConfig"- ) &&- plan.value.issue- );-});--const route = useRoute();-const router = useRouter();const { confirmNavigation } = useNavigationGuard();providePlanContext({@@ -124,18 +84,6 @@ providePlanContext({provideSidebarContext(containerRef);-// Tab navigation-const { tabKey, availableTabs, tabRender, handleTabChange } =- useIssueTabNavigation({- route,- router,- plan,- issue,- isCreating,- enabledNewLayout,- t,- });-const { overrideMainContainerClass } = useBodyLayoutContext();overrideMainContainerClass("py-0! px-0!");diff --git a/frontend/src/views/project/PlanSpecDetailView.vue b/frontend/src/views/project/PlanSpecDetailView.vueindex 97351cb201..583d37c5e4 100644--- a/frontend/src/views/project/PlanSpecDetailView.vue+++ b/frontend/src/views/project/PlanSpecDetailView.vue@@ -5,11 +5,31 @@</template><script lang="ts" setup>-import { computed } from "vue";-import { useRoute } from "vue-router";+import { computed, onMounted } from "vue";+import { useRoute, useRouter } from "vue-router";+import { usePlanContext } from "@/components/Plan";import { SpecDetailView } from "@/components/Plan/components";+import { PROJECT_V1_ROUTE_ISSUE_DETAIL_V1 } from "@/router/dashboard/projectV1";+import { extractIssueUID } from "@/utils";const route = useRoute();+const router = useRouter();+const { plan } = usePlanContext();const specId = computed(() => route.params.specId as string | undefined);++onMounted(() => {+ // Redirect to issue page for plans with an issue+ const hasIssue = !!plan.value.issue;+ if (hasIssue) {+ router.replace({+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,+ params: {+ projectId: route.params.projectId,+ issueId: extractIssueUID(plan.value.issue),+ },+ query: route.query,+ });+ }+});</script>diff --git a/frontend/src/views/project/PlanSpecsView.vue b/frontend/src/views/project/PlanSpecsView.vueindex 169e1ad852..8e0deb084c 100644--- a/frontend/src/views/project/PlanSpecsView.vue+++ b/frontend/src/views/project/PlanSpecsView.vue@@ -5,7 +5,11 @@import { head } from "lodash-es";import { useRoute, useRouter } from "vue-router";import { usePlanContext } from "@/components/Plan";-import { PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL } from "@/router/dashboard/projectV1";+import {+ PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,+} from "@/router/dashboard/projectV1";+import { extractIssueUID } from "@/utils";const route = useRoute();const router = useRouter();@@ -13,9 +17,25 @@ 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) {throw new Error("No spec found in the plan.");+}++// Redirect to issue page for database change plans with an issue+const hasIssue = !!plan.value.issue;+const isDatabaseChangePlan = plan.value.specs.some(+ (s) => s.config.case === "changeDatabaseConfig"+);++if (hasIssue && isDatabaseChangePlan) {+ router.replace({+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,+ params: {+ projectId: route.params.projectId,+ issueId: extractIssueUID(plan.value.issue),+ },+ query: route.query,+ });} else {router.replace({name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,