Skip to content

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

refactor: plan detail page with spec-based view (#16437)

boojackbae37a6dc066
diff --git a/backend/api/v1/plan_service.go b/backend/api/v1/plan_service.go
index 46db857ce5..18ac60f402 100644
--- a/backend/api/v1/plan_service.go
+++ b/backend/api/v1/plan_service.go
@@ -970,7 +970,6 @@ func validateSpecs(specs []*v1pb.Plan_Spec) error {
if len(specs) == 0 {
return errors.Errorf("the plan has zero spec")
}
- var databaseTarget, databaseGroupTarget int
configTypeCount := map[string]int{}
seenID := map[string]bool{}
@@ -988,27 +987,27 @@ func validateSpecs(specs []*v1pb.Plan_Spec) error {
case *v1pb.Plan_Spec_CreateDatabaseConfig:
configTypeCount["create_database"]++
case *v1pb.Plan_Spec_ChangeDatabaseConfig:
+ configTypeCount["change_database"]++
+ var databaseTarget, databaseGroupTarget int
for _, target := range config.ChangeDatabaseConfig.Targets {
if _, _, err := common.GetInstanceDatabaseID(target); err == nil {
databaseTarget++
- configTypeCount["change_database"]++
} else if _, _, err := common.GetProjectIDDatabaseGroupID(target); err == nil {
databaseGroupTarget++
- configTypeCount["change_database_group"]++
} else {
return errors.Errorf("invalid target %v", target)
}
}
+ // Disallow mixing database and database group targets in the same spec.
+ if databaseTarget > 0 && databaseGroupTarget > 0 {
+ return errors.Errorf("found databaseTarget and databaseGroupTarget, expect only one kind")
+ }
case *v1pb.Plan_Spec_ExportDataConfig:
configTypeCount["export_data"]++
default:
return errors.Errorf("invalid spec type")
}
}
-
- if databaseTarget > 0 && databaseGroupTarget > 0 {
- return errors.Errorf("found databaseGroupTarget and databaseTarget, expect only one kind")
- }
if len(configTypeCount) > 1 {
return errors.Errorf("plan contains multiple types of spec configurations (%v), but each plan must contain only one type", len(configTypeCount))
}
diff --git a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue
index 409815964c..65955cf102 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue
@@ -10,8 +10,8 @@ import {
specForTask,
useIssueContext,
} from "@/components/IssueV1/logic";
-import { PreBackupSection } from "@/components/Plan/components/Sidebar";
-import { providePreBackupSettingContext } from "@/components/Plan/components/Sidebar/PreBackupSection/context";
+import { PreBackupSection } from "@/components/Plan/components/Configuration";
+import { providePreBackupSettingContext } from "@/components/Plan/components/Configuration/PreBackupSection/context";
import { databaseForTask } from "@/components/Rollout/RolloutDetail";
import { useCurrentProjectV1 } from "@/store";
import type { Plan } from "@/types/proto/v1/plan_service";
@@ -74,4 +74,11 @@ preBackupEvents.on("update", () => {
eager: true,
});
});
+
+defineExpose({
+ shouldShow: computed(
+ () =>
+ shouldShowTaskRollbackSection.value || shouldShowPreBackupSection.value
+ ),
+});
</script>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/Sidebar.vue b/frontend/src/components/IssueV1/components/Sidebar/Sidebar.vue
index 33a6fb5b51..7f3e1e5a44 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/Sidebar.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/Sidebar.vue
@@ -5,7 +5,11 @@
<ReviewSection />
<IssueLabels />
- <template v-if="selectedSpec">
+ <template
+ v-if="
+ selectedSpec && (shouldShowPreBackupSection || shouldShowGhostSection)
+ "
+ >
<div class="border-t -mx-3" />
<NTooltip :showArrow="false">
<template #trigger>
@@ -25,7 +29,7 @@
</template>
{{ $t("plan.options.split-into-multiple-issues-tip") }}
</NTooltip>
- <PreBackupSection />
+ <PreBackupSection ref="preBackupSectionRef" />
<GhostSection v-if="shouldShowGhostSection" />
</template>
</div>
@@ -33,10 +37,10 @@
<script lang="ts" setup>
import { NTooltip } from "naive-ui";
-import { computed } from "vue";
+import { computed, ref } from "vue";
import { targetsForSpec } from "@/components/Plan";
-import { GhostSection } from "@/components/Plan/components/Sidebar";
-import { provideGhostSettingContext } from "@/components/Plan/components/Sidebar/GhostSection/context";
+import { GhostSection } from "@/components/Plan/components/Configuration";
+import { provideGhostSettingContext } from "@/components/Plan/components/Configuration/GhostSection/context";
import { useCurrentProjectV1 } from "@/store";
import type { Plan } from "@/types/proto/v1/plan_service";
import { specForTask, useIssueContext } from "../../logic";
@@ -48,6 +52,7 @@ import TaskCheckSummarySection from "./TaskCheckSummarySection";
const { isCreating, selectedTask, issue, events } = useIssueContext();
const { project } = useCurrentProjectV1();
+const preBackupSectionRef = ref<InstanceType<typeof PreBackupSection>>();
const selectedSpec = computed(() =>
specForTask(issue.value.planEntity as Plan, selectedTask.value)
@@ -71,6 +76,10 @@ const { shouldShow: shouldShowGhostSection, events: ghostEvents } =
issue,
});
+const shouldShowPreBackupSection = computed(() => {
+ return preBackupSectionRef.value?.shouldShow ?? false;
+});
+
ghostEvents.on("update", () => {
events.emit("status-changed", {
eager: true,
diff --git a/frontend/src/components/Plan/PlanDetailPage.vue b/frontend/src/components/Plan/PlanDetailPage.vue
index 3e8cc1c2fa..fcb10f1791 100644
--- a/frontend/src/components/Plan/PlanDetailPage.vue
+++ b/frontend/src/components/Plan/PlanDetailPage.vue
@@ -3,77 +3,30 @@
<div class="border-b">
<HeaderSection />
</div>
- <div class="flex-1 flex flex-row">
+ <div class="w-full flex-1 flex flex-row">
+ <Navigator />
<div
class="flex-1 flex flex-col hide-scrollbar divide-y overflow-x-hidden"
>
- <SpecListSection />
- <SQLCheckSection v-if="isCreating" />
- <PlanCheckSection v-else />
- <StatementSection />
- <DescriptionSection />
- </div>
- <div
- v-if="sidebarMode == 'DESKTOP'"
- class="hide-scrollbar border-l"
- :style="{
- width: `${desktopSidebarWidth}px`,
- }"
- >
- <Sidebar />
+ <Overview v-if="!selectedSpec" />
+ <SpecDetailView v-else :key="selectedSpec.id" />
</div>
</div>
</div>
-
- <template v-if="sidebarMode === 'MOBILE'">
- <!-- mobile sidebar -->
- <Drawer :show="mobileSidebarOpen" @close="mobileSidebarOpen = false">
- <div
- style="
- min-width: 240px;
- width: 80vw;
- max-width: 320px;
- padding: 0.5rem 0;
- "
- >
- <Sidebar v-if="sidebarMode === 'MOBILE'" />
- </div>
- </Drawer>
- </template>
</template>
<script setup lang="ts">
import { ref } from "vue";
-import { Drawer } from "@/components/v2";
-import { useCurrentProjectV1 } from "@/store";
import {
HeaderSection,
- PlanCheckSection,
- StatementSection,
- DescriptionSection,
- SQLCheckSection,
- SpecListSection,
+ Navigator,
+ Overview,
+ SpecDetailView,
} from "./components";
-import { providePlanSQLCheckContext } from "./components/SQLCheckSection";
-import Sidebar from "./components/Sidebar";
import { usePlanContext, usePollPlan } from "./logic";
-import { provideSidebarContext } from "./logic";
-const { project } = useCurrentProjectV1();
-const { isCreating, plan, selectedSpec } = usePlanContext();
+const { selectedSpec } = usePlanContext();
const containerRef = ref<HTMLElement>();
usePollPlan();
-
-providePlanSQLCheckContext({
- project,
- plan: plan,
- selectedSpec: selectedSpec,
-});
-
-const {
- mode: sidebarMode,
- desktopSidebarWidth,
- mobileSidebarOpen,
-} = provideSidebarContext(containerRef);
</script>
diff --git a/frontend/src/components/Plan/components/AddSpecDrawer.vue b/frontend/src/components/Plan/components/AddSpecDrawer.vue
new file mode 100644
index 0000000000..c8c223dbb9
--- /dev/null
+++ b/frontend/src/components/Plan/components/AddSpecDrawer.vue
@@ -0,0 +1,171 @@
+<template>
+ <Drawer
+ v-model:show="show"
+ :width="640"
+ :mask-closable="true"
+ placement="right"
+ class="!w-[100vw] sm:!w-[80vw]"
+ >
+ <DrawerContent :title="$t('plan.add-spec')" closable>
+ <div class="flex flex-col gap-y-4">
+ <!-- Step 1: Select Change Type -->
+ <div class="flex flex-row items-center gap-x-4">
+ <label class="text-sm font-medium text-main block">
+ {{ $t("plan.change-type") }}
+ </label>
+ <NRadioGroup v-model:value="changeType" class="space-y-2">
+ <NRadio value="MIGRATE">
+ <div class="flex items-center gap-2">
+ <FileDiffIcon class="w-4 h-4" />
+ <span>{{ $t("plan.schema-migration") }}</span>
+ </div>
+ <div class="text-sm text-control-light ml-6">
+ {{ $t("plan.schema-migration-description") }}
+ </div>
+ </NRadio>
+ <NRadio value="DATA">
+ <div class="flex items-center gap-2">
+ <EditIcon class="w-4 h-4" />
+ <span>{{ $t("plan.data-change") }}</span>
+ </div>
+ <div class="text-sm text-control-light ml-6">
+ {{ $t("plan.data-change-description") }}
+ </div>
+ </NRadio>
+ </NRadioGroup>
+ </div>
+
+ <!-- Step 2: Select Targets -->
+ <div>
+ <label class="text-sm font-medium text-main mb-2 block">
+ {{ $t("plan.select-targets") }}
+ </label>
+ <DatabaseAndGroupSelector
+ :project="project"
+ :value="databaseSelectState"
+ @update:value="handleUpdateSelection"
+ />
+ </div>
+ </div>
+ <template #footer>
+ <div class="flex items-center justify-end gap-x-3">
+ <NButton @click="handleCancel">
+ {{ $t("common.cancel") }}
+ </NButton>
+ <NButton
+ type="primary"
+ :disabled="!canSubmit"
+ :loading="isCreating"
+ @click="handleConfirm"
+ >
+ {{ $t("common.add") }}
+ </NButton>
+ </div>
+ </template>
+ </DrawerContent>
+ </Drawer>
+</template>
+
+<script setup lang="ts">
+import { FileDiffIcon, EditIcon } from "lucide-vue-next";
+import { NButton, NRadio, NRadioGroup } from "naive-ui";
+import { v4 as uuidv4 } from "uuid";
+import { computed, reactive, ref, watch } from "vue";
+import DatabaseAndGroupSelector from "@/components/DatabaseAndGroupSelector";
+import type { DatabaseSelectState } from "@/components/DatabaseAndGroupSelector";
+import { getLocalSheetByName, getNextLocalSheetUID } from "@/components/Plan";
+import { Drawer, DrawerContent } from "@/components/v2";
+import { useCurrentProjectV1 } from "@/store";
+import {
+ Plan_ChangeDatabaseConfig,
+ Plan_ChangeDatabaseConfig_Type,
+} from "@/types/proto/v1/plan_service";
+import type { Plan_Spec } from "@/types/proto/v1/plan_service";
+import { Sheet } from "@/types/proto/v1/sheet_service";
+
+const emit = defineEmits<{
+ (event: "created", spec: Plan_Spec): void;
+}>();
+
+const { project } = useCurrentProjectV1();
+const show = defineModel<boolean>("show", { default: false });
+
+const changeType = ref<"MIGRATE" | "DATA">("MIGRATE");
+const isCreating = ref(false);
+
+const databaseSelectState = reactive<DatabaseSelectState>({
+ changeSource: "DATABASE",
+ selectedDatabaseNameList: [],
+});
+
+const hasSelection = computed(() => {
+ if (databaseSelectState.changeSource === "DATABASE") {
+ return databaseSelectState.selectedDatabaseNameList.length > 0;
+ } else {
+ return !!databaseSelectState.selectedDatabaseGroup;
+ }
+});
+
+const canSubmit = computed(() => {
+ return hasSelection.value && changeType.value;
+});
+
+// Reset state when drawer opens
+watch(show, (newVal) => {
+ if (newVal) {
+ changeType.value = "MIGRATE";
+ databaseSelectState.changeSource = "DATABASE";
+ databaseSelectState.selectedDatabaseNameList = [];
+ databaseSelectState.selectedDatabaseGroup = undefined;
+ isCreating.value = false;
+ }
+});
+
+const handleUpdateSelection = (newState: DatabaseSelectState) => {
+ Object.assign(databaseSelectState, newState);
+};
+
+const handleCancel = () => {
+ show.value = false;
+};
+
+const handleConfirm = async () => {
+ if (!canSubmit.value) return;
+
+ isCreating.value = true;
+ try {
+ // Get targets
+ const targets: string[] = [];
+ if (databaseSelectState.changeSource === "DATABASE") {
+ targets.push(...databaseSelectState.selectedDatabaseNameList);
+ } else if (databaseSelectState.selectedDatabaseGroup) {
+ targets.push(databaseSelectState.selectedDatabaseGroup);
+ }
+
+ const sheetUID = getNextLocalSheetUID();
+ const sheet = Sheet.fromPartial({
+ ...getLocalSheetByName(`${project.value.name}/sheets/${sheetUID}`),
+ title:
+ changeType.value === "MIGRATE" ? "Schema Migration" : "Data Change",
+ });
+
+ // Create spec
+ const spec: Plan_Spec = {
+ id: uuidv4(),
+ changeDatabaseConfig: Plan_ChangeDatabaseConfig.fromPartial({
+ targets,
+ type:
+ changeType.value === "MIGRATE"
+ ? Plan_ChangeDatabaseConfig_Type.MIGRATE
+ : Plan_ChangeDatabaseConfig_Type.DATA,
+ sheet: sheet.name,
+ }),
+ };
+
+ emit("created", spec);
+ show.value = false;
+ } finally {
+ isCreating.value = false;
+ }
+};
+</script>
diff --git a/frontend/src/components/Plan/components/Configuration/Configuration.vue b/frontend/src/components/Plan/components/Configuration/Configuration.vue
new file mode 100644
index 0000000000..dc22a8a9ed
--- /dev/null
+++ b/frontend/src/components/Plan/components/Configuration/Configuration.vue
@@ -0,0 +1,58 @@
+<template>
+ <div v-if="shouldShow" class="flex flex-col gap-y-3 py-3 px-4">
+ <p class="text-base font-medium">
+ {{ $t("plan.options.self") }}
+ </p>
+ <div class="w-auto">
+ <GhostSection v-if="shouldShowGhostSection" />
+ <PreBackupSection v-if="shouldShowPreBackupSection" />
+ </div>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { computed } from "vue";
+import { useCurrentProjectV1 } from "@/store";
+import { usePlanContext } from "../../logic";
+import useSelectedSpec from "../common/useSelectedSpec";
+import GhostSection from "./GhostSection";
+import { provideGhostSettingContext } from "./GhostSection/context";
+import PreBackupSection from "./PreBackupSection";
+import { providePreBackupSettingContext } from "./PreBackupSection/context";
+
+const { project } = useCurrentProjectV1();
+const { isCreating, plan, events } = usePlanContext();
+const selectedSpec = useSelectedSpec();
+
+const { shouldShow: shouldShowGhostSection, events: ghostEvents } =
+ provideGhostSettingContext({
+ project,
+ plan: plan,
+ selectedSpec,
+ isCreating,
+ });
+
+const { shouldShow: shouldShowPreBackupSection, events: preBackupEvents } =
+ providePreBackupSettingContext({
+ project,
+ plan: plan,
+ selectedSpec,
+ isCreating,
+ });
+
+const shouldShow = computed(() => {
+ return shouldShowGhostSection.value || shouldShowPreBackupSection.value;
+});
+
+preBackupEvents.on("update", () => {
+ events.emit("status-changed", {
+ eager: true,
+ });
+});
+
+ghostEvents.on("update", () => {
+ events.emit("status-changed", {
+ eager: true,
+ });
+});
+</script>
diff --git a/frontend/src/components/Plan/components/Sidebar/GhostSection/FlagsForm/BoolFlag.vue b/frontend/src/components/Plan/components/Configuration/GhostSection/FlagsForm/BoolFlag.vue
similarity index 100%
rename from frontend/src/components/Plan/components/Sidebar/GhostSection/FlagsForm/BoolFlag.vue
rename to frontend/src/components/Plan/components/Configuration/GhostSection/FlagsForm/BoolFlag.vue
diff --git a/frontend/src/components/Plan/components/Sidebar/GhostSection/FlagsForm/FlagsForm.vue b/frontend/src/components/Plan/components/Configuration/GhostSection/FlagsForm/FlagsForm.vue
similarity index 100%
rename from frontend/src/components/Plan/components/Sidebar/GhostSection/FlagsForm/FlagsForm.vue
rename to frontend/src/components/Plan/components/Configuration/GhostSection/FlagsForm/FlagsForm.vue
diff --git a/frontend/src/components/Plan/components/Sidebar/GhostSection/FlagsForm/constants.ts b/frontend/src/components/Plan/components/Configuration/GhostSection/FlagsForm/constants.ts
similarity index 100%
rename from frontend/src/components/Plan/components/Sidebar/GhostSection/FlagsForm/constants.ts
rename to frontend/src/components/Plan/components/Configuration/GhostSection/FlagsForm/constants.ts
diff --git a/frontend/src/components/Plan/components/Sidebar/GhostSection/FlagsForm/index.ts b/frontend/src/components/Plan/components/Configuration/GhostSection/FlagsForm/index.ts
similarity index 100%
rename from frontend/src/components/Plan/components/Sidebar/GhostSection/FlagsForm/index.ts
rename to frontend/src/components/Plan/components/Configuration/GhostSection/FlagsForm/index.ts
diff --git a/frontend/src/components/Plan/components/Sidebar/GhostSection/GhostFlagsPanel.vue b/frontend/src/components/Plan/components/Configuration/GhostSection/GhostFlagsPanel.vue
similarity index 99%
rename from frontend/src/components/Plan/components/Sidebar/GhostSection/GhostFlagsPanel.vue
rename to frontend/src/components/Plan/components/Configuration/GhostSection/GhostFlagsPanel.vue
index 31ff156009..dcb95ea41b 100644
--- a/frontend/src/components/Plan/components/Sidebar/GhostSection/GhostFlagsPanel.vue
+++ b/frontend/src/components/Plan/components/Configuration/GhostSection/GhostFlagsPanel.vue
@@ -1,5 +1,5 @@
<template>
- <Drawer :show="show">
+ <Drawer :show="show" @close="close">
<DrawerContent
:title="title"
class="w-[100vw] md:max-w-[calc(100vw-8rem)] md:w-[40vw]"
diff --git a/frontend/src/components/Plan/components/Sidebar/GhostSection/GhostSection.vue b/frontend/src/components/Plan/components/Configuration/GhostSection/GhostSection.vue
similarity index 76%
rename from frontend/src/components/Plan/components/Sidebar/GhostSection/GhostSection.vue
rename to frontend/src/components/Plan/components/Configuration/GhostSection/GhostSection.vue
index d068a70d00..5c07d3627d 100644
--- a/frontend/src/components/Plan/components/Sidebar/GhostSection/GhostSection.vue
+++ b/frontend/src/components/Plan/components/Configuration/GhostSection/GhostSection.vue
@@ -1,8 +1,7 @@
<template>
<div class="flex flex-col items-start gap-1">
- <div
- class="w-full flex flex-row items-center justify-between whitespace-nowrap"
- >
+ <div class="w-full flex flex-row items-center gap-2 whitespace-nowrap">
+ <GhostSwitch />
<div class="textlabel flex items-center gap-x-1 whitespace-nowrap">
<NTooltip>
<template #trigger>
@@ -26,24 +25,22 @@
</template>
</NTooltip>
</div>
- <GhostSwitch />
+ <NButton
+ v-if="enabled && allowChange"
+ tag="div"
+ size="tiny"
+ style="--n-padding: 0 5px"
+ @click="showFlagsPanel = true"
+ >
+ <template #icon>
+ <WrenchIcon class="w-4 h-4" />
+ </template>
+ <template #default>
+ {{ $t("task.online-migration.configure") }}
+ </template>
+ </NButton>
</div>
- <NButton
- v-if="enabled && allowChange"
- tag="div"
- size="small"
- style="--n-padding: 0 5px"
- @click="showFlagsPanel = true"
- >
- <template #icon>
- <WrenchIcon class="w-4 h-4" />
- </template>
- <template #default>
- {{ $t("task.online-migration.configure") }}
- </template>
- </NButton>
-
<GhostFlagsPanel
:show="showFlagsPanel"
@update:show="(show) => (showFlagsPanel = show)"
diff --git a/frontend/src/components/Plan/components/Sidebar/GhostSection/GhostSwitch.vue b/frontend/src/components/Plan/components/Configuration/GhostSection/GhostSwitch.vue
similarity index 99%
rename from frontend/src/components/Plan/components/Sidebar/GhostSection/GhostSwitch.vue
rename to frontend/src/components/Plan/components/Configuration/GhostSection/GhostSwitch.vue
index 343230ae0b..5861c242ef 100644
--- a/frontend/src/components/Plan/components/Sidebar/GhostSection/GhostSwitch.vue
+++ b/frontend/src/components/Plan/components/Configuration/GhostSection/GhostSwitch.vue
@@ -2,6 +2,7 @@
<NTooltip :disabled="!tooltipMessage" :showArrow="false">
<template #trigger>
<NSwitch
+ size="small"
:value="enabled"
:disabled="!allowChange || errors.length > 0"
@update:value="toggleChecked"
diff --git a/frontend/src/components/Plan/components/Sidebar/GhostSection/common.ts b/frontend/src/components/Plan/components/Configuration/GhostSection/common.ts
similarity index 95%
rename from frontend/src/components/Plan/components/Sidebar/GhostSection/common.ts
rename to frontend/src/components/Plan/components/Configuration/GhostSection/common.ts
index 65cfc48bd0..9b53bcd44f 100644
--- a/frontend/src/components/Plan/components/Sidebar/GhostSection/common.ts
+++ b/frontend/src/components/Plan/components/Configuration/GhostSection/common.ts
@@ -7,6 +7,8 @@ import {
} from "@/types/proto/v1/plan_service";
import { semverCompare } from "@/utils";
+export const GHOST_AVAILABLE_ENGINES = [Engine.MYSQL, Engine.MARIADB];
+
export const MIN_GHOST_SUPPORT_MYSQL_VERSION = "5.6.0";
export const MIN_GHOST_SUPPORT_MARIADB_VERSION = "10.6.0";
diff --git a/frontend/src/components/Plan/components/Sidebar/GhostSection/context.ts b/frontend/src/components/Plan/components/Configuration/GhostSection/context.ts
similarity index 94%
rename from frontend/src/components/Plan/components/Sidebar/GhostSection/context.ts
rename to frontend/src/components/Plan/components/Configuration/GhostSection/context.ts
index e52c6f8cd3..633bfcad69 100644
--- a/frontend/src/components/Plan/components/Sidebar/GhostSection/context.ts
+++ b/frontend/src/components/Plan/components/Configuration/GhostSection/context.ts
@@ -16,7 +16,11 @@ import {
hasProjectPermissionV2,
isNullOrUndefined,
} from "@/utils";
-import { allowGhostForSpec, getGhostEnabledForSpec } from "./common";
+import {
+ allowGhostForSpec,
+ getGhostEnabledForSpec,
+ GHOST_AVAILABLE_ENGINES,
+} from "./common";
export const KEY = Symbol(
"bb.plan.setting.gh-ost"
@@ -65,6 +69,9 @@ export const provideGhostSettingContext = (refs: {
return (
selectedSpec.value &&
allowGhostForSpec(selectedSpec.value) &&
+ databases.value.every((db) =>
+ GHOST_AVAILABLE_ENGINES.includes(db.instanceResource.engine)
+ ) &&
!isNullOrUndefined(getGhostEnabledForSpec(selectedSpec.value))
);
});
diff --git a/frontend/src/components/Plan/components/Sidebar/GhostSection/index.ts b/frontend/src/components/Plan/components/Configuration/GhostSection/index.ts
similarity index 100%
rename from frontend/src/components/Plan/components/Sidebar/GhostSection/index.ts
rename to frontend/src/components/Plan/components/Configuration/GhostSection/index.ts
diff --git a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSection.vue b/frontend/src/components/Plan/components/Configuration/PreBackupSection/PreBackupSection.vue
similarity index 73%
rename from frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSection.vue
rename to frontend/src/components/Plan/components/Configuration/PreBackupSection/PreBackupSection.vue
index 835e5a0741..a4cf611a77 100644
--- a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSection.vue
+++ b/frontend/src/components/Plan/components/Configuration/PreBackupSection/PreBackupSection.vue
@@ -1,7 +1,8 @@
<template>
<div
- class="w-full flex items-center justify-between gap-x-2 gap-y-1 flex-wrap min-h-[34px] whitespace-nowrap"
+ class="w-full flex items-center justify-start gap-x-2 flex-wrap min-h-[34px] whitespace-nowrap"
>
+ <PreBackupSwitch />
<NTooltip>
<template #trigger>
<div class="textlabel flex items-center">
@@ -14,9 +15,6 @@
</div>
</template>
</NTooltip>
- <div class="flex items-center">
- <PreBackupSwitch />
- </div>
</div>
</template>
diff --git a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSwitch.vue b/frontend/src/components/Plan/components/Configuration/PreBackupSection/PreBackupSwitch.vue
similarity index 85%
rename from frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSwitch.vue
rename to frontend/src/components/Plan/components/Configuration/PreBackupSection/PreBackupSwitch.vue
index a602f9a83a..1d7a3e335c 100644
--- a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSwitch.vue
+++ b/frontend/src/components/Plan/components/Configuration/PreBackupSection/PreBackupSwitch.vue
@@ -1,25 +1,24 @@
<template>
- <div class="flex items-center">
- <NTooltip :disabled="!tooltipMessage" :showArrow="false">
- <template #trigger>
- <NSwitch
- :value="enabled"
- :disabled="!allowChange || errors.length > 0"
- @update:value="(on) => handleToggle(on)"
- />
- </template>
- <div class="max-w-sm">
- <p class="opacity-80">{{ tooltipMessage }}</p>
- <ErrorList v-if="errors.length > 0" :errors="errors" class="mt-2" />
- <LearnMoreLink
- v-if="disallowPreBackupLink && errors.length === 0"
- :url="disallowPreBackupLink"
- color="light"
- class="mt-1 text-sm"
- />
- </div>
- </NTooltip>
- </div>
+ <NTooltip :disabled="!tooltipMessage" :showArrow="false">
+ <template #trigger>
+ <NSwitch
+ size="small"
+ :value="enabled"
+ :disabled="!allowChange || errors.length > 0"
+ @update:value="(on) => handleToggle(on)"
+ />
+ </template>
+ <div class="max-w-sm">
+ <p class="opacity-80">{{ tooltipMessage }}</p>
+ <ErrorList v-if="errors.length > 0" :errors="errors" class="mt-2" />
+ <LearnMoreLink
+ v-if="disallowPreBackupLink && errors.length === 0"
+ :url="disallowPreBackupLink"
+ color="light"
+ class="mt-1 text-sm"
+ />
+ </div>
+ </NTooltip>
</template>
<script lang="ts" setup>
diff --git a/frontend/src/components/Plan/components/Configuration/PreBackupSection/common.ts b/frontend/src/components/Plan/components/Configuration/PreBackupSection/common.ts
new file mode 100644
index 0000000000..0050e7baee
--- /dev/null
+++ b/frontend/src/components/Plan/components/Configuration/PreBackupSection/common.ts
@@ -0,0 +1,9 @@
+import { Engine } from "@/types/proto/v1/common";
+
+export const BACKUP_AVAILABLE_ENGINES = [
+ Engine.MYSQL,
+ Engine.TIDB,
+ Engine.MSSQL,
+ Engine.ORACLE,
+ Engine.POSTGRES,
+];
diff --git a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/context.ts b/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts
similarity index 94%
rename from frontend/src/components/Plan/components/Sidebar/PreBackupSection/context.ts
rename to frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts
index 8258744e21..272cd49e47 100644
--- a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/context.ts
+++ b/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts
@@ -25,6 +25,7 @@ import {
type Rollout,
} from "@/types/proto/v1/rollout_service";
import { flattenTaskV1List, hasProjectPermissionV2 } from "@/utils";
+import { BACKUP_AVAILABLE_ENGINES } from "./common";
export const PRE_BACKUP_AVAILABLE_ENGINES = [
Engine.MYSQL,
@@ -76,9 +77,15 @@ export const providePreBackupSettingContext = (refs: {
) {
return false;
}
- // Always show pre-backup for database change spec.
if (isDatabaseChangeSpec(selectedSpec.value)) {
- return true;
+ // If any of the databases in the spec is not supported, do not show.
+ if (
+ !databases.value.some((db) =>
+ BACKUP_AVAILABLE_ENGINES.includes(db.instanceResource.engine)
+ )
+ ) {
+ return false;
+ }
}
return true;
});
diff --git a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/index.ts b/frontend/src/components/Plan/components/Configuration/PreBackupSection/index.ts
similarity index 100%
rename from frontend/src/components/Plan/components/Sidebar/PreBackupSection/index.ts
rename to frontend/src/components/Plan/components/Configuration/PreBackupSection/index.ts
diff --git a/frontend/src/components/Plan/components/Sidebar/index.ts b/frontend/src/components/Plan/components/Configuration/index.ts
similarity index 63%
rename from frontend/src/components/Plan/components/Sidebar/index.ts
rename to frontend/src/components/Plan/components/Configuration/index.ts
index 6e71b5d5d3..51ecbcb2bb 100644
--- a/frontend/src/components/Plan/components/Sidebar/index.ts
+++ b/frontend/src/components/Plan/components/Configuration/index.ts
@@ -1,7 +1,7 @@
-import PreBackupSection from "./PreBackupSection";
+import Configuration from "./Configuration.vue";
import GhostSection from "./GhostSection";
-import Sidebar from "./Sidebar.vue";
+import PreBackupSection from "./PreBackupSection";
-export default Sidebar;
+export default Configuration;
export { PreBackupSection, GhostSection };
diff --git a/frontend/src/components/Plan/components/DescriptionSection/DescriptionSection.vue b/frontend/src/components/Plan/components/DescriptionSection/DescriptionSection.vue
index 0a246583ed..fc08cda0b8 100644
--- a/frontend/src/components/Plan/components/DescriptionSection/DescriptionSection.vue
+++ b/frontend/src/components/Plan/components/DescriptionSection/DescriptionSection.vue
@@ -1,17 +1,19 @@
<template>
- <div class="px-4 py-2 flex flex-col gap-y-2">
- <div class="flex items-center justify-between">
- <span class="textlabel">
- {{ title }}
- </span>
+ <div class="">
+ <div class="flex items-center justify-between mb-3">
+ <h2 class="text-lg font-semibold">{{ $t("common.description") }}</h2>
<div v-if="!isCreating && allowEdit" class="flex items-center gap-x-2">
- <NButton v-if="!state.isEditing" size="tiny" @click.prevent="beginEdit">
+ <NButton
+ v-if="!state.isEditing"
+ size="small"
+ @click.prevent="beginEdit"
+ >
{{ $t("common.edit") }}
</NButton>
<NButton
v-if="state.isEditing"
- size="tiny"
+ size="small"
:disabled="state.description === plan.description"
:loading="state.isUpdating"
@click.prevent="saveEdit"
@@ -20,7 +22,7 @@
</NButton>
<NButton
v-if="state.isEditing"
- size="tiny"
+ size="small"
quaternary
@click.prevent="cancelEdit"
>
@@ -29,39 +31,36 @@
</div>
</div>
- <div class="text-sm">
- <NInput
- v-if="isCreating || state.isEditing"
- ref="inputRef"
- v-model:value="state.description"
- :placeholder="$t('issue.add-some-description')"
- :autosize="{ minRows: 3, maxRows: 10 }"
- :disabled="state.isUpdating"
- :loading="state.isUpdating"
- style="
- width: 100%;
- --n-placeholder-color: rgb(var(--color-control-placeholder));
- "
- type="textarea"
- size="small"
- @update:value="onDescriptionChange"
- />
- <div
- v-else
- class="min-h-[3rem] max-h-[12rem] whitespace-pre-wrap px-[10px] py-[4.5px] text-sm"
- >
- <template v-if="plan.description">
- <iframe
- v-if="plan.description"
- ref="contentPreviewArea"
- :srcdoc="renderedContent"
- class="rounded-md w-full overflow-hidden"
- />
- </template>
- <span v-else class="text-control-placeholder">
- {{ $t("issue.add-some-description") }}
- </span>
- </div>
+ <NInput
+ v-if="isCreating || state.isEditing"
+ ref="inputRef"
+ v-model:value="state.description"
+ :placeholder="$t('issue.add-some-description')"
+ :autosize="{ minRows: 3, maxRows: 10 }"
+ :disabled="state.isUpdating"
+ :loading="state.isUpdating"
+ style="
+ width: 100%;
+ --n-placeholder-color: rgb(var(--color-control-placeholder));
+ "
+ type="textarea"
+ @update:value="onDescriptionChange"
+ />
+ <div
+ v-else
+ class="min-h-[4rem] max-h-[12rem] whitespace-pre-wrap px-[10px] py-[4.5px] border rounded"
+ >
+ <template v-if="plan.description">
+ <iframe
+ v-if="plan.description"
+ ref="contentPreviewArea"
+ :srcdoc="renderedContent"
+ class="w-full overflow-hidden"
+ />
+ </template>
+ <span v-else class="text-control-placeholder">
+ {{ $t("issue.add-some-description") }}
+ </span>
</div>
</div>
</template>
@@ -102,10 +101,6 @@ const state = reactive<LocalState>({
const inputRef = ref<InstanceType<typeof NInput>>();
-const title = computed(() => {
- return t("common.description");
-});
-
const allowEdit = computed(() => {
if (isCreating.value) {
return true;
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue
index e3b3f272dd..ed9a2272df 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue
@@ -33,7 +33,6 @@ import { zindexable as vZindexable } from "vdirs";
import { computed, nextTick, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
-import formatSQL from "@/components/MonacoEditor/sqlFormatter";
import { ErrorList } from "@/components/Plan/components/common";
import {
databaseEngineForSpec,
@@ -44,26 +43,20 @@ import { usePlanContext } from "@/components/Plan/logic";
import { planServiceClient } from "@/grpcweb";
import { PROJECT_V1_ROUTE_REVIEW_CENTER_DETAIL } from "@/router/dashboard/projectV1";
import { useCurrentProjectV1, useSheetV1Store } from "@/store";
-import { dialectOfEngineV1, languageOfEngineV1 } from "@/types";
-import type { Engine } from "@/types/proto/v1/common";
import { type Plan_ChangeDatabaseConfig } from "@/types/proto/v1/plan_service";
import type { Sheet } from "@/types/proto/v1/sheet_service";
import type { ComposedPlan } from "@/types/v1/issue/plan";
import {
extractProjectResourceName,
extractSheetUID,
- getSheetStatement,
hasProjectPermissionV2,
planV1Slug,
- setSheetStatement,
} from "@/utils";
-const MAX_FORMATTABLE_STATEMENT_SIZE = 10000; // 10K characters
-
const { t } = useI18n();
const router = useRouter();
const { project } = useCurrentProjectV1();
-const { plan, formatOnSave } = usePlanContext();
+const { plan } = usePlanContext();
const sheetStore = useSheetV1Store();
const loading = ref(false);
@@ -133,7 +126,6 @@ const createSheets = async () => {
const engine = await databaseEngineForSpec(spec);
sheet.engine = engine;
pendingCreateSheetMap.set(sheet.name, sheet);
- await maybeFormatSQL(sheet, engine);
}
}
const pendingCreateSheetList = Array.from(pendingCreateSheetMap.values());
@@ -154,25 +146,4 @@ const createSheets = async () => {
}
});
};
-
-const maybeFormatSQL = async (sheet: Sheet, engine: Engine) => {
- if (!formatOnSave.value) {
- return;
- }
- const language = languageOfEngineV1(engine);
- if (language !== "sql") {
- return;
- }
- const dialect = dialectOfEngineV1(engine);
- const statement = getSheetStatement(sheet);
- if (statement.length > MAX_FORMATTABLE_STATEMENT_SIZE) {
- return;
- }
- const { error, data: formatted } = await formatSQL(statement, dialect);
- if (error) {
- return;
- }
-
- setSheetStatement(sheet, formatted);
-};
</script>
diff --git a/frontend/src/components/Plan/components/Navigator.vue b/frontend/src/components/Plan/components/Navigator.vue
new file mode 100644
index 0000000000..2eb95f4dfd
--- /dev/null
+++ b/frontend/src/components/Plan/components/Navigator.vue
@@ -0,0 +1,282 @@
+<template>
+ <div class="w-60 flex flex-col border-r">
+ <!-- Navigator Content -->
+ <NScrollbar class="flex-1">
+ <div class="py-2">
+ <!-- Overview Tab -->
+ <div
+ class="mx-2 px-3 py-2 rounded-md cursor-pointer group transition-all"
+ :class="[
+ !selectedSpec
+ ? 'bg-accent bg-opacity-10 shadow-sm'
+ : 'hover:bg-gray-50',
+ ]"
+ @click="handleSelectOverview"
+ >
+ <div class="flex items-center gap-2">
+ <LayoutDashboardIcon
+ class="w-4 h-4 transition-colors"
+ :class="[
+ !selectedSpec
+ ? 'text-accent'
+ : 'text-control-light group-hover:text-main',
+ ]"
+ />
+ <span
+ class="text-sm font-medium transition-colors"
+ :class="[
+ !selectedSpec
+ ? 'text-accent'
+ : 'text-control group-hover:text-main',
+ ]"
+ >
+ {{ $t("plan.navigator.overview") }}
+ </span>
+ </div>
+ </div>
+
+ <!-- Specs Section -->
+ <div class="px-4 pb-2 mt-3">
+ <div class="flex items-center justify-between">
+ <div class="flex items-center gap-2">
+ <span
+ class="text-xs font-medium uppercase tracking-wider text-control-light"
+ >
+ {{ $t("plan.navigator.specifications") }}
+ </span>
+ <NBadge
+ v-if="specs.length > 10"
+ type="info"
+ :value="specs.length"
+ :max="99"
+ />
+ </div>
+ <NButton
+ v-if="isCreating"
+ type="default"
+ size="tiny"
+ @click="handleAddSpec"
+ >
+ <template #icon>
+ <PlusIcon class="w-4 h-4" />
+ </template>
+ </NButton>
+ </div>
+ </div>
+
+ <!-- Spec List -->
+ <div class="px-2 space-y-1">
+ <div
+ v-for="(spec, index) in specs"
+ :key="spec.id"
+ class="px-3 py-2 rounded-md cursor-pointer group transition-all"
+ :class="[
+ selectedSpec?.id === spec.id
+ ? 'bg-accent bg-opacity-10 shadow-sm'
+ : 'hover:bg-gray-50',
+ ]"
+ @click="handleSelectSpec(spec)"
+ >
+ <div class="flex items-start justify-between gap-2">
+ <div class="flex-1 min-w-0">
+ <div class="flex items-center gap-2">
+ <span
+ class="text-sm font-medium"
+ :class="[
+ selectedSpec?.id === spec.id
+ ? 'text-accent'
+ : 'text-control',
+ ]"
+ >
+ {{
+ $t("plan.navigator.spec-number", { number: index + 1 })
+ }}
+ <span
+ v-if="isSpecEmpty(spec)"
+ class="text-error ml-0.5"
+ :title="$t('plan.navigator.statement-empty')"
+ >
+ *
+ </span>
+ </span>
+ <SpecStatusBadge
+ v-if="getSpecCheckStatus(spec) !== 'STATUS_UNSPECIFIED'"
+ :status="getSpecCheckStatus(spec)"
+ />
+ </div>
+
+ <div
+ class="flex flex-row items-center gap-1 mt-1 text-xs text-control-light"
+ >
+ <div class="truncate">
+ {{ getSpecTypeName(spec) }}
+ </div>
+ <span class="mx-0.5">·</span>
+ <div class="opacity-80">
+ {{ getTargetCountText(spec) }}
+ </div>
+ </div>
+ </div>
+
+ <ChevronRightIcon
+ v-if="selectedSpec?.id === spec.id"
+ class="w-4 h-4 text-accent mt-0.5 flex-shrink-0"
+ />
+ </div>
+ </div>
+ </div>
+
+ <div
+ v-if="specs.length === 0"
+ class="text-sm text-control-light text-center py-8 px-4"
+ >
+ {{ $t("plan.navigator.no-specifications") }}
+ </div>
+ </div>
+ </NScrollbar>
+
+ <!-- Add Spec Drawer -->
+ <AddSpecDrawer
+ v-model:show="showAddSpecDrawer"
+ @created="handleSpecCreated"
+ />
+ </div>
+</template>
+
+<script setup lang="ts">
+import {
+ LayoutDashboardIcon,
+ ChevronRightIcon,
+ PlusIcon,
+} from "lucide-vue-next";
+import { NButton, NScrollbar, NBadge } from "naive-ui";
+import { computed, ref } from "vue";
+import { useI18n } from "vue-i18n";
+import { useRouter, useRoute } from "vue-router";
+import {
+ Plan_ChangeDatabaseConfig_Type,
+ type Plan_Spec,
+} from "@/types/proto/v1/plan_service";
+import { usePlanContext } from "../logic/context";
+import { targetsForSpec } from "../logic/plan";
+import AddSpecDrawer from "./AddSpecDrawer.vue";
+import SpecStatusBadge from "./SpecStatusBadge.vue";
+import { useSpecsValidation } from "./common/validateSpec";
+
+const router = useRouter();
+const route = useRoute();
+const { t } = useI18n();
+const { plan, selectedSpec, isCreating, events } = usePlanContext();
+
+const specs = computed(() => plan.value.specs);
+const showAddSpecDrawer = ref(false);
+
+// Use the validation hook for all specs
+const { isSpecEmpty } = useSpecsValidation(specs.value);
+
+const handleSelectOverview = () => {
+ // Clear spec selection to show overview
+ router.replace({
+ query: {
+ ...route.query,
+ spec: undefined,
+ target: undefined,
+ },
+ hash: route.hash,
+ });
+};
+
+const handleSelectSpec = (spec: Plan_Spec) => {
+ events.emit("select-spec", { spec });
+};
+
+const handleAddSpec = () => {
+ showAddSpecDrawer.value = true;
+};
+
+const handleSpecCreated = (spec: Plan_Spec) => {
+ // Add the new spec to the plan
+ if (!plan.value?.specs) {
+ plan.value.specs = [];
+ }
+ plan.value.specs.push(spec);
+
+ // Select the newly created spec
+ events.emit("select-spec", { spec });
+};
+
+const getSpecCheckStatus = (spec: Plan_Spec) => {
+ // Get aggregated check status for the spec
+ const checkRuns = plan.value?.planCheckRunList || [];
+ const targets = targetsForSpec(spec);
+ const sheet = getSheetFromSpec(spec);
+
+ if (!sheet || targets.length === 0) {
+ return "STATUS_UNSPECIFIED";
+ }
+
+ const relevantCheckRuns = checkRuns.filter((check) => {
+ return targets.includes(check.target) && check.sheet === sheet;
+ });
+
+ if (relevantCheckRuns.length === 0) {
+ return "STATUS_UNSPECIFIED";
+ }
+
+ // Find worst status
+ let hasError = false;
+ let hasWarning = false;
+
+ for (const checkRun of relevantCheckRuns) {
+ for (const result of checkRun.results) {
+ if (result.status === "ERROR") {
+ hasError = true;
+ } else if (result.status === "WARNING") {
+ hasWarning = true;
+ }
+ }
+ }
+
+ if (hasError) return "ERROR";
+ if (hasWarning) return "WARNING";
+ return "SUCCESS";
+};
+
+const getSheetFromSpec = (spec: Plan_Spec): string | undefined => {
+ if (spec.changeDatabaseConfig) {
+ return spec.changeDatabaseConfig.sheet;
+ } else if (spec.exportDataConfig) {
+ return spec.exportDataConfig.sheet;
+ }
+ return undefined;
+};
+
+const getSpecTypeName = (spec: Plan_Spec): string => {
+ if (spec.createDatabaseConfig) {
+ return t("plan.spec.type.create-database");
+ } else if (spec.changeDatabaseConfig) {
+ const changeType = spec.changeDatabaseConfig.type;
+ switch (changeType) {
+ case Plan_ChangeDatabaseConfig_Type.MIGRATE:
+ return t("plan.spec.type.schema-change");
+ case Plan_ChangeDatabaseConfig_Type.DATA:
+ return t("plan.spec.type.data-change");
+ case Plan_ChangeDatabaseConfig_Type.MIGRATE_GHOST:
+ return t("plan.spec.type.ghost-migration");
+ default:
+ return t("plan.spec.type.database-change");
+ }
+ } else if (spec.exportDataConfig) {
+ return t("plan.spec.type.export-data");
+ }
+ return t("plan.spec.type.unknown");
+};
+
+const getTargetCountText = (spec: Plan_Spec): string => {
+ const targets = targetsForSpec(spec);
+ if (targets.length === 0) return t("plan.targets.no-targets");
+ return targets.length === 1
+ ? t("plan.targets.one-target")
+ : t("plan.targets.multiple-targets", { count: targets.length });
+};
+</script>
diff --git a/frontend/src/components/Plan/components/Overview.vue b/frontend/src/components/Plan/components/Overview.vue
new file mode 100644
index 0000000000..32259f295c
--- /dev/null
+++ b/frontend/src/components/Plan/components/Overview.vue
@@ -0,0 +1,288 @@
+<template>
+ <div class="w-full p-4 overflow-y-auto mt-4">
+ <div class="max-w-4xl mx-auto space-y-4">
+ <!-- Plan Header -->
+ <div>
+ <h1 class="text-2xl font-semibold mb-2">
+ {{ $t("plan.overview.title") }}
+ </h1>
+ <p class="text-control-light">
+ {{ $t("plan.overview.description") }}
+ </p>
+ </div>
+
+ <!-- Statistics Cards -->
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
+ <div class="bg-white rounded border px-3 py-2">
+ <div class="flex items-center justify-between">
+ <div>
+ <p class="text-sm text-control-light">
+ {{ $t("plan.overview.total-specs") }}
+ </p>
+ <p class="text-2xl font-semibold mt-1">
+ {{ statistics.totalSpecs }}
+ </p>
+ </div>
+ <LayersIcon class="w-8 h-8 text-control-light" stroke-width="1" />
+ </div>
+ </div>
+
+ <div class="bg-white rounded border px-3 py-2">
+ <div class="flex items-center justify-between">
+ <div>
+ <p class="text-sm text-control-light">
+ {{ $t("plan.overview.total-targets") }}
+ </p>
+ <p class="text-2xl font-semibold mt-1">
+ {{ statistics.totalTargets }}
+ </p>
+ </div>
+ <DatabaseIcon class="w-8 h-8 text-control-light" stroke-width="1" />
+ </div>
+ </div>
+
+ <div class="bg-white rounded border px-3 py-2">
+ <div class="flex items-center justify-between">
+ <div>
+ <p class="text-sm text-control-light">
+ {{ $t("plan.overview.check-status") }}
+ </p>
+ <div class="flex items-center gap-3 mt-1">
+ <div
+ v-if="statistics.checkStatus.error > 0"
+ class="flex items-center gap-1"
+ >
+ <XCircleIcon class="w-5 h-5 text-error" />
+ <span class="text-lg font-semibold text-error">{{
+ statistics.checkStatus.error
+ }}</span>
+ </div>
+ <div
+ v-if="statistics.checkStatus.warning > 0"
+ class="flex items-center gap-1"
+ >
+ <AlertCircleIcon class="w-5 h-5 text-warning" />
+ <span class="text-lg font-semibold text-warning">{{
+ statistics.checkStatus.warning
+ }}</span>
+ </div>
+ <div
+ v-if="statistics.checkStatus.success > 0"
+ class="flex items-center gap-1"
+ >
+ <CheckCircleIcon class="w-5 h-5 text-success" />
+ <span class="text-lg font-semibold text-success">{{
+ statistics.checkStatus.success
+ }}</span>
+ </div>
+ <span
+ v-if="statistics.checkStatus.total === 0"
+ class="text-lg text-control"
+ >
+ {{ $t("plan.overview.no-checks") }}
+ </span>
+ </div>
+ </div>
+ <ActivityIcon class="w-8 h-8 text-control-light" stroke-width="1" />
+ </div>
+ </div>
+ </div>
+
+ <!-- Affected Resources -->
+ <div v-if="affectedResources.length > 0">
+ <h2 class="text-lg font-semibold mb-3">
+ {{ $t("plan.overview.affected-resources") }}
+ </h2>
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">
+ <div
+ v-for="resource in affectedResources"
+ :key="resource.name"
+ class="flex items-start gap-3 p-3 rounded border"
+ >
+ <!-- Icon -->
+ <InstanceV1EngineIcon
+ v-if="resource.type === 'instance' && resource.instance"
+ :instance="resource.instance"
+ :tooltip="false"
+ size="medium"
+ class="mt-0.5"
+ />
+ <FolderIcon
+ v-else-if="resource.type === 'databaseGroup'"
+ class="w-5 h-5 text-control mt-0.5"
+ />
+
+ <!-- Content -->
+ <div class="flex-1 min-w-0">
+ <div class="flex items-center gap-2">
+ <!-- Instance info -->
+ <template v-if="resource.type === 'instance'">
+ <span
+ v-if="resource.instance?.environmentEntity"
+ class="text-sm text-gray-600"
+ >
+ ({{ resource.instance.environmentEntity.title }})
+ </span>
+ <span class="font-medium truncate">
+ {{
+ resource.instance
+ ? instanceV1Name(resource.instance)
+ : resource.name
+ }}
+ </span>
+ <span class="text-sm text-control-light">
+ {{
+ resource.databases.length === 1
+ ? t("plan.targets.one-database")
+ : t("plan.targets.multiple-databases", {
+ count: resource.databases.length,
+ })
+ }}
+ </span>
+ </template>
+
+ <!-- Database Group info -->
+ <template v-else-if="resource.type === 'databaseGroup'">
+ <span class="font-medium truncate">
+ {{ resource.databaseGroup?.title || resource.name }}
+ </span>
+ <span
+ class="text-xs px-1.5 py-0.5 rounded bg-blue-100 text-blue-600"
+ >
+ {{ t("plan.targets.database-group") }}
+ </span>
+ </template>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <DescriptionSection />
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import {
+ LayersIcon,
+ DatabaseIcon,
+ ActivityIcon,
+ CheckCircleIcon,
+ AlertCircleIcon,
+ XCircleIcon,
+ FolderIcon,
+} from "lucide-vue-next";
+import { computed, watch } from "vue";
+import { useI18n } from "vue-i18n";
+import { InstanceV1EngineIcon } from "@/components/v2/Model/Instance";
+import { useInstanceV1Store, useDBGroupStore } from "@/store";
+import { PlanCheckRun_Result_Status } from "@/types/proto/v1/plan_service";
+import { instanceV1Name, extractDatabaseResourceName } from "@/utils";
+import { usePlanContext } from "../logic/context";
+import { targetsForSpec } from "../logic/plan";
+import DescriptionSection from "./DescriptionSection";
+
+const { t } = useI18n();
+const { plan } = usePlanContext();
+const instanceStore = useInstanceV1Store();
+const dbGroupStore = useDBGroupStore();
+
+// Calculate statistics
+const statistics = computed(() => {
+ let totalTargets = 0;
+ const checkStatus = {
+ total: 0,
+ success:
+ plan.value.planCheckRunStatusCount[PlanCheckRun_Result_Status.SUCCESS] ||
+ 0,
+ warning:
+ plan.value.planCheckRunStatusCount[PlanCheckRun_Result_Status.WARNING] ||
+ 0,
+ error:
+ plan.value.planCheckRunStatusCount[PlanCheckRun_Result_Status.ERROR] || 0,
+ };
+ checkStatus.total =
+ checkStatus.success + checkStatus.warning + checkStatus.error || 0;
+ for (const spec of plan.value.specs) {
+ totalTargets += targetsForSpec(spec).length;
+ }
+ return {
+ totalSpecs: plan.value.specs.length,
+ totalTargets,
+ checkStatus,
+ };
+});
+
+// Get affected resources
+const affectedResources = computed(() => {
+ const specs = plan.value?.specs || [];
+ const resourceList: Array<{
+ type: "instance" | "databaseGroup";
+ name: string;
+ instance?: any;
+ databaseGroup?: any;
+ databases: string[];
+ }> = [];
+
+ const instanceMap = new Map<string, Set<string>>();
+ const dbGroupSet = new Set<string>();
+
+ for (const spec of specs) {
+ const targets = targetsForSpec(spec);
+ for (const target of targets) {
+ // Check if it's a database group
+ if (target.includes("/databaseGroups/")) {
+ dbGroupSet.add(target);
+ } else {
+ // Parse instance/database format
+ const { instance, databaseName } = extractDatabaseResourceName(target);
+ if (instance && databaseName) {
+ if (!instanceMap.has(instance)) {
+ instanceMap.set(instance, new Set());
+ }
+ instanceMap.get(instance)!.add(databaseName);
+ }
+ }
+ }
+ }
+
+ // Add instances to resource list
+ for (const [instanceName, databases] of instanceMap.entries()) {
+ const instance = instanceStore.getInstanceByName(instanceName);
+ resourceList.push({
+ type: "instance",
+ name: instanceName,
+ instance: instance,
+ databases: Array.from(databases),
+ });
+ }
+
+ // Add database groups to resource list
+ for (const dbGroupName of dbGroupSet) {
+ const dbGroup = dbGroupStore.getDBGroupByName(dbGroupName);
+ resourceList.push({
+ type: "databaseGroup",
+ name: dbGroupName,
+ databaseGroup: dbGroup,
+ databases: dbGroup?.matchedDatabases.map((db) => db.name) || [],
+ });
+ }
+
+ return resourceList;
+});
+
+watch(
+ () => affectedResources.value,
+ () => {
+ for (const resource of affectedResources.value) {
+ if (resource.type === "instance") {
+ instanceStore.getOrFetchInstanceByName(resource.name);
+ } else if (resource.type === "databaseGroup") {
+ dbGroupStore.getOrFetchDBGroupByName(resource.name);
+ }
+ }
+ },
+ { immediate: true }
+);
+</script>
diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
index 4f4025e361..de2b00f38a 100644
--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
@@ -18,29 +18,22 @@ import {
usePlanContext,
} from "@/components/Plan/logic";
import PlanCheckRunBar from "@/components/PlanCheckRun/PlanCheckRunBar.vue";
-import {
- useCurrentUserV1,
- extractUserId,
- useCurrentProjectV1,
- useDatabaseV1Store,
-} from "@/store";
-import { EMPTY_ID } from "@/types";
+import { useCurrentUserV1, extractUserId, useCurrentProjectV1 } from "@/store";
+import { unknownDatabase } from "@/types";
import { hasProjectPermissionV2 } from "@/utils";
const currentUser = useCurrentUserV1();
const { project } = useCurrentProjectV1();
-const { plan, selectedSpec, selectedTarget } = usePlanContext();
+const { plan, selectedSpec } = usePlanContext();
const show = computed(() => {
- if (selectedSpec.value.id === String(EMPTY_ID)) {
+ if (!selectedSpec.value) {
return false;
}
return planSpecHasPlanChecks(selectedSpec.value);
});
-const database = computed(() =>
- useDatabaseV1Store().getDatabaseByName(selectedTarget.value)
-);
+const database = computed(() => unknownDatabase());
const allowRunChecks = computed(() => {
// Allowing below users to run plan checks
diff --git a/frontend/src/components/Plan/components/PlanCheckSection/SpecBasedPlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/SpecBasedPlanCheckSection.vue
new file mode 100644
index 0000000000..381d98d837
--- /dev/null
+++ b/frontend/src/components/Plan/components/PlanCheckSection/SpecBasedPlanCheckSection.vue
@@ -0,0 +1,475 @@
+<template>
+ <div v-if="show" class="px-4 py-3 flex flex-col gap-y-1 overflow-hidden">
+ <div class="flex items-center justify-between gap-2">
+ <div class="flex items-center gap-1">
+ <h3 class="text-base font-medium">Checks</h3>
+ <span class="text-control-light">({{ totalCheckRuns }})</span>
+ </div>
+
+ <div class="flex items-center gap-2">
+ <!-- Status Summary -->
+ <div class="flex items-center gap-2 text-sm">
+ <button
+ v-if="summary.error > 0"
+ class="flex items-center gap-1 hover:opacity-80"
+ @click="openDrawer('ERROR')"
+ >
+ <XCircleIcon class="w-4 h-4 text-error" />
+ <span class="text-error font-medium">{{ summary.error }}</span>
+ </button>
+ <button
+ v-if="summary.warning > 0"
+ class="flex items-center gap-1 hover:opacity-80"
+ @click="openDrawer('WARNING')"
+ >
+ <AlertCircleIcon class="w-4 h-4 text-warning" />
+ <span class="text-warning font-medium">{{ summary.warning }}</span>
+ </button>
+ <button
+ v-if="summary.success > 0"
+ class="flex items-center gap-1 hover:opacity-80"
+ @click="openDrawer('SUCCESS')"
+ >
+ <CheckCircleIcon class="w-4 h-4 text-success" />
+ <span class="text-success font-medium">{{ summary.success }}</span>
+ </button>
+ </div>
+
+ <!-- Run Checks Button -->
+ <NButton
+ v-if="allowRunChecks"
+ size="small"
+ :loading="isRunningChecks"
+ @click="runChecks"
+ >
+ <template #icon>
+ <PlayIcon class="w-4 h-4" />
+ </template>
+ Run Checks
+ </NButton>
+ </div>
+ </div>
+
+ <div class="flex-1 overflow-y-auto">
+ <!-- Loading State -->
+ <div v-if="isLoading" class="flex items-center justify-center py-8">
+ <BBSpin />
+ </div>
+
+ <!-- Check Results -->
+ <div v-else-if="checkRunsForSpec.length > 0" class="flex flex-wrap gap-2">
+ <!-- Group by Check Type -->
+ <div
+ v-for="(typeGroup, checkType) in groupedByType"
+ :key="checkType"
+ class="inline-flex items-center gap-2"
+ @click="selectedCheckType = checkType"
+ >
+ <component
+ :is="getCheckTypeIcon(checkType)"
+ class="w-4 h-4 opacity-80"
+ />
+ <span class="text-sm">{{ getCheckTypeLabel(checkType) }}</span>
+
+ <!-- Status indicators -->
+ <div class="flex items-center gap-2">
+ <div
+ v-if="typeGroup.summary.error > 0"
+ class="flex items-center gap-1"
+ >
+ <XCircleIcon class="w-3.5 h-3.5 text-error" />
+ <span class="text-sm text-error">{{
+ typeGroup.summary.error
+ }}</span>
+ </div>
+ <div
+ v-if="typeGroup.summary.warning > 0"
+ class="flex items-center gap-1"
+ >
+ <AlertCircleIcon class="w-3.5 h-3.5 text-warning" />
+ <span class="text-sm text-warning">{{
+ typeGroup.summary.warning
+ }}</span>
+ </div>
+ <div
+ v-if="typeGroup.summary.success > 0"
+ class="flex items-center gap-1"
+ >
+ <CheckCircleIcon class="w-3.5 h-3.5 text-success" />
+ <span class="text-sm text-success">{{
+ typeGroup.summary.success
+ }}</span>
+ </div>
+ </div>
+ <NDivider vertical />
+ </div>
+ </div>
+
+ <!-- Empty State -->
+ <div v-else class="flex flex-col">
+ <div class="text-control-light">
+ <div class="flex flex-row justify-start items-center gap-2">
+ <CheckCircleIcon class="w-5 h-5 opacity-40" />
+ <span>No check results available</span>
+ </div>
+ <p v-if="allowRunChecks" class="text-sm mt-1">
+ Click "Run Checks" to validate this specification
+ </p>
+ </div>
+ </div>
+ </div>
+
+ <!-- Status Drawer -->
+ <Drawer v-model:show="drawerVisible">
+ <DrawerContent
+ :title="drawerTitle"
+ class="w-[40rem] max-w-[100vw] relative"
+ >
+ <div class="w-full h-full flex flex-col">
+ <!-- Drawer Header -->
+ <div class="flex items-center justify-between px-4 py-3 border-b">
+ <div class="flex items-center gap-2">
+ <component
+ :is="getStatusIcon(selectedStatus)"
+ class="w-5 h-5"
+ :class="getStatusColor(selectedStatus)"
+ />
+ <h3 class="text-lg font-medium">{{ drawerTitle }}</h3>
+ </div>
+ </div>
+
+ <!-- Drawer Content -->
+ <div class="flex-1 overflow-y-auto px-4 py-3">
+ <div v-if="drawerCheckRuns.length > 0" class="space-y-4">
+ <!-- Group by Check Type -->
+ <div
+ v-for="[checkType, checkRuns] in drawerCheckRunsByType"
+ :key="checkType"
+ class="space-y-2"
+ >
+ <div class="flex items-center gap-2 mb-3">
+ <component
+ :is="getCheckTypeIcon(checkType)"
+ class="w-4 h-4"
+ />
+ <span class="font-medium">{{
+ getCheckTypeLabel(checkType)
+ }}</span>
+ <span class="text-control-light"
+ >({{ checkRuns.length }})</span
+ >
+ </div>
+
+ <div class="space-y-3 pl-6">
+ <div
+ v-for="checkRun in checkRuns"
+ :key="checkRun.name"
+ class="space-y-2"
+ >
+ <div class="text-sm font-medium text-control">
+ {{ formatTarget(checkRun.target) }}
+ </div>
+ <div
+ v-for="(result, idx) in getResultsByStatus(
+ checkRun,
+ selectedStatus
+ )"
+ :key="idx"
+ class="pl-4 py-1"
+ >
+ <div
+ class="text-sm"
+ :class="getStatusColor(selectedStatus)"
+ >
+ {{ result.title }}
+ </div>
+ <div
+ v-if="result.content"
+ class="text-xs text-control-light mt-0.5"
+ >
+ {{ result.content }}
+ </div>
+ <div
+ v-if="
+ result.sqlReviewReport &&
+ result.sqlReviewReport.line > 0
+ "
+ class="text-xs text-control-lighter mt-0.5"
+ >
+ Line {{ result.sqlReviewReport.line }}, Column
+ {{ result.sqlReviewReport.column }}
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div v-else class="text-center py-8 text-control-light">
+ No {{ selectedStatus.toLowerCase() }} results
+ </div>
+ </div>
+ </div>
+ </DrawerContent>
+ </Drawer>
+ </div>
+</template>
+
+<script setup lang="ts">
+import {
+ CheckCircleIcon,
+ AlertCircleIcon,
+ XCircleIcon,
+ PlayIcon,
+ FileCodeIcon,
+ DatabaseIcon,
+ ShieldIcon,
+} from "lucide-vue-next";
+import { NButton, NDivider } from "naive-ui";
+import { computed, ref } from "vue";
+import { BBSpin } from "@/bbkit";
+import Drawer from "@/components/v2/Container/Drawer.vue";
+import DrawerContent from "@/components/v2/Container/DrawerContent.vue";
+import { planServiceClient } from "@/grpcweb";
+import {
+ useCurrentUserV1,
+ useCurrentProjectV1,
+ pushNotification,
+ extractUserId,
+} from "@/store";
+import {
+ PlanCheckRun_Result_Status,
+ type PlanCheckRun,
+} from "@/types/proto/v1/plan_service";
+import { hasProjectPermissionV2, extractDatabaseResourceName } from "@/utils";
+import { planCheckRunListForSpec, planSpecHasPlanChecks } from "../../logic";
+import { usePlanContext } from "../../logic/context";
+
+const currentUser = useCurrentUserV1();
+const { project } = useCurrentProjectV1();
+const { plan, selectedSpec } = usePlanContext();
+
+const isLoading = ref(false);
+const isRunningChecks = ref(false);
+const drawerVisible = ref(false);
+const selectedStatus = ref<"ERROR" | "WARNING" | "SUCCESS">("ERROR");
+const selectedCheckType = ref<string>("");
+
+const show = computed(() => {
+ if (!selectedSpec.value) {
+ return false;
+ }
+ return planSpecHasPlanChecks(selectedSpec.value);
+});
+
+const checkRunsForSpec = computed(() => {
+ if (!selectedSpec.value) return [];
+ return planCheckRunListForSpec(plan.value, selectedSpec.value);
+});
+
+const totalCheckRuns = computed(() => checkRunsForSpec.value.length);
+
+const summary = computed(() => {
+ const result = { success: 0, warning: 0, error: 0 };
+
+ for (const checkRun of checkRunsForSpec.value) {
+ const status = getCheckRunStatus(checkRun);
+ if (status === "ERROR") {
+ result.error++;
+ } else if (status === "WARNING") {
+ result.warning++;
+ } else if (status === "SUCCESS") {
+ result.success++;
+ }
+ }
+
+ return result;
+});
+
+const groupedByType = computed(() => {
+ const groups: Record<
+ string,
+ {
+ summary: { success: number; warning: number; error: number };
+ checkRuns: PlanCheckRun[];
+ }
+ > = {};
+
+ for (const checkRun of checkRunsForSpec.value) {
+ const type = checkRun.type;
+ if (!groups[type]) {
+ groups[type] = {
+ summary: { success: 0, warning: 0, error: 0 },
+ checkRuns: [],
+ };
+ }
+
+ groups[type].checkRuns.push(checkRun);
+
+ const status = getCheckRunStatus(checkRun);
+ if (status === PlanCheckRun_Result_Status.ERROR) {
+ groups[type].summary.error++;
+ } else if (status === PlanCheckRun_Result_Status.WARNING) {
+ groups[type].summary.warning++;
+ } else {
+ groups[type].summary.success++;
+ }
+ }
+
+ return groups;
+});
+
+const drawerTitle = computed(() => {
+ if (selectedStatus.value === "ERROR") return "Error Details";
+ if (selectedStatus.value === "WARNING") return "Warning Details";
+ return "Success Details";
+});
+
+const drawerCheckRuns = computed(() => {
+ const result: PlanCheckRun[] = [];
+
+ for (const checkRun of checkRunsForSpec.value) {
+ const status = getCheckRunStatus(checkRun);
+ if (
+ (selectedStatus.value === "ERROR" &&
+ status === PlanCheckRun_Result_Status.ERROR) ||
+ (selectedStatus.value === "WARNING" &&
+ status === PlanCheckRun_Result_Status.WARNING) ||
+ (selectedStatus.value === "SUCCESS" &&
+ status === PlanCheckRun_Result_Status.SUCCESS)
+ ) {
+ result.push(checkRun);
+ }
+ }
+
+ return result;
+});
+
+const drawerCheckRunsByType = computed(() => {
+ const groups = new Map<string, PlanCheckRun[]>();
+
+ for (const checkRun of drawerCheckRuns.value) {
+ const type = checkRun.type;
+ if (!groups.has(type)) {
+ groups.set(type, []);
+ }
+ groups.get(type)!.push(checkRun);
+ }
+
+ return groups;
+});
+
+const allowRunChecks = computed(() => {
+ const me = currentUser.value;
+ if (extractUserId(plan.value.creator) === me.email) {
+ return true;
+ }
+
+ return hasProjectPermissionV2(project.value, "bb.planCheckRuns.run");
+});
+
+const getCheckRunStatus = (
+ checkRun: PlanCheckRun
+): PlanCheckRun_Result_Status => {
+ let hasError = false;
+ let hasWarning = false;
+
+ for (const result of checkRun.results) {
+ if (result.status === "ERROR") {
+ hasError = true;
+ } else if (result.status === "WARNING") {
+ hasWarning = true;
+ }
+ }
+
+ if (hasError) return PlanCheckRun_Result_Status.ERROR;
+ if (hasWarning) return PlanCheckRun_Result_Status.WARNING;
+ return PlanCheckRun_Result_Status.SUCCESS;
+};
+
+const getCheckTypeIcon = (type: string) => {
+ switch (type) {
+ case "DATABASE_STATEMENT_ADVISE":
+ case "DATABASE_STATEMENT_SUMMARY_REPORT":
+ return FileCodeIcon;
+ case "DATABASE_CONNECT":
+ return DatabaseIcon;
+ case "DATABASE_GHOST_SYNC":
+ return ShieldIcon;
+ default:
+ return FileCodeIcon;
+ }
+};
+
+const getCheckTypeLabel = (type: string) => {
+ switch (type) {
+ case "DATABASE_STATEMENT_ADVISE":
+ return "Statement Validation";
+ case "DATABASE_STATEMENT_SUMMARY_REPORT":
+ return "Statement Summary";
+ case "DATABASE_CONNECT":
+ return "Database Connection";
+ case "DATABASE_GHOST_SYNC":
+ return "Ghost Sync Check";
+ default:
+ return type;
+ }
+};
+
+const formatTarget = (target: string): string => {
+ const { instanceName, databaseName } = extractDatabaseResourceName(target);
+ if (instanceName && databaseName) {
+ return `${databaseName} (${instanceName})`;
+ }
+ return target;
+};
+
+const runChecks = async () => {
+ if (!plan.value.name || !selectedSpec.value) return;
+
+ isRunningChecks.value = true;
+ try {
+ await planServiceClient.runPlanChecks({ name: plan.value.name });
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: "Plan checks started",
+ });
+ } catch (error: any) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: "Failed to run plan checks",
+ description: error.message,
+ });
+ } finally {
+ isRunningChecks.value = false;
+ }
+};
+
+const openDrawer = (status: "ERROR" | "WARNING" | "SUCCESS") => {
+ selectedStatus.value = status;
+ drawerVisible.value = true;
+};
+
+const getStatusIcon = (status: string) => {
+ if (status === "ERROR") return XCircleIcon;
+ if (status === "WARNING") return AlertCircleIcon;
+ return CheckCircleIcon;
+};
+
+const getStatusColor = (status: string) => {
+ if (status === "ERROR") return "text-error";
+ if (status === "WARNING") return "text-warning";
+ return "text-success";
+};
+
+const getResultsByStatus = (checkRun: PlanCheckRun, status: string) => {
+ return checkRun.results.filter(
+ (result) =>
+ result.status ===
+ PlanCheckRun_Result_Status[
+ status as keyof typeof PlanCheckRun_Result_Status
+ ]
+ );
+};
+</script>
diff --git a/frontend/src/components/Plan/components/Sidebar/Sidebar.vue b/frontend/src/components/Plan/components/Sidebar/Sidebar.vue
deleted file mode 100644
index 61b50b388b..0000000000
--- a/frontend/src/components/Plan/components/Sidebar/Sidebar.vue
+++ /dev/null
@@ -1,74 +0,0 @@
-<template>
- <div v-if="shouldShow" class="flex flex-col gap-y-3 py-2 px-3">
- <NTooltip :showArrow="false">
- <template #trigger>
- <p class="textinfolabel -mb-1">
- {{ $t("plan.options.self") }}
- <span class="opacity-80">
- ({{
- targetsForSpec(selectedSpec).length === flattenSpecCount
- ? $t("plan.options.applies-to-all-tasks")
- : $t("plan.options.applies-to-some-tasks", {
- count: targetsForSpec(selectedSpec).length,
- total: flattenSpecCount,
- })
- }})
- </span>
- </p>
- </template>
- {{ $t("plan.options.split-into-multiple-issues-tip") }}
- </NTooltip>
- <GhostSection v-if="shouldShowGhostSection" />
- <PreBackupSection v-if="shouldShowPreBackupSection" />
- </div>
-</template>
-
-<script lang="ts" setup>
-import { NTooltip } from "naive-ui";
-import { computed } from "vue";
-import { useCurrentProjectV1 } from "@/store";
-import { targetsForSpec, usePlanContext } from "../../logic";
-import GhostSection from "./GhostSection";
-import { provideGhostSettingContext } from "./GhostSection/context";
-import PreBackupSection from "./PreBackupSection";
-import { providePreBackupSettingContext } from "./PreBackupSection/context";
-
-const { project } = useCurrentProjectV1();
-const { isCreating, plan, selectedSpec, events } = usePlanContext();
-
-const flattenSpecCount = computed(() =>
- plan.value.specs.reduce((acc, spec) => acc + targetsForSpec(spec).length, 0)
-);
-
-const { shouldShow: shouldShowGhostSection, events: ghostEvents } =
- provideGhostSettingContext({
- project,
- plan: plan,
- selectedSpec,
- isCreating,
- });
-
-const { shouldShow: shouldShowPreBackupSection, events: preBackupEvents } =
- providePreBackupSettingContext({
- project,
- plan: plan,
- selectedSpec,
- isCreating,
- });
-
-const shouldShow = computed(() => {
- return shouldShowGhostSection.value || shouldShowPreBackupSection.value;
-});
-
-preBackupEvents.on("update", () => {
- events.emit("status-changed", {
- eager: true,
- });
-});
-
-ghostEvents.on("update", () => {
- events.emit("status-changed", {
- eager: true,
- });
-});
-</script>
diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue
new file mode 100644
index 0000000000..f10c8cb01e
--- /dev/null
+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue
@@ -0,0 +1,34 @@
+<template>
+ <div class="flex-1 flex flex-col hide-scrollbar divide-y overflow-x-hidden">
+ <SQLCheckSection v-if="isCreating" />
+ <SpecBasedPlanCheckSection v-else />
+ <TargetListSection />
+ <div>
+ <StatementSection />
+ <Configuration />
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import type { Ref } from "vue";
+import { useCurrentProjectV1 } from "@/store";
+import type { Plan_Spec } from "@/types/proto/v1/plan_service";
+import { usePlanContext } from "../../logic/context";
+import Configuration from "../Configuration";
+import SpecBasedPlanCheckSection from "../PlanCheckSection/SpecBasedPlanCheckSection.vue";
+import SQLCheckSection, {
+ providePlanSQLCheckContext,
+} from "../SQLCheckSection";
+import StatementSection from "../StatementSection";
+import TargetListSection from "./TargetListSection.vue";
+
+const { project } = useCurrentProjectV1();
+const { isCreating, plan, selectedSpec } = usePlanContext();
+
+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.vue
new file mode 100644
index 0000000000..7fb0e0bae2
--- /dev/null
+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
@@ -0,0 +1,284 @@
+<template>
+ <div class="px-4 py-3 flex flex-col gap-y-2">
+ <div class="flex items-center justify-between gap-2">
+ <div class="flex items-center gap-1">
+ <h3 class="text-base font-medium">{{ $t("plan.targets.title") }}</h3>
+ <span class="text-control-light">({{ targets.length }})</span>
+ </div>
+ <!-- TODO(claude): allow to update targets when no rollout is created by plan -->
+ <NButton
+ v-if="allowEdit"
+ size="small"
+ @click="showTargetsSelector = true"
+ >
+ <template #icon>
+ <EditIcon class="w-4 h-4" />
+ </template>
+ {{ $t("common.edit") }}
+ </NButton>
+ </div>
+
+ <div class="flex-1 overflow-y-auto">
+ <div v-if="isLoading" class="flex items-center justify-center py-8">
+ <BBSpin />
+ </div>
+ <div v-else-if="targets.length > 0" class="flex flex-wrap gap-2">
+ <NTooltip
+ v-for="(item, index) in tableData"
+ :key="index"
+ placement="top"
+ >
+ <template #trigger>
+ <div
+ class="inline-flex items-center gap-x-1.5 px-3 py-1.5 border rounded-lg transition-all cursor-default max-w-[20rem]"
+ >
+ <component
+ :is="item.icon"
+ class="w-4 h-4 text-control-light flex-shrink-0"
+ />
+ <div class="flex items-center gap-x-1 min-w-0">
+ <NEllipsis :line-clamp="1" class="text-sm">
+ <span class="font-medium">{{ item.name }}</span>
+ <span
+ v-if="item.type === 'database' && item.instance"
+ class="text-control-light"
+ >
+ <span class="mx-1">·</span>{{ item.instance }}
+ </span>
+ </NEllipsis>
+ </div>
+ <div
+ class="text-xs px-2 py-0.5 rounded-md bg-control-bg text-control-light flex-shrink-0"
+ >
+ {{ getTypeLabel(item.type) }}
+ </div>
+ </div>
+ </template>
+
+ <!-- Tooltip Content -->
+ <div class="max-w-sm space-y-1">
+ <div class="font-semibold">{{ item.name }}</div>
+ <div class="text-sm space-y-0.5">
+ <div
+ v-if="item.type !== 'instance' && item.instance"
+ class="flex items-center gap-1"
+ >
+ <ServerIcon class="w-3 h-3" />
+ <span>{{ item.instance }}</span>
+ </div>
+ <div v-if="item.environment">
+ {{
+ $t("plan.targets.environment", {
+ environment: item.environment,
+ })
+ }}
+ </div>
+ <div v-if="item.description" class="pt-1 text-control-light">
+ {{ item.description }}
+ </div>
+ </div>
+ </div>
+ </NTooltip>
+ </div>
+ <div v-else class="text-center text-control-light py-8">
+ {{ $t("plan.targets.no-targets-found") }}
+ </div>
+ </div>
+
+ <TargetsSelectorDrawer
+ v-if="project"
+ v-model:show="showTargetsSelector"
+ :current-targets="targets"
+ @confirm="handleUpdateTargets"
+ />
+ </div>
+</template>
+
+<script setup lang="ts">
+import {
+ ServerIcon,
+ DatabaseIcon,
+ FolderIcon,
+ EditIcon,
+} from "lucide-vue-next";
+import { NEllipsis, NTooltip, NButton } from "naive-ui";
+import { computed, ref, watchEffect } from "vue";
+import { useI18n } from "vue-i18n";
+import { BBSpin } from "@/bbkit";
+import {
+ useInstanceV1Store,
+ useDatabaseV1Store,
+ useDBGroupStore,
+ useProjectV1Store,
+} from "@/store";
+import {
+ extractInstanceResourceName,
+ instanceV1Name,
+ extractDatabaseResourceName,
+ extractDatabaseGroupName,
+} from "@/utils";
+import { usePlanContext } from "../../logic/context";
+import { targetsForSpec } from "../../logic/plan";
+import TargetsSelectorDrawer from "./TargetsSelectorDrawer.vue";
+
+interface TargetRow {
+ target: string;
+ type: "instance" | "database" | "databaseGroup";
+ icon: any;
+ name: string;
+ instance?: string;
+ environment?: string;
+ description?: string;
+}
+
+const { t } = useI18n();
+const { plan, selectedSpec, isCreating } = usePlanContext();
+const instanceStore = useInstanceV1Store();
+const databaseStore = useDatabaseV1Store();
+const dbGroupStore = useDBGroupStore();
+const projectStore = useProjectV1Store();
+
+const isLoading = ref(false);
+const showTargetsSelector = ref(false);
+
+const targets = computed(() => {
+ if (!selectedSpec.value) return [];
+ return targetsForSpec(selectedSpec.value);
+});
+
+const isCreateDatabaseSpec = computed(() => {
+ return !!selectedSpec.value?.createDatabaseConfig;
+});
+
+const project = computed(() => {
+ if (!plan.value?.project) return undefined;
+ return projectStore.getProjectByName(plan.value.project);
+});
+
+// Only allow editing in creation mode or if the plan is editable
+const allowEdit = computed(() => {
+ return isCreating.value && selectedSpec.value;
+});
+
+// Prepare data - fetch resources when targets change
+watchEffect(async () => {
+ isLoading.value = true;
+ try {
+ if (!selectedSpec.value) return;
+
+ const targetList = targets.value;
+ if (targetList.length === 0) return;
+
+ // Prepare promises for fetching resources
+ const fetchPromises: Promise<any>[] = [];
+
+ for (const target of targetList) {
+ // For create database spec, target is instance
+ if (isCreateDatabaseSpec.value) {
+ const instanceResourceName = extractInstanceResourceName(target);
+ fetchPromises.push(
+ instanceStore.getOrFetchInstanceByName(instanceResourceName)
+ );
+ }
+ // For database group targets
+ else if (target.includes("/databaseGroups/")) {
+ fetchPromises.push(dbGroupStore.getOrFetchDBGroupByName(target));
+ }
+ // For regular database targets
+ else {
+ fetchPromises.push(databaseStore.getOrFetchDatabaseByName(target));
+ }
+ }
+
+ // Fetch all resources in parallel
+ await Promise.allSettled(fetchPromises);
+ } finally {
+ isLoading.value = false;
+ }
+});
+
+const tableData = computed((): TargetRow[] => {
+ if (!selectedSpec.value) return [];
+
+ return targets.value.map((target): TargetRow => {
+ // For create database spec, target is instance
+ if (isCreateDatabaseSpec.value) {
+ const instanceResourceName = extractInstanceResourceName(target);
+ const instance = instanceStore.getInstanceByName(instanceResourceName);
+
+ return {
+ target,
+ type: "instance",
+ icon: ServerIcon,
+ name: instance ? instanceV1Name(instance) : instanceResourceName,
+ environment: instance?.environmentEntity?.title || "Unknown",
+ description: instance?.title || "",
+ };
+ }
+
+ // For database group targets
+ if (target.includes("/databaseGroups/")) {
+ const groupName = extractDatabaseGroupName(target);
+ const dbGroup = dbGroupStore.getDBGroupByName(target);
+
+ return {
+ target,
+ type: "databaseGroup",
+ icon: FolderIcon,
+ name: dbGroup?.title || groupName,
+ };
+ }
+
+ // For regular database targets
+ const database = databaseStore.getDatabaseByName(target);
+
+ if (!database) {
+ // Fallback when database is not found
+ const { instance: instanceId, databaseName } =
+ extractDatabaseResourceName(target);
+ if (instanceId && databaseName) {
+ return {
+ target,
+ type: "database",
+ icon: DatabaseIcon,
+ name: databaseName,
+ instance: instanceId,
+ description: t("plan.targets.database-not-found"),
+ };
+ }
+ }
+
+ const instance = database?.instanceResource;
+
+ return {
+ target,
+ type: "database",
+ icon: DatabaseIcon,
+ name: database?.databaseName || target,
+ instance: instance ? instanceV1Name(instance) : "",
+ environment: database?.effectiveEnvironmentEntity?.title || "",
+ };
+ });
+});
+
+const getTypeLabel = (type: TargetRow["type"]) => {
+ const typeLabels = {
+ instance: t("plan.targets.type.instance"),
+ database: t("plan.targets.type.database"),
+ databaseGroup: t("plan.targets.type.database-group"),
+ };
+ return typeLabels[type];
+};
+
+const handleUpdateTargets = (targets: string[]) => {
+ if (!selectedSpec.value) return;
+
+ // Update the targets in the spec.
+ const config =
+ selectedSpec.value.changeDatabaseConfig ||
+ selectedSpec.value.exportDataConfig;
+ if (config) {
+ config.targets = targets;
+ }
+};
+</script>
diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetsSelectorDrawer.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetsSelectorDrawer.vue
new file mode 100644
index 0000000000..b1edebd037
--- /dev/null
+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetsSelectorDrawer.vue
@@ -0,0 +1,108 @@
+<template>
+ <Drawer
+ v-model:show="show"
+ :mask-closable="true"
+ placement="right"
+ class="!w-[100vw] sm:!w-[80vw]"
+ >
+ <DrawerContent :title="$t('plan.select-targets')" closable>
+ <div class="flex flex-col gap-y-4">
+ <div class="flex-1 overflow-hidden">
+ <DatabaseAndGroupSelector
+ :project="project"
+ :value="databaseSelectState"
+ @update:value="handleUpdateSelection"
+ />
+ </div>
+ </div>
+ <template #footer>
+ <div class="flex items-center justify-end gap-x-3">
+ <NButton @click="show = false">
+ {{ $t("common.cancel") }}
+ </NButton>
+ <NButton
+ type="primary"
+ :disabled="!hasSelection"
+ @click="handleConfirm"
+ >
+ {{ $t("common.confirm") }}
+ </NButton>
+ </div>
+ </template>
+ </DrawerContent>
+ </Drawer>
+</template>
+
+<script setup lang="ts">
+import { NButton } from "naive-ui";
+import { computed, reactive, watch } from "vue";
+import DatabaseAndGroupSelector from "@/components/DatabaseAndGroupSelector";
+import type { DatabaseSelectState } from "@/components/DatabaseAndGroupSelector";
+import { Drawer, DrawerContent } from "@/components/v2";
+import { useCurrentProjectV1 } from "@/store";
+
+const props = defineProps<{
+ currentTargets: string[];
+}>();
+
+const emit = defineEmits<{
+ (event: "confirm", targets: string[]): void;
+}>();
+
+const { project } = useCurrentProjectV1();
+const show = defineModel<boolean>("show", { default: false });
+
+const databaseSelectState = reactive<DatabaseSelectState>({
+ changeSource: "DATABASE",
+ selectedDatabaseNameList: [],
+});
+
+const hasSelection = computed(() => {
+ if (databaseSelectState.changeSource === "DATABASE") {
+ return databaseSelectState.selectedDatabaseNameList.length > 0;
+ } else {
+ return !!databaseSelectState.selectedDatabaseGroup;
+ }
+});
+
+// Initialize selection when drawer opens
+watch(show, (newVal) => {
+ if (newVal && props.currentTargets.length > 0) {
+ // Check if current targets are database group or databases
+ const firstTarget = props.currentTargets[0];
+ if (firstTarget.includes("/databaseGroups/")) {
+ // It's a database group
+ databaseSelectState.changeSource = "GROUP";
+ databaseSelectState.selectedDatabaseGroup = firstTarget;
+ databaseSelectState.selectedDatabaseNameList = [];
+ } else {
+ // It's database(s)
+ databaseSelectState.changeSource = "DATABASE";
+ databaseSelectState.selectedDatabaseNameList = [...props.currentTargets];
+ databaseSelectState.selectedDatabaseGroup = undefined;
+ }
+ } else if (newVal) {
+ // Reset to default state if no current targets
+ databaseSelectState.changeSource = "DATABASE";
+ databaseSelectState.selectedDatabaseNameList = [];
+ databaseSelectState.selectedDatabaseGroup = undefined;
+ }
+});
+
+const handleUpdateSelection = (newState: DatabaseSelectState) => {
+ Object.assign(databaseSelectState, newState);
+};
+
+const handleConfirm = () => {
+ const targets: string[] = [];
+
+ if (databaseSelectState.changeSource === "DATABASE") {
+ targets.push(...databaseSelectState.selectedDatabaseNameList);
+ } else if (databaseSelectState.selectedDatabaseGroup) {
+ targets.push(databaseSelectState.selectedDatabaseGroup);
+ }
+
+ emit("confirm", targets);
+ show.value = false;
+};
+</script>
diff --git a/frontend/src/components/Plan/components/SpecDetailView/index.ts b/frontend/src/components/Plan/components/SpecDetailView/index.ts
new file mode 100644
index 0000000000..a467e7f4b7
--- /dev/null
+++ b/frontend/src/components/Plan/components/SpecDetailView/index.ts
@@ -0,0 +1 @@
+export { default as SpecDetailView } from "./SpecDetailView.vue";
diff --git a/frontend/src/components/Plan/components/SpecListSection/CurrentSpecSection.vue b/frontend/src/components/Plan/components/SpecListSection/CurrentSpecSection.vue
deleted file mode 100644
index 65ba90f36d..0000000000
--- a/frontend/src/components/Plan/components/SpecListSection/CurrentSpecSection.vue
+++ /dev/null
@@ -1,126 +0,0 @@
-<template>
- <div class="px-4 py-2 flex flex-row items-center gap-x-4">
- <span class="textlabel">{{ $t("task.current-task") }}</span>
- <div class="flex items-center flex-wrap gap-1">
- <InstanceV1Name
- v-if="!isCreatingDatabaseSpec"
- :instance="coreDatabaseInfo.instanceResource"
- :plain="true"
- :link="link"
- >
- <template
- v-if="
- database &&
- formatEnvironmentName(instanceEnvironment.id) !==
- database.effectiveEnvironment
- "
- #prefix
- >
- <EnvironmentV1Name
- :environment="instanceEnvironment"
- :plain="true"
- :show-icon="false"
- :link="link"
- text-class="text-control-light"
- />
- </template>
- </InstanceV1Name>
- <span v-else>
- <!-- For creating database issues, we will only show the resource id of target instance. -->
- {{
- extractInstanceResourceName(
- selectedSpec.createDatabaseConfig?.target || ""
- )
- }}
- </span>
-
- <ChevronRightIcon class="text-control-light" :size="16" />
-
- <div class="flex items-center gap-x-1">
- <DatabaseIcon class="text-control-light" :size="16" />
-
- <template v-if="!isCreatingDatabaseSpec">
- <EnvironmentV1Name
- :environment="coreDatabaseInfo.effectiveEnvironmentEntity"
- :plain="true"
- :show-icon="false"
- :link="link"
- text-class="text-control-light"
- />
-
- <DatabaseV1Name
- :database="coreDatabaseInfo"
- :plain="true"
- :link="link"
- />
- </template>
- <span v-else>
- {{ coreDatabaseInfo.databaseName }}
- </span>
- </div>
- </div>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { computedAsync } from "@vueuse/core";
-import { ChevronRightIcon, DatabaseIcon } from "lucide-vue-next";
-import { computed } from "vue";
-import {
- DatabaseV1Name,
- EnvironmentV1Name,
- InstanceV1Name,
-} from "@/components/v2";
-import { useDatabaseV1Store, useEnvironmentV1Store } from "@/store";
-import {
- formatEnvironmentName,
- isValidDatabaseName,
- unknownEnvironment,
-} from "@/types";
-import { extractInstanceResourceName, isNullOrUndefined } from "@/utils";
-import { usePlanContext } from "../../logic";
-
-withDefaults(
- defineProps<{
- link?: boolean;
- }>(),
- {
- link: true,
- }
-);
-
-const { selectedSpec, selectedTarget } = usePlanContext();
-
-const coreDatabaseInfo = computed(() => {
- return useDatabaseV1Store().getDatabaseByName(selectedTarget.value);
-});
-
-const isCreatingDatabaseSpec = computed(
- () => !isNullOrUndefined(selectedSpec.value.createDatabaseConfig)
-);
-
-const database = computedAsync(async () => {
- const maybeExistedDatabase = coreDatabaseInfo.value;
- if (isValidDatabaseName(maybeExistedDatabase.name)) {
- return maybeExistedDatabase;
- }
- if (isCreatingDatabaseSpec.value) {
- const name = coreDatabaseInfo.value.name;
- const maybeCreatedDatabase =
- await useDatabaseV1Store().getOrFetchDatabaseByName(name);
- if (isValidDatabaseName(maybeCreatedDatabase.name)) {
- return maybeCreatedDatabase;
- }
- }
- return undefined;
-}, undefined);
-
-const instanceEnvironment = computed(() => {
- if (!database.value) return unknownEnvironment();
- return (
- useEnvironmentV1Store().getEnvironmentByName(
- database.value.instanceResource.environment
- ) ?? unknownEnvironment()
- );
-});
-</script>
diff --git a/frontend/src/components/Plan/components/SpecListSection/SpecCard.vue b/frontend/src/components/Plan/components/SpecListSection/SpecCard.vue
deleted file mode 100644
index 3551df96a0..0000000000
--- a/frontend/src/components/Plan/components/SpecListSection/SpecCard.vue
+++ /dev/null
@@ -1,164 +0,0 @@
-<template>
- <div
- v-for="target in targetsForSpec(spec)"
- :key="`${spec.id}-${target}`"
- class="px-3 py-2 w-full cursor-pointer border rounded lg:flex-1 flex justify-start items-center overflow-hidden gap-x-1"
- :class="[getTargetClass(target)]"
- @click="onClickSpec(spec, target)"
- >
- <NTooltip
- v-if="
- [
- PlanCheckRun_Result_Status.WARNING,
- PlanCheckRun_Result_Status.ERROR,
- ].includes(planCheckStatusForTarget(target))
- "
- trigger="hover"
- placement="top"
- >
- <template #trigger>
- <AlertCircleIcon
- class="w-4 h-4 shrink-0"
- :class="[
- planCheckStatusForTarget(target) ===
- PlanCheckRun_Result_Status.ERROR
- ? 'text-error hover:text-error-hover'
- : 'text-warning hover:text-warning-hover',
- ]"
- />
- </template>
- <span>{{
- $t(
- "custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"
- )
- }}</span>
- </NTooltip>
- <div
- v-if="isDatabaseChangeSpec(spec)"
- class="flex items-center gap-1 truncate"
- >
- <InstanceV1Name
- :instance="getDatabaseForTarget(target).instanceResource"
- :link="false"
- class="text-gray-500 text-sm"
- />
- <span class="truncate text-sm">{{
- getDatabaseForTarget(target).databaseName
- }}</span>
- </div>
- <div
- v-else-if="isGroupingChangeSpec(spec) && getRelatedDatabaseGroup(target)"
- class="flex items-center gap-2 truncate"
- >
- <NTooltip>
- <template #trigger>
- <DatabaseGroupIcon class="w-4 h-auto" />
- </template>
- {{ $t("dynamic.resource.database-group") }}
- </NTooltip>
- <span class="truncate text-sm">{{
- getRelatedDatabaseGroup(target)?.title
- }}</span>
- </div>
- <!-- Fallback -->
- <div v-else class="flex items-center gap-2 text-sm">Unknown target</div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { isEqual } from "lodash-es";
-import { AlertCircleIcon } from "lucide-vue-next";
-import { NTooltip } from "naive-ui";
-import DatabaseGroupIcon from "@/components/DatabaseGroupIcon.vue";
-import { mockDatabase } from "@/components/IssueV1/logic/utils";
-import { planCheckRunSummaryForCheckRunList } from "@/components/PlanCheckRun/common";
-import { InstanceV1Name } from "@/components/v2";
-import {
- useCurrentProjectV1,
- useDBGroupStore,
- useDatabaseV1Store,
-} from "@/store";
-import { isValidDatabaseName } from "@/types";
-import {
- PlanCheckRun_Result_Status,
- type Plan_Spec,
-} from "@/types/proto/v1/plan_service";
-import { sheetNameOfSpec } from "@/utils";
-import {
- isDatabaseChangeSpec,
- usePlanContext,
- isGroupingChangeSpec,
- targetsForSpec,
-} from "../../logic";
-
-const props = defineProps<{
- spec: Plan_Spec;
-}>();
-
-const { project } = useCurrentProjectV1();
-const { isCreating, plan, selectedSpec, selectedTarget, events } =
- usePlanContext();
-const dbGroupStore = useDBGroupStore();
-
-const getTargetClass = (target: string) => {
- const classes: string[] = [];
- const isSpecSelected = isEqual(props.spec, selectedSpec.value);
- const isTargetSelected = isSpecSelected && selectedTarget.value === target;
-
- if (isTargetSelected) {
- classes.push("border-accent bg-accent bg-opacity-5 shadow");
- }
-
- const checkStatus = planCheckStatusForTarget(target);
- if (checkStatus === PlanCheckRun_Result_Status.WARNING) {
- classes.push("bg-warning bg-opacity-5");
- if (isTargetSelected) {
- classes.push("border-warning");
- }
- } else if (checkStatus === PlanCheckRun_Result_Status.ERROR) {
- classes.push("bg-error bg-opacity-5");
- if (isTargetSelected) {
- classes.push("border-error");
- }
- }
-
- return classes;
-};
-
-const getDatabaseForTarget = (target: string) => {
- const db = useDatabaseV1Store().getDatabaseByName(target);
- if (!isValidDatabaseName(db.name)) {
- return mockDatabase(project.value, target);
- }
- return db;
-};
-
-const getRelatedDatabaseGroup = (target: string) => {
- if (!isGroupingChangeSpec(props.spec)) {
- return undefined;
- }
- return dbGroupStore.getDBGroupByName(target);
-};
-
-const planCheckStatusForTarget = (
- target: string
-): PlanCheckRun_Result_Status => {
- if (isCreating.value) return PlanCheckRun_Result_Status.STATUS_UNSPECIFIED;
- const planCheckRuns = plan.value.planCheckRunList.filter(
- (run) => run.sheet === sheetNameOfSpec(props.spec) && run.target === target
- );
- const summary = planCheckRunSummaryForCheckRunList(planCheckRuns);
- if (summary.errorCount > 0) {
- return PlanCheckRun_Result_Status.ERROR;
- }
- if (summary.warnCount > 0) {
- return PlanCheckRun_Result_Status.WARNING;
- }
- return PlanCheckRun_Result_Status.SUCCESS;
-};
-
-const onClickSpec = (spec: Plan_Spec, target: string) => {
- events.emit("select-spec", { spec });
- events.emit("select-target", { target });
-};
-</script>
diff --git a/frontend/src/components/Plan/components/SpecListSection/SpecFilter.vue b/frontend/src/components/Plan/components/SpecListSection/SpecFilter.vue
deleted file mode 100644
index 805ddc712d..0000000000
--- a/frontend/src/components/Plan/components/SpecListSection/SpecFilter.vue
+++ /dev/null
@@ -1,85 +0,0 @@
-<template>
- <div class="w-full flex flex-row gap-4">
- <div class="flex items-center justify-between">
- <h3 class="textlabel">
- {{ $t("common.tasks") }}
- <span>({{ specList.length }})</span>
- </h3>
- </div>
- <div class="flex flex-row gap-2 items-center">
- <div
- class="bg-gray-50 pl-2 p-1 flex flex-row items-center rounded-full gap-1"
- >
- <span class="text-sm mr-1 text-gray-600">{{
- $t("issue.sql-check.sql-checks")
- }}</span>
- <template v-for="status in ADVICE_STATUS_FILTERS" :key="status">
- <NTag
- v-if="getSpecCount(status) > 0"
- :disabled="disabled"
- :size="'small'"
- round
- checkable
- :checked="adviceStatusList.includes(status)"
- @update:checked="
- (checked) => {
- emit(
- 'update:adviceStatusList',
- checked
- ? [...adviceStatusList, status]
- : adviceStatusList.filter((s) => s !== status)
- );
- }
- "
- >
- <template #avatar>
- <AdviceStatusIcon :status="status" />
- </template>
- <span class="select-none">{{ getSpecCount(status) }}</span>
- </NTag>
- </template>
- </div>
- </div>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { NTag } from "naive-ui";
-import { computed } from "vue";
-import { Advice_Status } from "@/types/proto/v1/sql_service";
-import { usePlanContext } from "../../logic";
-import AdviceStatusIcon from "../SQLCheckSection/AdviceStatusIcon.vue";
-import { usePlanSQLCheckContext } from "../SQLCheckSection/context";
-import { filterSpec } from "./filter";
-
-defineProps<{
- disabled: boolean;
- adviceStatusList: Advice_Status[];
-}>();
-
-const emit = defineEmits<{
- (event: "update:adviceStatusList", adviceStatusList: Advice_Status[]): void;
-}>();
-
-const ADVICE_STATUS_FILTERS: Advice_Status[] = [
- Advice_Status.UNRECOGNIZED,
- Advice_Status.SUCCESS,
- Advice_Status.WARNING,
- Advice_Status.ERROR,
-];
-
-const planContext = usePlanContext();
-const { resultMap } = usePlanSQLCheckContext();
-
-const { plan } = planContext;
-
-const specList = computed(() => plan.value.specs);
-
-const getSpecCount = (adviceStatus?: Advice_Status) => {
- return specList.value.filter((spec) =>
- filterSpec(planContext, resultMap.value, spec, {
- adviceStatus,
- })
- ).length;
-};
-</script>
diff --git a/frontend/src/components/Plan/components/SpecListSection/SpecListSection.vue b/frontend/src/components/Plan/components/SpecListSection/SpecListSection.vue
deleted file mode 100644
index 41f858bba1..0000000000
--- a/frontend/src/components/Plan/components/SpecListSection/SpecListSection.vue
+++ /dev/null
@@ -1,209 +0,0 @@
-<template>
- <div class="w-relative">
- <div
- v-if="shouldShowSpecFilter"
- class="w-full sticky top-0 z-10 bg-white px-4 pt-2 pb-1"
- >
- <SpecFilter
- :disabled="state.isRequesting"
- v-model:advice-status-list="state.adviceStatusFilters"
- />
- </div>
- <div class="w-full relative">
- <div
- ref="specBar"
- class="spec-list gap-2 px-4 py-2 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 3xl:grid-cols-5 4xl:grid-cols-6 overflow-y-auto"
- :class="{
- 'more-bottom': specBarScrollState.bottom,
- 'more-top': specBarScrollState.top,
- }"
- :style="{
- 'max-height': `${MAX_LIST_HEIGHT}px`,
- }"
- >
- <SpecCard
- v-for="(spec, i) in filteredSpecList.slice(0, state.index)"
- :key="i"
- :spec="spec"
- />
- <div
- v-show="state.isRequesting"
- class="col-span-full flex items-center justify-center py-4"
- >
- <BBSpin />
- </div>
- <div
- v-if="filteredSpecList.length > state.index"
- class="col-span-full flex flex-row items-center justify-end"
- >
- <NButton
- size="small"
- quaternary
- :loading="state.isRequesting"
- @click="loadMore"
- >
- {{ $t("common.load-more") }}
- </NButton>
- </div>
- </div>
- </div>
- </div>
-
- <CurrentSpecSection v-if="shouldShowCurrentSpecView" />
-</template>
-
-<script lang="ts" setup>
-import { useDebounceFn } from "@vueuse/core";
-import { NButton } from "naive-ui";
-import { computed, reactive, ref, watch } from "vue";
-import { BBSpin } from "@/bbkit";
-import { useVerticalScrollState } from "@/composables/useScrollState";
-import { batchGetOrFetchDatabases, useDBGroupStore } from "@/store";
-import { DEBOUNCE_SEARCH_DELAY, isValidDatabaseName } from "@/types";
-import type { Advice_Status } from "@/types/proto/v1/sql_service";
-import { isDev } from "@/utils";
-import {
- isDatabaseChangeSpec,
- isGroupingChangeSpec,
- targetsForSpec,
- usePlanContext,
-} from "../../logic";
-import { usePlanSQLCheckContext } from "../SQLCheckSection/context";
-import CurrentSpecSection from "./CurrentSpecSection.vue";
-import SpecCard from "./SpecCard.vue";
-import SpecFilter from "./SpecFilter.vue";
-import { filterSpec } from "./filter";
-
-interface LocalState {
- // Index is the current number of specs to show.
- index: number;
- adviceStatusFilters: Advice_Status[];
- isRequesting: boolean;
-}
-
-const MAX_LIST_HEIGHT = 256;
-
-// The default number of specs to show per page.
-// This is set to 4 in development mode for easier testing.
-const SPEC_PER_PAGE = isDev() ? 4 : 20;
-
-const planContext = usePlanContext();
-const { resultMap } = usePlanSQLCheckContext();
-const { plan, selectedSpec } = planContext;
-const dbGroupStore = useDBGroupStore();
-const state = reactive<LocalState>({
- index: 0,
- adviceStatusFilters: [],
- isRequesting: false,
-});
-const specBar = ref<HTMLDivElement>();
-const specBarScrollState = useVerticalScrollState(specBar, MAX_LIST_HEIGHT);
-
-const specList = computed(() => plan.value?.specs || []);
-
-const filteredSpecList = computed(() => {
- return specList.value.filter((spec) => {
- if (state.adviceStatusFilters.length > 0) {
- if (
- !state.adviceStatusFilters.some((status) =>
- filterSpec(planContext, resultMap.value, spec, {
- adviceStatus: status,
- })
- )
- ) {
- return false;
- }
- }
- return true;
- });
-});
-
-const shouldShowSpecFilter = computed(() => {
- return (
- specList.value.length > 2 &&
- // Only show the filter when every spec is a database change spec.
- // Excluding database group spec.
- specList.value.every((spec) => isDatabaseChangeSpec(spec))
- );
-});
-
-const shouldShowCurrentSpecView = computed(() => {
- if (state.index === 0) {
- return false;
- }
- // Only show the current spec view when the selected spec is not in the filtered list.
- const visibleSpecs = filteredSpecList.value.slice(0, state.index);
- return !visibleSpecs.some((spec) => spec.id === selectedSpec.value.id);
-});
-
-const loadMore = useDebounceFn(async () => {
- if (state.isRequesting) return;
-
- const isGroupChangingPlan = specList.value.every((spec) =>
- isGroupingChangeSpec(spec)
- );
- if (isGroupChangingPlan) {
- // Fetch all database groups referenced in specs
- const dbGroupNames = new Set<string>();
- for (const spec of specList.value) {
- const targets = targetsForSpec(spec);
- targets.forEach((target) => dbGroupNames.add(target));
- }
-
- await Promise.all(
- Array.from(dbGroupNames).map((name) =>
- dbGroupStore.getOrFetchDBGroupByName(name)
- )
- );
- } else {
- const fromIndex = state.index;
- const toIndex = fromIndex + SPEC_PER_PAGE;
-
- // Collect all database names from all targets in the visible specs
- const databaseNames = new Set<string>();
- filteredSpecList.value.slice(fromIndex, toIndex).forEach((spec) => {
- const targets = targetsForSpec(spec);
- targets.forEach((target) => {
- if (isValidDatabaseName(target)) {
- databaseNames.add(target);
- }
- });
- });
-
- state.isRequesting = true;
- try {
- await batchGetOrFetchDatabases(Array.from(databaseNames));
- } finally {
- state.index = toIndex;
- state.isRequesting = false;
- }
- }
-}, DEBOUNCE_SEARCH_DELAY);
-
-watch(
- () => plan.value.name,
- async () => {
- await loadMore();
- },
- { immediate: true }
-);
-</script>
-
-<style scoped lang="postcss">
-.spec-list::before {
- @apply absolute top-0 h-4 w-full -ml-4 z-10 pointer-events-none transition-shadow;
- content: "";
- box-shadow: none;
-}
-.spec-list::after {
- @apply absolute bottom-0 h-4 w-full -ml-4 z-10 pointer-events-none transition-shadow;
- content: "";
- box-shadow: none;
-}
-.spec-list.more-top::before {
- box-shadow: inset 0 0.3rem 0.25rem -0.25rem rgb(0 0 0 / 10%);
-}
-.spec-list.more-bottom::after {
- box-shadow: inset 0 -0.3rem 0.25rem -0.25rem rgb(0 0 0 / 10%);
-}
-</style>
diff --git a/frontend/src/components/Plan/components/SpecListSection/filter.ts b/frontend/src/components/Plan/components/SpecListSection/filter.ts
deleted file mode 100644
index ece3b1f84c..0000000000
--- a/frontend/src/components/Plan/components/SpecListSection/filter.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import { planCheckRunSummaryForCheckRunList } from "@/components/PlanCheckRun/common";
-import type { Plan_Spec } from "@/types/proto/v1/plan_service";
-import type { CheckReleaseResponse_CheckResult } from "@/types/proto/v1/release_service";
-import { Advice_Status } from "@/types/proto/v1/sql_service";
-import { sheetNameOfSpec } from "@/utils";
-import { type PlanContext, targetsForSpec } from "../../logic";
-
-export const filterSpec = (
- planContext: PlanContext,
- sqlCheckResultMap: Record<string, CheckReleaseResponse_CheckResult>,
- spec: Plan_Spec,
- {
- adviceStatus,
- }: {
- adviceStatus?: Advice_Status;
- }
-): boolean => {
- const { isCreating } = planContext;
- const targets = targetsForSpec(spec);
-
- if (adviceStatus) {
- if (isCreating.value) {
- // Check if any target matches the filter criteria.
- return targets.some((target) => {
- const result = sqlCheckResultMap[target];
- if (adviceStatus === Advice_Status.UNRECOGNIZED) {
- return !Boolean(result);
- }
- if (adviceStatus === Advice_Status.SUCCESS) {
- return result && result.advices.length === 0;
- }
- return (
- result &&
- result.advices.some((advice) => advice.status === adviceStatus)
- );
- });
- } else {
- // Check if any target has the specified advice status.
- return targets.some((target) => {
- const planCheckRuns = planContext.plan.value.planCheckRunList.filter(
- (run) => run.sheet === sheetNameOfSpec(spec) && run.target === target
- );
- const summary = planCheckRunSummaryForCheckRunList(planCheckRuns);
- if (summary.errorCount > 0) {
- return adviceStatus === Advice_Status.ERROR;
- } else if (summary.warnCount > 0) {
- return adviceStatus === Advice_Status.WARNING;
- } else {
- return adviceStatus === Advice_Status.SUCCESS;
- }
- });
- }
- }
-
- return false;
-};
diff --git a/frontend/src/components/Plan/components/SpecListSection/index.ts b/frontend/src/components/Plan/components/SpecListSection/index.ts
deleted file mode 100644
index cc15800de3..0000000000
--- a/frontend/src/components/Plan/components/SpecListSection/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import SpecListSection from "./SpecListSection.vue";
-
-export default SpecListSection;
diff --git a/frontend/src/components/Plan/components/SpecStatusBadge.vue b/frontend/src/components/Plan/components/SpecStatusBadge.vue
new file mode 100644
index 0000000000..2e468ae2b1
--- /dev/null
+++ b/frontend/src/components/Plan/components/SpecStatusBadge.vue
@@ -0,0 +1,60 @@
+<template>
+ <NTag size="small" round :type="tagType">
+ <template #icon>
+ <component :is="statusIcon" class="w-3 h-3" />
+ </template>
+ {{ statusText }}
+ </NTag>
+</template>
+
+<script setup lang="ts">
+import { CheckCircleIcon, AlertCircleIcon, XCircleIcon } from "lucide-vue-next";
+import { NTag } from "naive-ui";
+import { computed } from "vue";
+import { useI18n } from "vue-i18n";
+
+const props = defineProps<{
+ status: "SUCCESS" | "WARNING" | "ERROR" | "STATUS_UNSPECIFIED";
+}>();
+
+const { t } = useI18n();
+
+const statusIcon = computed(() => {
+ switch (props.status) {
+ case "SUCCESS":
+ return CheckCircleIcon;
+ case "WARNING":
+ return AlertCircleIcon;
+ case "ERROR":
+ return XCircleIcon;
+ default:
+ return null;
+ }
+});
+
+const statusText = computed(() => {
+ switch (props.status) {
+ case "SUCCESS":
+ return t("plan.spec.status.pass");
+ case "WARNING":
+ return t("plan.spec.status.warn");
+ case "ERROR":
+ return t("plan.spec.status.error");
+ default:
+ return "";
+ }
+});
+
+const tagType = computed(() => {
+ switch (props.status) {
+ case "SUCCESS":
+ return "success";
+ case "WARNING":
+ return "warning";
+ case "ERROR":
+ return "error";
+ default:
+ return "default";
+ }
+});
+</script>
diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
index 5d9ea626fd..55c2833124 100644
--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
@@ -4,29 +4,25 @@
<div class="flex items-center gap-x-4">
<div class="flex items-center gap-x-1 text-sm font-medium">
<span
- :class="isEmpty(state.statement) ? 'text-red-600' : 'text-control'"
+ class="text-base font-medium"
+ :class="isEmpty(state.statement) ? 'text-red-600' : ''"
>
{{ statementTitle }}
</span>
<span v-if="isCreating" class="text-red-600">*</span>
<NButton
v-if="!isCreating && !hasFeature('bb.feature.sql-review')"
- size="tiny"
+ size="small"
@click.prevent="state.showFeatureModal = true"
>
🎈{{ $t("sql-review.unlock-full-feature") }}
</NButton>
</div>
</div>
-
<div class="flex items-center justify-end gap-x-2">
<template v-if="isCreating">
- <FormatOnSaveCheckbox
- v-model:value="formatOnSave"
- :language="language"
- />
<SQLUploadButton
- size="tiny"
+ size="small"
:loading="state.isUploadingFile"
@update:sql="handleUpdateStatement"
>
@@ -42,7 +38,7 @@
<template #trigger>
<NButton
v-if="!isSheetOversize"
- size="tiny"
+ size="small"
tag="div"
:disabled="denyEditStatementReasons.length > 0"
@click.prevent="beginEdit"
@@ -52,7 +48,7 @@
<!-- for oversized sheets, only allow to upload and overwrite the sheet -->
<SQLUploadButton
v-else
- size="tiny"
+ size="small"
:loading="state.isUploadingFile"
@update:sql="handleUpdateStatementAndOverwrite"
>
@@ -66,12 +62,8 @@
</template>
</template>
<template v-else>
- <FormatOnSaveCheckbox
- v-model:value="formatOnSave"
- :language="language"
- />
<SQLUploadButton
- size="tiny"
+ size="small"
:loading="state.isUploadingFile"
@update:sql="handleUpdateStatement"
>
@@ -79,7 +71,7 @@
</SQLUploadButton>
<NButton
v-if="state.isEditing"
- size="tiny"
+ size="small"
:disabled="!allowSaveSQL"
@click.prevent="saveEdit"
>
@@ -87,7 +79,7 @@
</NButton>
<NButton
v-if="state.isEditing"
- size="tiny"
+ size="small"
quaternary
@click.prevent="cancelEdit"
>
@@ -196,7 +188,7 @@ import { cloneDeep, head, isEmpty } from "lodash-es";
import { ExpandIcon } from "lucide-vue-next";
import { NButton, NTooltip, useDialog } from "naive-ui";
import { v1 as uuidv1 } from "uuid";
-import { computed, h, reactive, ref, watch } from "vue";
+import { computed, reactive, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { BBAttention, BBModal } from "@/bbkit";
import { FeatureModal } from "@/components/FeatureGuard";
@@ -207,7 +199,6 @@ import {
createEmptyLocalSheet,
databaseEngineForSpec,
databaseForSpec,
- isGroupingChangeSpec,
} from "@/components/Plan/logic";
import { usePlanContext } from "@/components/Plan/logic";
import DownloadSheetButton from "@/components/Sheet/DownloadSheetButton.vue";
@@ -220,19 +211,17 @@ import {
useSheetV1Store,
} from "@/store";
import type { SQLDialect } from "@/types";
-import { EMPTY_ID, dialectOfEngineV1 } from "@/types";
-import type { Plan_Spec } from "@/types/proto/v1/plan_service";
+import { dialectOfEngineV1 } from "@/types";
import { Sheet } from "@/types/proto/v1/sheet_service";
import {
- defer,
getSheetStatement,
setSheetStatement,
useInstanceV1EditorLanguage,
getStatementSize,
} from "@/utils";
import { usePlanSQLCheckContext } from "../../SQLCheckSection/context";
+import useSelectedSpec from "../../common/useSelectedSpec";
import { useSQLAdviceMarkers } from "../useSQLAdviceMarkers";
-import FormatOnSaveCheckbox from "./FormatOnSaveCheckbox.vue";
import type { EditState } from "./useTempEditState";
import { useTempEditState } from "./useTempEditState";
@@ -246,7 +235,8 @@ const { t } = useI18n();
const dialog = useDialog();
const context = usePlanContext();
const { project } = useCurrentProjectV1();
-const { isCreating, plan, selectedSpec, formatOnSave, events } = context;
+const { isCreating, plan, events } = context;
+const selectedSpec = useSelectedSpec();
const { resultMap } = usePlanSQLCheckContext();
const editorContainerElRef = ref<HTMLElement>();
const monacoEditorRef = ref<InstanceType<typeof MonacoEditor>>();
@@ -371,80 +361,6 @@ const cancelEdit = () => {
state.isEditing = false;
};
-const chooseUpdateStatementTarget = () => {
- type Target = "CANCELED" | "SPEC" | "ALL";
- const d = defer<{ target: Target; specs: Plan_Spec[] }>();
-
- const targets: Record<Target, Plan_Spec[]> = {
- CANCELED: [],
- SPEC: [selectedSpec.value],
- ALL: plan.value?.specs || [],
- };
-
- // If there is only one spec, we don't need to ask the user to choose.
- if (targets.ALL.length === 1) {
- d.resolve({ target: "SPEC", specs: targets.SPEC });
- return d.promise;
- }
-
- const $d = dialog.create({
- title: t("issue.update-statement.self", { type: statementTitle.value }),
- content: t("issue.update-statement.apply-current-change-to"),
- type: "info",
- autoFocus: false,
- closable: false,
- maskClosable: false,
- closeOnEsc: false,
- showIcon: false,
- action: () => {
- const finish = (target: Target) => {
- d.resolve({ target, specs: targets[target] });
- $d.destroy();
- };
-
- const CANCEL = h(
- NButton,
- { size: "small", onClick: () => finish("CANCELED") },
- {
- default: () => t("common.cancel"),
- }
- );
- const SPEC = h(
- NButton,
- { size: "small", onClick: () => finish("SPEC") },
- {
- default: () => t("issue.update-statement.target.selected-task"),
- }
- );
- const ALL = h(
- NButton,
- { size: "small", onClick: () => finish("ALL") },
- {
- default: () => t("issue.update-statement.target.all-tasks"),
- }
- );
-
- const buttons = [CANCEL];
- // For no grouping change spec, we can choose to update the current spec.
- if (!isGroupingChangeSpec(selectedSpec.value)) {
- buttons.push(SPEC);
- }
- buttons.push(ALL);
-
- return h(
- "div",
- { class: "flex items-center justify-end gap-x-2" },
- buttons
- );
- },
- onClose() {
- d.resolve({ target: "CANCELED", specs: [] });
- },
- });
-
- return d.promise;
-};
-
const showOverwriteConfirmDialog = () => {
return new Promise((resolve, reject) => {
// Show a confirm dialog before replacing if the editing statement is not empty.
@@ -499,29 +415,8 @@ const updateStatement = async (statement: string) => {
if (!planPatch) {
return;
}
-
- const specsIdList: string[] = [];
- const { target, specs } = await chooseUpdateStatementTarget();
- if (target === "CANCELED" || specs.length === 0) {
- cancelEdit();
- return;
- }
-
- specs.forEach((spec) => {
- if (spec) {
- specsIdList.push(spec.id);
- }
- });
-
- const distinctSpecsIds = new Set(
- specsIdList.filter((id) => id && id !== String(EMPTY_ID))
- );
- if (distinctSpecsIds.size === 0) {
- return;
- }
-
- const specsToPatch = planPatch.specs.filter((spec) =>
- distinctSpecsIds.has(spec.id)
+ const specsToPatch = planPatch.specs.filter(
+ (spec) => spec.id === selectedSpec.value.id
);
const sheet = Sheet.fromPartial({
...createEmptyLocalSheet(),
@@ -537,8 +432,12 @@ const updateStatement = async (statement: string) => {
for (const spec of specsToPatch) {
if (spec.changeDatabaseConfig) {
spec.changeDatabaseConfig.sheet = createdSheet.name;
+ } else if (spec.exportDataConfig) {
+ spec.exportDataConfig.sheet = createdSheet.name;
} else {
- console.error("Unexpected spec type", spec);
+ throw new Error(
+ `Unsupported spec type for plan update ${JSON.stringify(spec)}`
+ );
}
}
diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/FormatOnSaveCheckbox.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/FormatOnSaveCheckbox.vue
deleted file mode 100644
index 93b53a4160..0000000000
--- a/frontend/src/components/Plan/components/StatementSection/EditorView/FormatOnSaveCheckbox.vue
+++ /dev/null
@@ -1,27 +0,0 @@
-<template>
- <NCheckbox
- v-if="allowFormatOnSave"
- :checked="value"
- size="small"
- @update:checked="$emit('update:value', $event)"
- >
- {{ $t("issue.format-on-save") }}
- </NCheckbox>
-</template>
-
-<script setup lang="ts">
-import { NCheckbox } from "naive-ui";
-import { computed } from "vue";
-import type { Language } from "@/types";
-
-const props = defineProps<{
- language: Language;
- value: boolean;
-}>();
-
-defineEmits<{
- (event: "update:value", on: boolean): void;
-}>();
-
-const allowFormatOnSave = computed(() => props.language === "sql");
-</script>
diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/useTempEditState.ts b/frontend/src/components/Plan/components/StatementSection/EditorView/useTempEditState.ts
index d3dada6879..fceb5d9c9f 100644
--- a/frontend/src/components/Plan/components/StatementSection/EditorView/useTempEditState.ts
+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/useTempEditState.ts
@@ -1,6 +1,7 @@
import { computed, nextTick, ref, watch } from "vue";
import { UNKNOWN_ID } from "@/types";
import { usePlanContext } from "../../../logic";
+import useSelectedSpec from "../../common/useSelectedSpec";
import { useSpecSheet } from "../useSpecSheet";
export type EditState = {
@@ -9,7 +10,8 @@ export type EditState = {
};
export const useTempEditState = (state: EditState) => {
- const { isCreating, selectedSpec } = usePlanContext();
+ const { isCreating } = usePlanContext();
+ const selectedSpec = useSelectedSpec();
const { sheet, sheetName, sheetReady, sheetStatement } = useSpecSheet(
selectedSpec.value
);
diff --git a/frontend/src/components/Plan/components/StatementSection/StatementSection.vue b/frontend/src/components/Plan/components/StatementSection/StatementSection.vue
index 25b6e1f7d1..4d4103884a 100644
--- a/frontend/src/components/Plan/components/StatementSection/StatementSection.vue
+++ b/frontend/src/components/Plan/components/StatementSection/StatementSection.vue
@@ -7,7 +7,6 @@
<script setup lang="ts">
import { computed } from "vue";
import { ref } from "vue";
-import { EMPTY_ID } from "@/types";
import { usePlanContext } from "../..";
import EditorView from "./EditorView";
@@ -15,7 +14,7 @@ const { selectedSpec } = usePlanContext();
const editorViewRef = ref<InstanceType<typeof EditorView>>();
const viewMode = computed((): "NONE" | "EDITOR" => {
- if (selectedSpec.value.id !== String(EMPTY_ID)) {
+ if (selectedSpec.value) {
return "EDITOR";
}
return "NONE";
diff --git a/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts b/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts
index 318205f7f2..04fca6980b 100644
--- a/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts
+++ b/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts
@@ -2,6 +2,7 @@ import { maxBy } from "lodash-es";
import { computed, type Ref } from "vue";
import type { AdviceOption } from "@/components/MonacoEditor";
import {
+ Plan_Spec,
PlanCheckRun,
PlanCheckRun_Result_Status,
PlanCheckRun_Type,
@@ -37,7 +38,7 @@ export const useSQLAdviceMarkers = (
const { plan, selectedSpec } = context;
const planCheckRunList = planCheckRunListForSpec(
plan.value,
- selectedSpec.value
+ selectedSpec.value as Plan_Spec
);
const types: PlanCheckRun_Type[] = [
PlanCheckRun_Type.DATABASE_STATEMENT_ADVISE,
diff --git a/frontend/src/components/Plan/components/common/index.ts b/frontend/src/components/Plan/components/common/index.ts
index 54c6860e1a..67a174ea46 100644
--- a/frontend/src/components/Plan/components/common/index.ts
+++ b/frontend/src/components/Plan/components/common/index.ts
@@ -1,3 +1,4 @@
import ErrorList from "./ErrorList.vue";
export { ErrorList };
+export * from "./validateSpec";
diff --git a/frontend/src/components/Plan/components/common/useSelectedSpec.ts b/frontend/src/components/Plan/components/common/useSelectedSpec.ts
new file mode 100644
index 0000000000..702909d29f
--- /dev/null
+++ b/frontend/src/components/Plan/components/common/useSelectedSpec.ts
@@ -0,0 +1,11 @@
+import type { Ref } from "vue";
+import type { Plan_Spec } from "@/types/proto/v1/plan_service";
+import { usePlanContext } from "../../logic";
+
+const useSelectedSpec = () => {
+ const { selectedSpec } = usePlanContext();
+
+ return selectedSpec as Ref<Plan_Spec>;
+};
+
+export default useSelectedSpec;
diff --git a/frontend/src/components/Plan/components/common/validateSpec.ts b/frontend/src/components/Plan/components/common/validateSpec.ts
new file mode 100644
index 0000000000..2d1bb7507b
--- /dev/null
+++ b/frontend/src/components/Plan/components/common/validateSpec.ts
@@ -0,0 +1,63 @@
+import { ref, watchEffect } from "vue";
+import type { Plan_Spec } from "@/types/proto/v1/plan_service";
+import { useSheetV1Store } from "@/store";
+import { extractSheetUID, getSheetStatement, sheetNameOfSpec } from "@/utils";
+import { getLocalSheetByName } from "@/components/Plan";
+
+// Hook to validate all specs in a plan
+export const useSpecsValidation = (specs: Plan_Spec[]) => {
+ const sheetStore = useSheetV1Store();
+ const validationMap = ref(new Map<string, boolean>());
+
+ const checkSpecStatement = async (spec: Plan_Spec): Promise<boolean> => {
+ // Only changeDatabaseConfig and exportDataConfig specs have statements
+ if (!spec.changeDatabaseConfig && !spec.exportDataConfig) {
+ return false;
+ }
+
+ const sheetName = sheetNameOfSpec(spec);
+ // If there's no sheet reference, it's definitely empty
+ if (!sheetName) {
+ return true;
+ }
+
+ try {
+ // Get sheet content
+ const uid = extractSheetUID(sheetName);
+ const sheet = uid.startsWith("-")
+ ? getLocalSheetByName(sheetName)
+ : await sheetStore.getOrFetchSheetByName(sheetName);
+
+ if (!sheet) {
+ return true; // Consider empty if sheet not found
+ }
+
+ const statement = getSheetStatement(sheet);
+ return !statement || statement.trim() === "";
+ } catch {
+ return false; // If error, don't show as empty
+ }
+ };
+
+ watchEffect(async () => {
+ const newMap = new Map<string, boolean>();
+
+ // Check all specs
+ await Promise.all(
+ specs.map(async (spec) => {
+ const isEmpty = await checkSpecStatement(spec);
+ newMap.set(spec.id, isEmpty);
+ })
+ );
+
+ validationMap.value = newMap;
+ });
+
+ const isSpecEmpty = (spec: Plan_Spec): boolean => {
+ return validationMap.value.get(spec.id) ?? false;
+ };
+
+ return {
+ isSpecEmpty,
+ };
+};
\ No newline at end of file
diff --git a/frontend/src/components/Plan/components/index.ts b/frontend/src/components/Plan/components/index.ts
index c0a362dae9..75e93bddd0 100644
--- a/frontend/src/components/Plan/components/index.ts
+++ b/frontend/src/components/Plan/components/index.ts
@@ -1,13 +1,17 @@
import DescriptionSection from "./DescriptionSection";
import HeaderSection from "./HeaderSection";
+import Navigator from "./Navigator.vue";
+import Overview from "./Overview.vue";
import PlanCheckSection from "./PlanCheckSection";
import SQLCheckSection from "./SQLCheckSection";
-import SpecListSection from "./SpecListSection";
+import { SpecDetailView } from "./SpecDetailView";
import StatementSection from "./StatementSection";
export {
HeaderSection,
- SpecListSection,
+ Navigator,
+ Overview,
+ SpecDetailView,
PlanCheckSection,
SQLCheckSection,
StatementSection,
diff --git a/frontend/src/components/Plan/logic/base.ts b/frontend/src/components/Plan/logic/base.ts
index b619cbaac2..a193a473f1 100644
--- a/frontend/src/components/Plan/logic/base.ts
+++ b/frontend/src/components/Plan/logic/base.ts
@@ -1,29 +1,22 @@
import Emittery from "emittery";
-import { first } from "lodash-es";
-import { useDialog } from "naive-ui";
import { computed } from "vue";
import { useRoute, useRouter } from "vue-router";
import { PROJECT_V1_ROUTE_REVIEW_CENTER_DETAIL } from "@/router/dashboard/projectV1";
-import { useUIStateStore } from "@/store";
import type { Plan_Spec } from "@/types/proto/v1/plan_service";
-import { emptyPlanSpec } from "@/types/v1/issue/plan";
import type { PlanContext, PlanEvents } from "./context";
-import { targetsForSpec } from "./plan";
export const useBasePlanContext = (
context: Pick<PlanContext, "isCreating" | "ready" | "plan">
): Partial<PlanContext> => {
const { plan } = context;
- const uiStateStore = useUIStateStore();
const route = useRoute();
const router = useRouter();
- const dialog = useDialog();
const events: PlanEvents = new Emittery();
const specs = computed(() => plan.value?.specs || []);
- const selectedSpec = computed((): Plan_Spec => {
+ const selectedSpec = computed((): Plan_Spec | undefined => {
// Check if spec is selected from URL.
const specId = route.query.spec as string;
if (specId) {
@@ -34,24 +27,7 @@ export const useBasePlanContext = (
}
// Fallback to first spec.
- return first(specs.value) || emptyPlanSpec();
- });
-
- const selectedTarget = computed((): string => {
- const specTargets = targetsForSpec(selectedSpec.value);
- const target = route.query.target as string;
- if (target) {
- if (specTargets.includes(target)) {
- return target;
- }
- }
- // Fallback to first target.
- return first(specTargets) || "";
- });
-
- const formatOnSave = computed({
- get: () => uiStateStore.editorFormatStatementOnSave,
- set: (value: boolean) => uiStateStore.setEditorFormatStatementOnSave(value),
+ return undefined;
});
events.on("select-spec", ({ spec }) => {
@@ -65,22 +41,8 @@ export const useBasePlanContext = (
});
});
- events.on("select-target", ({ target }) => {
- router.replace({
- name: PROJECT_V1_ROUTE_REVIEW_CENTER_DETAIL,
- query: {
- ...route.query,
- target: target,
- },
- hash: route.hash,
- });
- });
-
return {
events,
selectedSpec,
- selectedTarget,
- formatOnSave,
- dialog,
};
};
diff --git a/frontend/src/components/Plan/logic/context.ts b/frontend/src/components/Plan/logic/context.ts
index 140eacc9cb..517063e608 100644
--- a/frontend/src/components/Plan/logic/context.ts
+++ b/frontend/src/components/Plan/logic/context.ts
@@ -1,5 +1,4 @@
import type Emittery from "emittery";
-import type { useDialog } from "naive-ui";
import { v4 as uuidv4 } from "uuid";
import type { InjectionKey, Ref } from "vue";
import { inject, provide } from "vue";
@@ -19,16 +18,10 @@ export type PlanContext = {
plan: Ref<ComposedPlan>;
// TODO(steven): save related issue/rollout for checking if the plan is changable.
- selectedSpec: Ref<Plan_Spec>;
- selectedTarget: Ref<string>;
- formatOnSave: Ref<boolean>;
+ selectedSpec: Ref<Plan_Spec | undefined>;
// UI events
events: PlanEvents;
-
- // misc
- dialog: ReturnType<typeof useDialog>;
- reInitialize: (overrides?: Record<string, string>) => Promise<void>;
};
const KEY = Symbol(`bb.plan.context.${uuidv4()}`) as InjectionKey<PlanContext>;
diff --git a/frontend/src/components/Plan/logic/initialize/create.ts b/frontend/src/components/Plan/logic/initialize/create.ts
index 6075910bcb..8b15a84a25 100644
--- a/frontend/src/components/Plan/logic/initialize/create.ts
+++ b/frontend/src/components/Plan/logic/initialize/create.ts
@@ -23,7 +23,7 @@ import {
setSheetStatement,
} from "@/utils";
import { sheetNameForSpec, targetsForSpec } from "../plan";
-import { getLocalSheetByName } from "../sheet";
+import { getLocalSheetByName, getNextLocalSheetUID } from "../sheet";
import { extractInitialSQLFromQuery } from "./util";
export type InitialSQL = {
@@ -127,7 +127,7 @@ const buildSpecForTargetsV1 = async (
{ project, template, query }: CreatePlanParams,
sheetUID?: string
) => {
- let sheet = `${project.name}/sheets/${sheetUID ?? nextUID()}`;
+ let sheet = `${project.name}/sheets/${sheetUID ?? getNextLocalSheetUID()}`;
if (query.sheetId) {
const remoteSheet = await useSheetV1Store().getOrFetchSheetByUID(
query.sheetId,
@@ -187,7 +187,7 @@ const buildSpecsViaChangelist = async (
for (const db of databaseNameList) {
for (const change of changes) {
const statement = await generateSQLForChangeToDatabase(change);
- const sheetUID = nextUID();
+ const sheetUID = getNextLocalSheetUID();
const sheetName = `${params.project.name}/sheets/${sheetUID}`;
const sheet = getLocalSheetByName(sheetName);
setSheetStatement(sheet, statement);
diff --git a/frontend/src/components/Plan/logic/initialize/index.ts b/frontend/src/components/Plan/logic/initialize/index.ts
index 653ccdcd44..5be7a7b566 100644
--- a/frontend/src/components/Plan/logic/initialize/index.ts
+++ b/frontend/src/components/Plan/logic/initialize/index.ts
@@ -69,21 +69,7 @@ export function useInitializePlan(
{ immediate: true }
);
- const reInitialize = async (overrides: Record<string, string> = {}) => {
- const url = route.fullPath;
- const query = convertRouterQuery(router.resolve(url).query);
- try {
- const updated = await createPlanSkeleton(route, {
- ...query,
- ...overrides,
- });
- plan.value = updated;
- } catch {
- // Nothing
- }
- };
-
- return { isCreating, plan, isInitializing, reInitialize };
+ return { isCreating, plan, isInitializing };
}
export const convertRouterQuery = (query: LocationQuery) => {
diff --git a/frontend/src/components/Plan/logic/sheet.ts b/frontend/src/components/Plan/logic/sheet.ts
index a868d1ead7..aa91f98bec 100644
--- a/frontend/src/components/Plan/logic/sheet.ts
+++ b/frontend/src/components/Plan/logic/sheet.ts
@@ -1,12 +1,24 @@
import { reactive } from "vue";
import { Sheet } from "@/types/proto/v1/sheet_service";
+const state = {
+ uid: -101,
+};
+
+const nextUID = () => {
+ return String(state.uid--);
+};
+
const sheetsByName = reactive(new Map<string, Sheet>());
export const createEmptyLocalSheet = () => {
return reactive(Sheet.fromPartial({}));
};
+export const getNextLocalSheetUID = () => {
+ return nextUID();
+};
+
export const getLocalSheetByName = (name: string): Sheet => {
const existed = sheetsByName.get(name);
if (existed) {
diff --git a/frontend/src/components/PlanCheckRun/PlanCheckRunBar.vue b/frontend/src/components/PlanCheckRun/PlanCheckRunBar.vue
index 4c20ca8506..b3ac9d08ac 100644
--- a/frontend/src/components/PlanCheckRun/PlanCheckRunBar.vue
+++ b/frontend/src/components/PlanCheckRun/PlanCheckRunBar.vue
@@ -1,7 +1,7 @@
<template>
<div class="w-full flex items-start gap-x-4 flex-wrap">
<div
- class="textlabel h-[26px] inline-flex items-center"
+ class="text-base font-medium inline-flex items-center"
:class="labelClass"
>
{{ $t("task.task-checks") }}
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 104e6e5889..66624874b5 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -995,6 +995,62 @@
}
},
"plan": {
+ "add-spec": "Add Specification",
+ "change-type": "Change Type",
+ "schema-migration": "Schema Migration",
+ "schema-migration-description": "Modify database schema (DDL)",
+ "data-change": "Data Change",
+ "data-change-description": "Modify data (DML)",
+ "select-targets": "Select Targets",
+ "overview": {
+ "title": "Plan Overview",
+ "description": "View and manage all specifications in this plan",
+ "total-specs": "Total Specs",
+ "total-targets": "Total Targets",
+ "check-status": "Check Status",
+ "no-checks": "No checks",
+ "affected-resources": "Affected Resources"
+ },
+ "navigator": {
+ "overview": "Overview",
+ "specifications": "Specifications",
+ "spec-number": "Spec {number}",
+ "no-specifications": "No specifications",
+ "statement-empty": "Statement is empty"
+ },
+ "spec": {
+ "type": {
+ "create-database": "Create Database",
+ "schema-change": "Schema Change",
+ "data-change": "Data Change",
+ "ghost-migration": "Ghost Migration",
+ "database-change": "Database Change",
+ "export-data": "Export Data",
+ "unknown": "Unknown"
+ },
+ "status": {
+ "pass": "Pass",
+ "warn": "Warn",
+ "error": "Error"
+ }
+ },
+ "targets": {
+ "title": "Targets",
+ "no-targets-found": "No targets found",
+ "no-targets": "No targets",
+ "one-target": "1 target",
+ "multiple-targets": "{count} targets",
+ "one-database": "1 database",
+ "multiple-databases": "{count} databases",
+ "database-group": "Database Group",
+ "database-not-found": "Database not found",
+ "environment": "Environment: {environment}",
+ "type": {
+ "instance": "Instance",
+ "database": "Database",
+ "database-group": "Database Group"
+ }
+ },
"options": {
"self": "Options",
"applies-to-all-tasks": "Applies to all tasks",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 4301718325..f2fb6ca12a 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -995,6 +995,62 @@
}
},
"plan": {
+ "add-spec": "Agregar especificación",
+ "change-type": "Cambiar tipo",
+ "schema-migration": "Migración de esquemas",
+ "schema-migration-description": "Modificar el esquema de la base de datos (DDL)",
+ "data-change": "Cambio de datos",
+ "data-change-description": "Modificar datos (DML)",
+ "select-targets": "Seleccionar objetivos",
+ "overview": {
+ "title": "Descripción general del plan",
+ "description": "Ver y administrar todas las especificaciones de este plan",
+ "total-specs": "Especificaciones totales",
+ "total-targets": "Objetivos totales",
+ "check-status": "Verificar estado",
+ "no-checks": "Sin controles",
+ "affected-resources": "Recursos afectados"
+ },
+ "navigator": {
+ "overview": "Descripción general",
+ "specifications": "Presupuesto",
+ "spec-number": "Especificación {number}",
+ "no-specifications": "Sin especificaciones",
+ "statement-empty": "La declaración está vacía"
+ },
+ "spec": {
+ "type": {
+ "create-database": "Crear base de datos",
+ "schema-change": "Cambio de esquema",
+ "data-change": "Cambio de datos",
+ "ghost-migration": "Migración fantasma",
+ "database-change": "Cambio de base de datos",
+ "export-data": "Exportar datos",
+ "unknown": "Desconocido"
+ },
+ "status": {
+ "pass": "Aprobar",
+ "warn": "Advertir",
+ "error": "Error"
+ }
+ },
+ "targets": {
+ "title": "Objetivos",
+ "no-targets-found": "No se encontraron objetivos",
+ "no-targets": "Sin objetivos",
+ "one-target": "1 objetivo",
+ "multiple-targets": "{count} objetivos",
+ "one-database": "1 base de datos",
+ "multiple-databases": "{count} bases de datos",
+ "database-group": "Grupo de bases de datos",
+ "database-not-found": "Base de datos no encontrada",
+ "environment": "Entorno: {environment}",
+ "type": {
+ "instance": "Instancia",
+ "database": "Base de datos",
+ "database-group": "Grupo de bases de datos"
+ }
+ },
"options": {
"self": "Opciones",
"applies-to-all-tasks": "Se aplica a todas las tareas.",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index e128175adb..f50cdf2a1b 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -995,6 +995,62 @@
}
},
"plan": {
+ "add-spec": "仕様を追加",
+ "change-type": "変更タイプ",
+ "schema-migration": "スキーマの移行",
+ "schema-migration-description": "データベーススキーマの変更(DDL)",
+ "data-change": "データの変更",
+ "data-change-description": "データの変更 (DML)",
+ "select-targets": "ターゲットを選択",
+ "overview": {
+ "title": "プランの概要",
+ "description": "このプランのすべての仕様を表示および管理します",
+ "total-specs": "合計スペック",
+ "total-targets": "合計ターゲット",
+ "check-status": "ステータスを確認する",
+ "no-checks": "チェックなし",
+ "affected-resources": "影響を受けるリソース"
+ },
+ "navigator": {
+ "overview": "概要",
+ "specifications": "仕様",
+ "spec-number": "スペック {number}",
+ "no-specifications": "仕様なし",
+ "statement-empty": "ステートメントが空です"
+ },
+ "spec": {
+ "type": {
+ "create-database": "データベースの作成",
+ "schema-change": "スキーマの変更",
+ "data-change": "データの変更",
+ "ghost-migration": "ゴーストマイグレーション",
+ "database-change": "データベースの変更",
+ "export-data": "データのエクスポート",
+ "unknown": "未知"
+ },
+ "status": {
+ "pass": "合格",
+ "warn": "警告する",
+ "error": "エラー"
+ }
+ },
+ "targets": {
+ "title": "ターゲット",
+ "no-targets-found": "ターゲットが見つかりません",
+ "no-targets": "ターゲットなし",
+ "one-target": "1つのターゲット",
+ "multiple-targets": "{count} 個のターゲット",
+ "one-database": "1 つのデータベース",
+ "multiple-databases": "{count} データベース",
+ "database-group": "データベースグループ",
+ "database-not-found": "データベースが見つかりません",
+ "environment": "環境: {environment}",
+ "type": {
+ "instance": "実例",
+ "database": "データベース",
+ "database-group": "データベースグループ"
+ }
+ },
"options": {
"self": "オプション",
"applies-to-all-tasks": "すべてのタスクに適用",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index a59a4e8bce..076b036c01 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -995,6 +995,62 @@
}
},
"plan": {
+ "add-spec": "Thêm thông số kỹ thuật",
+ "change-type": "Thay đổi loại",
+ "schema-migration": "Di chuyển lược đồ",
+ "schema-migration-description": "Sửa đổi lược đồ cơ sở dữ liệu (DDL)",
+ "data-change": "Thay đổi dữ liệu",
+ "data-change-description": "Sửa đổi dữ liệu (DML)",
+ "select-targets": "Chọn mục tiêu",
+ "overview": {
+ "title": "Tổng quan về kế hoạch",
+ "description": "Xem và quản lý tất cả các thông số kỹ thuật trong kế hoạch này",
+ "total-specs": "Tổng số thông số kỹ thuật",
+ "total-targets": "Tổng số mục tiêu",
+ "check-status": "Kiểm tra trạng thái",
+ "no-checks": "Không kiểm tra",
+ "affected-resources": "Tài nguyên bị ảnh hưởng"
+ },
+ "navigator": {
+ "overview": "Tổng quan",
+ "specifications": "Thông số kỹ thuật",
+ "spec-number": "Đặc điểm kỹ thuật {number}",
+ "no-specifications": "Không có thông số kỹ thuật",
+ "statement-empty": "Câu lệnh trống rỗng"
+ },
+ "spec": {
+ "type": {
+ "create-database": "Tạo cơ sở dữ liệu",
+ "schema-change": "Thay đổi sơ đồ",
+ "data-change": "Thay đổi dữ liệu",
+ "ghost-migration": "Di cư của ma",
+ "database-change": "Thay đổi cơ sở dữ liệu",
+ "export-data": "Xuất dữ liệu",
+ "unknown": "Không rõ"
+ },
+ "status": {
+ "pass": "Vượt qua",
+ "warn": "Cảnh báo",
+ "error": "Lỗi"
+ }
+ },
+ "targets": {
+ "title": "Mục tiêu",
+ "no-targets-found": "Không tìm thấy mục tiêu",
+ "no-targets": "Không có mục tiêu",
+ "one-target": "1 mục tiêu",
+ "multiple-targets": "{count} mục tiêu",
+ "one-database": "1 cơ sở dữ liệu",
+ "multiple-databases": "{count} cơ sở dữ liệu",
+ "database-group": "Nhóm cơ sở dữ liệu",
+ "database-not-found": "Không tìm thấy cơ sở dữ liệu",
+ "environment": "Môi trường: {environment}",
+ "type": {
+ "instance": "Ví dụ",
+ "database": "Cơ sở dữ liệu",
+ "database-group": "Nhóm cơ sở dữ liệu"
+ }
+ },
"options": {
"self": "Tùy chọn",
"applies-to-all-tasks": "Áp dụng cho tất cả các nhiệm vụ",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 972387ba13..cbbc34630c 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -995,6 +995,62 @@
}
},
"plan": {
+ "add-spec": "添加变更项",
+ "change-type": "变更类型",
+ "schema-migration": "Schema 变更",
+ "schema-migration-description": "修改数据库 Schema (DDL)",
+ "data-change": "数据变更",
+ "data-change-description": "修改数据(DML)",
+ "select-targets": "选择目标",
+ "overview": {
+ "title": "变更计划概述",
+ "description": "查看和管理此变更计划中的所有变更项",
+ "total-specs": "变更项",
+ "total-targets": "变更目标",
+ "check-status": "检查状态",
+ "no-checks": "没有检查",
+ "affected-resources": "受影响的资源"
+ },
+ "navigator": {
+ "overview": "概述",
+ "specifications": "变更项",
+ "spec-number": "变更项 {number}",
+ "no-specifications": "无变更项",
+ "statement-empty": "变更语句为空"
+ },
+ "spec": {
+ "type": {
+ "create-database": "创建数据库",
+ "schema-change": "Schema 变更",
+ "data-change": "数据变更",
+ "ghost-migration": "在线大表变更",
+ "database-change": "数据库变更",
+ "export-data": "导出数据",
+ "unknown": "未知"
+ },
+ "status": {
+ "pass": "通过",
+ "warn": "警告",
+ "error": "错误"
+ }
+ },
+ "targets": {
+ "title": "目标",
+ "no-targets-found": "未找到目标",
+ "no-targets": "没有目标",
+ "one-target": "1 个目标",
+ "multiple-targets": "{count} 个目标",
+ "one-database": "1 个数据库",
+ "multiple-databases": "{count} 个数据库",
+ "database-group": "数据库组",
+ "database-not-found": "未找到数据库",
+ "environment": "环境:{environment}",
+ "type": {
+ "instance": "实例",
+ "database": "数据库",
+ "database-group": "数据库组"
+ }
+ },
"options": {
"self": "配置项",
"applies-to-all-tasks": "适用于所有任务",
diff --git a/frontend/src/views/project/ProjectPlanDetail.vue b/frontend/src/views/project/ProjectPlanDetail.vue
index f2bf18da3f..6025343709 100644
--- a/frontend/src/views/project/ProjectPlanDetail.vue
+++ b/frontend/src/views/project/ProjectPlanDetail.vue
@@ -10,6 +10,11 @@
</template>
<script lang="ts" setup>
+import { useTitle } from "@vueuse/core";
+import Emittery from "emittery";
+import { NSpin } from "naive-ui";
+import { computed, toRef } from "vue";
+import { useI18n } from "vue-i18n";
import {
providePlanContext,
useBasePlanContext,
@@ -22,11 +27,6 @@ import {
} from "@/components/PlanCheckRun/context";
import { useBodyLayoutContext } from "@/layouts/common";
import { isValidPlanName } from "@/utils";
-import { useTitle } from "@vueuse/core";
-import Emittery from "emittery";
-import { NSpin } from "naive-ui";
-import { computed, toRef } from "vue";
-import { useI18n } from "vue-i18n";
defineOptions({
inheritAttrs: false,
@@ -39,7 +39,7 @@ const props = defineProps<{
const { t } = useI18n();
-const { isCreating, plan, isInitializing, reInitialize } = useInitializePlan(
+const { isCreating, plan, isInitializing } = useInitializePlan(
toRef(props, "planSlug"),
toRef(props, "projectId")
);
@@ -57,7 +57,6 @@ providePlanContext(
isCreating,
plan,
ready,
- reInitialize,
...planBaseContext,
},
true /* root */