Skip to content

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

chore: show specs directly instead of dropdown (#16890)

boojack29c97f596377
diff --git a/frontend/src/components/Plan/components/CurrentSpecSelector.vue b/frontend/src/components/Plan/components/CurrentSpecSelector.vue
deleted file mode 100644
index 4f6a10a002..0000000000
--- a/frontend/src/components/Plan/components/CurrentSpecSelector.vue
+++ /dev/null
@@ -1,116 +0,0 @@
-<template>
- <div v-if="shouldShow" class="flex flex-row justify-start items-center">
- <NSelect
- size="small"
- :options="options"
- :value="selectedSpec.id"
- :render-label="labelRender"
- :consistent-menu-width="false"
- :bordered="false"
- @update-value="handleSpecChange"
- />
- <NButton
- v-if="isCreating"
- type="default"
- size="small"
- @click="showAddSpecDrawer = true"
- >
- <template #icon>
- <PlusIcon class="w-4 h-4" />
- </template>
- </NButton>
- </div>
-
- <AddSpecDrawer
- v-model:show="showAddSpecDrawer"
- @created="handleSpecCreated"
- />
-</template>
-
-<script setup lang="tsx">
-import { head } from "lodash-es";
-import { PlusIcon } from "lucide-vue-next";
-import { NButton, NSelect } from "naive-ui";
-import { computed, ref } from "vue";
-import { useI18n } from "vue-i18n";
-import { useRoute, useRouter } from "vue-router";
-import {
- Plan_ChangeDatabaseConfig_Type,
- type Plan_Spec,
-} from "@/types/proto-es/v1/plan_service_pb";
-import { usePlanContext } from "../logic";
-import AddSpecDrawer from "./AddSpecDrawer.vue";
-import { gotoSpec } from "./common/utils";
-
-const { t } = useI18n();
-const route = useRoute();
-const router = useRouter();
-const { isCreating, plan } = usePlanContext();
-const showAddSpecDrawer = ref(false);
-
-const shouldShow = computed(() => {
- return isCreating.value || plan.value.specs.length > 1;
-});
-
-const specs = computed(() => plan.value.specs);
-
-const options = computed(() => {
- return specs.value.map((spec) => {
- return {
- label: getSpecTypeName(spec),
- value: spec.id,
- };
- });
-});
-
-const labelRender = (option: { label: string; value: string }) => {
- const spec = specs.value.find((s) => s.id === option.value);
- if (!spec) {
- return option.label;
- }
- const index = specs.value.indexOf(spec) + 1;
- const suffix = specs.value.length > 1 ? ` #${index}` : "";
- return (
- <span>
- {option.label}
- {suffix && <span class="text-gray-500">{suffix}</span>}
- </span>
- );
-};
-
-const selectedSpec = computed(() => {
- return (specs.value.find((spec) => spec.id === route.params.specId) ||
- head(specs.value)) as Plan_Spec;
-});
-
-const getSpecTypeName = (spec: Plan_Spec): string => {
- if (spec.config?.case === "createDatabaseConfig") {
- return t("plan.spec.type.create-database");
- } else if (spec.config?.case === "changeDatabaseConfig") {
- const changeType = spec.config.value.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.config?.case === "exportDataConfig") {
- return t("plan.spec.type.export-data");
- }
- return t("plan.spec.type.unknown");
-};
-
-const handleSpecChange = (specId: string) => {
- gotoSpec(router, specId);
-};
-
-const handleSpecCreated = async (spec: Plan_Spec) => {
- // Add the new spec to the plan
- plan.value.specs.push(spec);
- gotoSpec(router, spec.id);
-};
-</script>
diff --git a/frontend/src/components/Plan/components/HeaderSection/HeaderSection.vue b/frontend/src/components/Plan/components/HeaderSection/HeaderSection.vue
index 83690e9742..8abb7c4a6f 100644
--- a/frontend/src/components/Plan/components/HeaderSection/HeaderSection.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/HeaderSection.vue
@@ -2,6 +2,12 @@
<div
class="flex flex-row items-center justify-between gap-2 py-2 px-2 sm:px-4"
>
+ <NTag v-if="showDraftTag" round>
+ <template #icon>
+ <CircleDotDashedIcon class="w-4 h-4" />
+ </template>
+ {{ $t("common.draft") }}
+ </NTag>
<TitleInput />
<div class="flex flex-row items-center justify-end">
<Actions />
@@ -10,6 +16,16 @@
</template>
<script lang="ts" setup>
+import { CircleDotDashedIcon } from "lucide-vue-next";
+import { NTag } from "naive-ui";
+import { computed } from "vue";
+import { usePlanContext } from "../../logic";
import Actions from "./Actions";
import TitleInput from "./TitleInput.vue";
+
+const { isCreating, plan } = usePlanContext();
+
+const showDraftTag = computed(() => {
+ return !isCreating.value && !plan.value.issue && !plan.value.rollout;
+});
</script>
diff --git a/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue b/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
index f5354ce97a..dbbb44bd8e 100644
--- a/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
+++ b/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
@@ -80,7 +80,7 @@ const columnList = computed((): DataTableColumn<Plan>[] => {
)}
{showDraftTag && (
<NTag round size="small">
- Draft
+ {t("common.draft")}
</NTag>
)}
</div>
diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue
index b32be7b484..4350a81705 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue
@@ -2,7 +2,10 @@
<div
class="flex-1 flex flex-col hide-scrollbar gap-3 divide-y overflow-x-hidden"
>
- <TargetListSection />
+ <div class="w-full flex flex-col px-4 gap-2">
+ <SpecListSection v-if="isCreating || plan.specs.length > 1" />
+ <TargetListSection />
+ </div>
<SQLCheckV1Section v-if="isCreating" />
<PlanCheckSection v-else />
<div class="w-full space-y-3 pt-3">
@@ -22,6 +25,7 @@ import PlanCheckSection from "../PlanCheckSection";
import { providePlanSQLCheckContext } from "../SQLCheckSection";
import SQLCheckV1Section from "../SQLCheckV1Section";
import StatementSection from "../StatementSection";
+import SpecListSection from "./SpecListSection.vue";
import TargetListSection from "./TargetListSection.vue";
import { useSelectedSpec } from "./context";
diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
new file mode 100644
index 0000000000..63d3ebb653
--- /dev/null
+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
@@ -0,0 +1,106 @@
+<template>
+ <div class="flex items-center gap-2">
+ <NTabs
+ :value="selectedSpec?.id"
+ type="bar"
+ size="small"
+ class="flex-1"
+ @update:value="handleTabChange"
+ >
+ <NTab v-for="(spec, index) in plan.specs" :key="spec.id" :name="spec.id">
+ <span v-if="plan.specs.length > 1" class="mr-1 opacity-80"
+ >#{{ index + 1 }}</span
+ >
+ {{ getSpecTitle(spec) }}
+ <span
+ v-if="isSpecEmpty(spec)"
+ class="text-error ml-0.5"
+ :title="t('plan.navigator.statement-empty')"
+ >
+ *
+ </span>
+ </NTab>
+
+ <template #suffix>
+ <NButton
+ v-if="isCreating"
+ type="default"
+ size="small"
+ @click="showAddSpecDrawer = true"
+ >
+ <template #icon>
+ <PlusIcon class="w-4 h-4" />
+ </template>
+ {{ $t("plan.add-spec") }}
+ </NButton>
+ </template>
+ </NTabs>
+ </div>
+
+ <AddSpecDrawer
+ v-model:show="showAddSpecDrawer"
+ @created="handleSpecCreated"
+ />
+</template>
+
+<script setup lang="ts">
+import { PlusIcon } from "lucide-vue-next";
+import { NTabs, NTab, NButton } from "naive-ui";
+import { ref } from "vue";
+import { useI18n } from "vue-i18n";
+import { useRouter } from "vue-router";
+import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
+import { Plan_ChangeDatabaseConfig_Type } from "@/types/proto-es/v1/plan_service_pb";
+import { usePlanContext } from "../../logic/context";
+import AddSpecDrawer from "../AddSpecDrawer.vue";
+import { useSpecsValidation } from "../common";
+import { gotoSpec } from "../common/utils";
+import { useSelectedSpec } from "./context";
+
+const { t } = useI18n();
+const router = useRouter();
+const { plan, isCreating } = usePlanContext();
+const selectedSpec = useSelectedSpec();
+const { isSpecEmpty } = useSpecsValidation(plan.value.specs);
+
+const showAddSpecDrawer = ref(false);
+
+const getSpecTitle = (spec: Plan_Spec) => {
+ let title = "";
+ if (spec.config?.case === "createDatabaseConfig") {
+ title = t("plan.spec.type.create-database");
+ } else if (spec.config?.case === "changeDatabaseConfig") {
+ const changeType = spec.config.value.type;
+ switch (changeType) {
+ case Plan_ChangeDatabaseConfig_Type.MIGRATE:
+ title = t("plan.spec.type.schema-change");
+ break;
+ case Plan_ChangeDatabaseConfig_Type.DATA:
+ title = t("plan.spec.type.data-change");
+ break;
+ case Plan_ChangeDatabaseConfig_Type.MIGRATE_GHOST:
+ title = t("plan.spec.type.ghost-migration");
+ break;
+ default:
+ title = t("plan.spec.type.database-change");
+ }
+ } else if (spec.config?.case === "exportDataConfig") {
+ title = t("plan.spec.type.export-data");
+ } else {
+ title = t("plan.spec.type.unknown");
+ }
+ return title;
+};
+
+const handleTabChange = (specId: string) => {
+ if (selectedSpec.value?.id !== specId) {
+ gotoSpec(router, specId);
+ }
+};
+
+const handleSpecCreated = async (spec: Plan_Spec) => {
+ // Add the new spec to the plan
+ plan.value.specs.push(spec);
+ gotoSpec(router, spec.id);
+};
+</script>
diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
index 0b81ea82ea..0fc93ccff5 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
@@ -1,5 +1,5 @@
<template>
- <div class="px-4 flex flex-col gap-y-2">
+ <div class="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>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 3d4554cd05..0c3f192df6 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -233,7 +233,8 @@
"errors": "Errors",
"removed": "Removed",
"submit": "Submit",
- "start": "Start"
+ "start": "Start",
+ "draft": "Draft"
},
"error-page": {
"go-back-home": "Go back home"
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 3d4092564f..04886ff7ef 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -233,7 +233,8 @@
"errors": "Errores",
"removed": "Remoto",
"submit": "Entregar",
- "start": "Comenzar"
+ "start": "Comenzar",
+ "draft": "Borrador"
},
"error-page": {
"go-back-home": "Volver al inicio"
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 273aec2181..340117f3ad 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -233,7 +233,8 @@
"errors": "エラー",
"removed": "削除されました",
"submit": "提出する",
- "start": "始める"
+ "start": "始める",
+ "draft": "下書き"
},
"error-page": {
"go-back-home": "ホームページに戻る"
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 9b15f558b5..5d77778ff6 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -233,7 +233,8 @@
"errors": "Lỗi",
"removed": "LOẠI BỎ",
"submit": "Nộp",
- "start": "Bắt đầu"
+ "start": "Bắt đầu",
+ "draft": "Bản nháp"
},
"error-page": {
"go-back-home": "Về trang chủ"
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index f3d9425874..09fd71278d 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -233,7 +233,8 @@
"errors": "错误",
"removed": "已移除",
"submit": "提交",
- "start": "开始"
+ "start": "开始",
+ "draft": "草稿"
},
"error-page": {
"go-back-home": "回到主页"
diff --git a/frontend/src/views/project/CICDLayout.vue b/frontend/src/views/project/CICDLayout.vue
index 15dd6e2d01..50c64620e7 100644
--- a/frontend/src/views/project/CICDLayout.vue
+++ b/frontend/src/views/project/CICDLayout.vue
@@ -20,6 +20,7 @@
</div>
<HeaderSection />
+
<NTabs
type="line"
:value="tabKey"
@@ -37,8 +38,7 @@
<!-- Suffix slot -->
<template #suffix>
- <div class="pr-4 flex flex-row justify-end items-center gap-4">
- <CurrentSpecSelector v-if="tabKey === TabKey.Plan" />
+ <div class="pr-3 flex flex-row justify-end items-center gap-4">
<RefreshIndicator v-if="!isCreating" />
</div>
</template>
@@ -59,7 +59,7 @@
<script lang="tsx" setup>
import { useTitle } from "@vueuse/core";
import { CirclePlayIcon, FileDiffIcon, Layers2Icon } from "lucide-vue-next";
-import { NSpin, NTab, NTabs } from "naive-ui";
+import { NSpin, NTab, NTabs, NTag } from "naive-ui";
import { computed, ref, toRef, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
@@ -70,9 +70,7 @@ import {
} from "@/components/Plan";
import PollerProvider from "@/components/Plan/PollerProvider.vue";
import { HeaderSection } from "@/components/Plan/components";
-import CurrentSpecSelector from "@/components/Plan/components/CurrentSpecSelector.vue";
import RefreshIndicator from "@/components/Plan/components/RefreshIndicator.vue";
-import { useSpecsValidation } from "@/components/Plan/components/common";
import { provideIssueReviewContext } from "@/components/Plan/logic/issue-review";
import { useIssueLayoutVersion } from "@/composables/useIssueLayoutVersion";
import { useBodyLayoutContext } from "@/layouts/common";
@@ -180,8 +178,6 @@ watch(
{ once: true }
);
-const { isSpecEmpty } = useSpecsValidation(plan.value.specs);
-
const tabKey = computed(() => {
const routeName = route.name?.toString() as string;
if (
@@ -233,17 +229,12 @@ const tabRender = (tab: TabKey) => {
return (
<div class="flex items-center gap-2">
<FileDiffIcon size={18} />
- <span>
- {t("plan.navigator.changes")}
- {plan.value.specs.some(isSpecEmpty) && (
- <span
- class="text-error ml-0.5"
- title={t("plan.navigator.statement-empty")}
- >
- *
- </span>
- )}
- </span>
+ <span>{t("plan.navigator.changes")}</span>
+ {(isCreating.value || plan.value.specs.length > 1) && (
+ <NTag size="tiny" round>
+ {plan.value.specs.length}
+ </NTag>
+ )}
</div>
);
case TabKey.Rollout: