Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: unify new plan drawer in review center (#16502)
boojack5e20595f7a6c
diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjsindex 739b0a007a..1cdc7532a4 100644--- a/frontend/eslint.config.mjs+++ b/frontend/eslint.config.mjs@@ -14,7 +14,12 @@ export default [}),...vueI18n.configs["flat/recommended"],{- ignores: ["**/dist/**", "**/node_modules/**", "**/proto/**"],+ ignores: [+ "**/dist/**",+ "**/node_modules/**",+ "**/proto/**",+ "**/proto-es/**",+ ],},{rules: {diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vuedeleted file mode 100644index cd38151036..0000000000--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue+++ /dev/null@@ -1,298 +0,0 @@-<template>- <DrawerContent class="max-w-[100vw]">- <template #header>- <div class="flex flex-col gap-y-1">- <span>- {{- isEditSchema- ? $t("database.edit-schema")- : $t("database.change-data")- }}- </span>- </div>- </template>-- <div- class="space-y-4 h-full w-[calc(100vw-8rem)] lg:w-[60rem] max-w-[calc(100vw-8rem)] overflow-x-auto"- >- <AdvancedSearch- v-model:params="state.params"- :autofocus="false"- :placeholder="$t('database.filter-database')"- :scope-options="scopeOptions"- />- <PagedDatabaseTable- mode="ALL_SHORT"- :filter="filter"- :parent="projectName"- :custom-click="true"- :show-sql-editor-button="false"- v-model:selected-database-names="state.selectedDatabaseNames"- />- </div>-- <template #footer>- <div class="flex-1 flex items-center justify-between">- <div>- <NTooltip v-if="flattenSelectedDatabaseNameList.length > 0">- <template #trigger>- <div class="textinfolabel">- {{- $t("database.selected-n-databases", {- n: flattenSelectedDatabaseNameList.length,- })- }}- </div>- </template>- <div class="mx-2">- <ul class="list-disc">- <li v-for="db in flattenSelectedDatabaseList" :key="db.name">- {{ db.databaseName }}- </li>- </ul>- </div>- </NTooltip>- </div>-- <div class="flex items-center justify-end gap-x-3">- <NCheckbox v-if="!props.planOnly" v-model:checked="state.planOnly">- {{ $t("issue.sql-review-only") }}- </NCheckbox>- <NButton @click.prevent="cancel">- {{ $t("common.cancel") }}- </NButton>- <NTooltip :disabled="flattenSelectedProjectList.length <= 1">- <template #trigger>- <NButton- type="primary"- :disabled="!allowGenerateMultiDb"- @click.prevent="generateMultiDb"- >- {{ $t("common.next") }}- </NButton>- </template>- <span class="w-56 text-sm">- {{ $t("database.select-databases-from-same-project") }}- </span>- </NTooltip>- </div>- </div>- </template>- </DrawerContent>-- <FeatureModal- :open="!!featureModalContext.feature"- :feature="featureModalContext.feature"- @cancel="featureModalContext.feature = undefined"- />-- <SchemaEditorModal- v-if="state.showSchemaEditorModal"- :database-names="schemaEditorContext.databaseNameList"- :alter-type="'MULTI_DB'"- :plan-only="state.planOnly"- @close="state.showSchemaEditorModal = false"- />-</template>--<script lang="ts" setup>-import { uniq, uniqBy } from "lodash-es";-import { NButton, NCheckbox, NTooltip } from "naive-ui";-import { computed, reactive, ref } from "vue";-import { useRouter } from "vue-router";-import { FeatureModal } from "@/components/FeatureGuard";-import { PagedDatabaseTable } from "@/components/v2/Model/DatabaseV1Table";-import {- PROJECT_V1_ROUTE_ISSUE_DETAIL,- PROJECT_V1_ROUTE_PLAN_DETAIL,-} from "@/router/dashboard/projectV1";-import { useDatabaseV1Store, useAppFeature } from "@/store";-import {- instanceNamePrefix,- environmentNamePrefix,-} from "@/store/modules/v1/common";-import { Engine } from "@/types/proto/v1/common";-import { PlanFeature } from "@/types/proto/v1/subscription_service";-import type { SearchParams, SearchScope } from "@/utils";-import {- allowUsingSchemaEditor,- generateIssueTitle,- extractProjectResourceName,-} from "@/utils";-import AdvancedSearch from "../AdvancedSearch";-import { useCommonSearchScopeOptions } from "../AdvancedSearch/useCommonSearchScopeOptions";-import { DrawerContent } from "../v2";-import SchemaEditorModal from "./SchemaEditorModal.vue";--type LocalState = {- showSchemaLessDatabaseList: boolean;- selectedDatabaseNames: string[];- showSchemaEditorModal: boolean;- params: SearchParams;- // planOnly is used to indicate whether only to create plan.- planOnly: boolean;-};--const props = withDefaults(- defineProps<{- projectName: string;- type: "bb.issue.database.schema.update" | "bb.issue.database.data.update";- planOnly?: boolean;- }>(),- {- planOnly: false,- }-);--const emit = defineEmits(["dismiss"]);--const router = useRouter();-const databaseV1Store = useDatabaseV1Store();-const disableSchemaEditor = useAppFeature(- "bb.feature.issue.disable-schema-editor"-);--const featureModalContext = ref<{- feature?: PlanFeature;-}>({});--const schemaEditorContext = ref<{- databaseNameList: string[];-}>({- databaseNameList: [],-});--const readonlyScopes = computed((): SearchScope[] => [- {- id: "project",- value: extractProjectResourceName(props.projectName),- readonly: true,- },-]);--const state = reactive<LocalState>({- selectedDatabaseNames: [],- showSchemaLessDatabaseList: false,- showSchemaEditorModal: false,- params: {- query: "",- scopes: [...readonlyScopes.value],- },- planOnly: props.planOnly,-});--const scopeOptions = useCommonSearchScopeOptions(- computed(() => ["project", "instance", "environment", "database-label"])-);--const selectedInstance = computed(() => {- const instanceId = state.params.scopes.find(- (scope) => scope.id === "instance"- )?.value;- if (!instanceId) {- return;- }- return `${instanceNamePrefix}${instanceId}`;-});--const selectedEnvironment = computed(() => {- const environmentId = state.params.scopes.find(- (scope) => scope.id === "environment"- )?.value;- if (!environmentId) {- return;- }- return `${environmentNamePrefix}${environmentId}`;-});--const selectedLabels = computed(() => {- return state.params.scopes- .filter((scope) => scope.id === "database-label")- .map((scope) => scope.value);-});--const filter = computed(() => ({- instance: selectedInstance.value,- environment: selectedEnvironment.value,- query: state.params.query,- excludeEngines: [Engine.REDIS],- labels: selectedLabels.value,-}));--// Returns true if alter schema, false if change data.-const isEditSchema = computed((): boolean => {- return props.type === "bb.issue.database.schema.update";-});--const flattenSelectedDatabaseNameList = computed(() => {- return uniq(state.selectedDatabaseNames);-});--const flattenSelectedProjectList = computed(() => {- const projects = flattenSelectedDatabaseNameList.value.map((name) => {- return databaseV1Store.getDatabaseByName(name).projectEntity;- });- return uniqBy(projects, (project) => project.name);-});--const allowGenerateMultiDb = computed(() => {- return (- flattenSelectedProjectList.value.length === 1 &&- flattenSelectedDatabaseNameList.value.length > 0- );-});--const flattenSelectedDatabaseList = computed(() =>- flattenSelectedDatabaseNameList.value.map((name) =>- databaseV1Store.getDatabaseByName(name)- )-);--// Also works when single db selected.-const generateMultiDb = async () => {- if (- flattenSelectedDatabaseList.value.length === 1 &&- isEditSchema.value &&- allowUsingSchemaEditor(flattenSelectedDatabaseList.value) &&- !disableSchemaEditor.value- ) {- schemaEditorContext.value.databaseNameList = [- ...flattenSelectedDatabaseNameList.value,- ];- state.showSchemaEditorModal = true;- return;- }-- if (flattenSelectedProjectList.value.length !== 1) {- return;- }-- const project = flattenSelectedProjectList.value[0];- const query: Record<string, any> = {- template: props.type,- name: generateIssueTitle(- props.type,- flattenSelectedDatabaseList.value.map((db) => db.databaseName)- ),- databaseList: flattenSelectedDatabaseList.value- .map((db) => db.name)- .join(","),- };-- router.push({- name: state.planOnly- ? PROJECT_V1_ROUTE_PLAN_DETAIL- : PROJECT_V1_ROUTE_ISSUE_DETAIL,- params: {- projectId: extractProjectResourceName(project.name),- issueSlug: "create",- planId: "create",- },- query,- });-};--const cancel = () => {- emit("dismiss");-};-</script>diff --git a/frontend/src/components/AlterSchemaPrepForm/index.ts b/frontend/src/components/AlterSchemaPrepForm/index.tsdeleted file mode 100644index c7794601d7..0000000000--- a/frontend/src/components/AlterSchemaPrepForm/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import AlterSchemaPrepForm from "./AlterSchemaPrepForm.vue";--export default AlterSchemaPrepForm;diff --git a/frontend/src/components/Plan/components/AddSpecDrawer.vue b/frontend/src/components/Plan/components/AddSpecDrawer.vueindex c8c223dbb9..12aff4925a 100644--- a/frontend/src/components/Plan/components/AddSpecDrawer.vue+++ b/frontend/src/components/Plan/components/AddSpecDrawer.vue@@ -6,7 +6,7 @@placement="right"class="!w-[100vw] sm:!w-[80vw]">- <DrawerContent :title="$t('plan.add-spec')" closable>+ <DrawerContent :title="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">@@ -58,7 +58,7 @@:loading="isCreating"@click="handleConfirm">- {{ $t("common.add") }}+ {{ $t("common.confirm") }}</NButton></div></template>@@ -83,6 +83,10 @@ import {import type { Plan_Spec } from "@/types/proto/v1/plan_service";import { Sheet } from "@/types/proto/v1/sheet_service";+defineProps<{+ title?: string;+}>();+const emit = defineEmits<{(event: "created", spec: Plan_Spec): void;}>();diff --git a/frontend/src/components/Plan/components/ChecksView/ChecksView.vue b/frontend/src/components/Plan/components/ChecksView/ChecksView.vueindex e0d5e4acab..f98ef50522 100644--- a/frontend/src/components/Plan/components/ChecksView/ChecksView.vue+++ b/frontend/src/components/Plan/components/ChecksView/ChecksView.vue@@ -131,7 +131,7 @@<divv-for="(result, idx) in getFilteredResults(checkRun)":key="idx"- class="flex items-start gap-3 p-3 border rounded-lg bg-gray-50"+ class="flex items-start gap-3 px-3 py-2 border rounded-lg bg-gray-50"><component:is="getStatusIcon(result.status)"@@ -140,22 +140,20 @@/><div class="flex-1 min-w-0">- <div class="text-sm font-medium text-main mb-1">+ <div class="text-sm font-medium text-main">{{ result.title }}</div>-<divv-if="result.content"- class="text-xs text-control-light mb-2"+ class="text-xs text-control-light mt-1">{{ result.content }}</div>-<divv-if="result.sqlReviewReport && result.sqlReviewReport.line > 0"- class="text-xs text-control-lighter"+ class="text-xs text-control-lighter mt-1">Line {{ result.sqlReviewReport.line }}, Column{{ result.sqlReviewReport.column }}diff --git a/frontend/src/components/Plan/components/CurrentSpecSelector.vue b/frontend/src/components/Plan/components/CurrentSpecSelector.vueindex 27694743ce..ae50a0a6ed 100644--- a/frontend/src/components/Plan/components/CurrentSpecSelector.vue+++ b/frontend/src/components/Plan/components/CurrentSpecSelector.vue@@ -21,7 +21,6 @@</NButton></div>- <!-- Add Spec Drawer --><AddSpecDrawerv-model:show="showAddSpecDrawer"@created="handleSpecCreated"diff --git a/frontend/src/components/Plan/components/Overview.vue b/frontend/src/components/Plan/components/Overview.vueindex b63e26a5bc..8119ff5c70 100644--- a/frontend/src/components/Plan/components/Overview.vue+++ b/frontend/src/components/Plan/components/Overview.vue@@ -115,7 +115,7 @@<template v-if="resource.type === 'instance'"><spanv-if="resource.instance?.environmentEntity"- class="text-sm text-gray-600"+ class="text-sm text-gray-500">({{ resource.instance.environmentEntity.title }})</span>diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vueindex cded741c3b..b5174dee2f 100644--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue@@ -148,7 +148,7 @@<div class="flex items-center gap-2 mb-3"><component:is="getCheckTypeIcon(checkType)"- class="w-4 h-4"+ class="w-5 h-5"/><span class="font-medium">{{getCheckTypeLabel(checkType)@@ -173,7 +173,7 @@selectedStatus)":key="idx"- class="pl-4 py-1"+ class="px-3 py-1 border rounded-lg bg-gray-50"><divclass="text-sm"diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vueindex eb3e80cfca..14cf69266b 100644--- a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue@@ -32,68 +32,35 @@'max-height': `${MAX_LIST_HEIGHT}px`,}">- <NTooltip- v-for="(item, index) in tableData"- :key="index"- placement="top"+ <div+ v-for="item in tableData"+ :key="item.name"+ class="inline-flex items-center gap-x-1.5 px-3 py-1.5 border rounded-lg transition-all cursor-default max-w-[20rem]">- <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]"- >- <EngineIcon- v-if="item.type === 'database' && item.engine"- :engine="item.engine"- custom-class="w-4 h-4 text-control-light flex-shrink-0"- />- <component- v-else- :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>+ <EngineIcon+ v-if="item.type === 'database' && item.engine"+ :engine="item.engine"+ custom-class="w-4 h-4 text-control-light flex-shrink-0"+ />+ <component+ v-else+ :is="item.icon"+ class="w-4 h-4 text-control-light flex-shrink-0"+ />+ <span class="text-sm text-gray-500" v-if="item.environment">+ ({{ item.environment }})+ </span>+ <div class="flex items-center gap-x-1 min-w-0 text-sm">+ <NEllipsis :line-clamp="1">+ <span class="font-medium">{{ item.name }}</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>- </NTooltip>+ </div><!-- Load More Button --><div@@ -132,7 +99,7 @@ import {FolderIcon,EditIcon,} from "lucide-vue-next";-import { NEllipsis, NTooltip, NButton } from "naive-ui";+import { NEllipsis, NButton } from "naive-ui";import { computed, ref, reactive, watch } from "vue";import { useI18n } from "vue-i18n";import { BBSpin } from "@/bbkit";diff --git a/frontend/src/components/Plan/components/SpecsView.vue b/frontend/src/components/Plan/components/SpecsView.vueindex b398a390ed..c339adca8c 100644--- a/frontend/src/components/Plan/components/SpecsView.vue+++ b/frontend/src/components/Plan/components/SpecsView.vue@@ -1,5 +1,5 @@<template>- <SpecDetailView />+ <SpecDetailView :key="selectedSpec.id" /></template><script setup lang="ts">diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex b29ed1ba7d..3ee4a4186a 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1034,7 +1034,6 @@"multiple-databases": "{count} databases","database-group": "Database Group","database-not-found": "Database not found",- "environment": "Environment: {environment}","type": {"instance": "Instance","database": "Database",@@ -1472,7 +1471,6 @@"unassigned-databases": "Unassigned databases","selected-n-databases": "{n} database selected | {n} databases selected","n-databases": "{n} database | {n} databases",- "select-databases-from-same-project": "Please select databases from the same project","sync-schema": {"title": "Sync Schema","description": "Bytebase supports synchronizing a schema to one or multiple target databases. (MySQL, PostgreSQL, Oracle, MSSQL, TiDB only)",@@ -2592,8 +2590,7 @@"permission-denied": "Permission denied"},"review-center": {- "self": "Review Center",- "review-sql": "Review SQL"+ "self": "Review Center"},"schema-designer": {"use-tips": "Click a table to start."diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 15587902ce..da10e09497 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1034,7 +1034,6 @@"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",@@ -1472,7 +1471,6 @@"unassigned-databases": "Bases de datos no asignadas","selected-n-databases": "{n} base de datos seleccionada | {n} bases de datos seleccionadas","n-databases": "{n} base de datos | {n} bases de datos",- "select-databases-from-same-project": "Por favor seleccione bases de datos del mismo proyecto","sync-schema": {"title": "Sincronizar esquema","description": "Bytebase admite la sincronización de un esquema con una o varias bases de datos de destino. (Solo MySQL, PostgreSQL, Oracle, MSSQL, TiDB)",@@ -2592,8 +2590,7 @@"permission-denied": "Permiso denegado"},"review-center": {- "self": "Centro de revisión",- "review-sql": "Revisar SQL"+ "self": "Centro de revisión"},"schema-designer": {"use-tips": "Selecciona las tablas a diseñar"diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 17e1a3920f..49e4204731 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1034,7 +1034,6 @@"multiple-databases": "{count} データベース","database-group": "データベースグループ","database-not-found": "データベースが見つかりません",- "environment": "環境: {environment}","type": {"instance": "実例","database": "データベース",@@ -1472,7 +1471,6 @@"unassigned-databases": "未割り当てのデータベース","selected-n-databases": "{n} 個のデータベースが選択されました","n-databases": "{n} データベース",- "select-databases-from-same-project": "同じプロジェクト内のデータベースを選択してください","sync-schema": {"title": "データベーステーブルの同期","description": "Bytebase は、スキーマを 1 つまたは複数のターゲット データベースに同期することをサポートします。(MySQL, PostgreSQL, Oracle, MSSQL, TiDB のみ)",@@ -2592,8 +2590,7 @@"permission-denied": "この操作を実行する権限がありません"},"review-center": {- "self": "レビューセンター",- "review-sql": "SQLを確認する"+ "self": "レビューセンター"},"schema-designer": {"use-tips": "デザインするテーブルを選択してください"diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 40cdd694a2..aa51ec6600 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1034,7 +1034,6 @@"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",@@ -1472,7 +1471,6 @@"unassigned-databases": "Cơ sở dữ liệu chưa được gán","selected-n-databases": "Đã chọn {n} cơ sở dữ liệu | Đã chọn {n} cơ sở dữ liệu","n-databases": "{n} cơ sở dữ liệu | {n} cơ sở dữ liệu",- "select-databases-from-same-project": "Vui lòng chọn cơ sở dữ liệu từ cùng một dự án","sync-schema": {"title": "Đồng bộ lược đồ","description": "Bytebase hỗ trợ đồng bộ hóa một lược đồ với một hoặc nhiều cơ sở dữ liệu đích. (Chỉ MySQL, PostgreSQL, Oracle, MSSQL, TiDB)",@@ -2592,8 +2590,7 @@"permission-denied": "Quyền bị từ chối"},"review-center": {- "self": "Trung tâm đánh giá",- "review-sql": "Đánh giá SQL"+ "self": "Trung tâm đánh giá"},"schema-designer": {"use-tips": "Nhấp vào một bảng để bắt đầu."diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 0c27233538..743718a52e 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1034,7 +1034,6 @@"multiple-databases": "{count} 个数据库","database-group": "数据库组","database-not-found": "未找到数据库",- "environment": "环境:{environment}","type": {"instance": "实例","database": "数据库",@@ -1472,7 +1471,6 @@"unassigned-databases": "未分配的数据库","selected-n-databases": "已选择 {n} 个数据库","n-databases": "{n} 个数据库",- "select-databases-from-same-project": "请选择同一个项目下的数据库","sync-schema": {"title": "库表同步","description": "Bytebase 支持将一个指定的 Schema 同步到一个或多个目标数据库。(支持 MySQL, PostgreSQL, Oracle, MSSQL 以及 TiDB)",@@ -2592,8 +2590,7 @@"permission-denied": "您没有权限执行此操作"},"review-center": {- "self": "SQL 审核中心",- "review-sql": "审核 SQL"+ "self": "SQL 审核中心"},"schema-designer": {"use-tips": "选择需要设计的表"diff --git a/frontend/src/views/ReviewCenter/index.vue b/frontend/src/views/ReviewCenter/index.vueindex 8338261210..f936ecbdf4 100644--- a/frontend/src/views/ReviewCenter/index.vue+++ b/frontend/src/views/ReviewCenter/index.vue@@ -1,5 +1,5 @@<template>- <div :class="['w-full', !specificProject && 'px-4']">+ <div :class="['w-full']"><divclass="w-full flex flex-col lg:flex-row items-start lg:items-center justify-between gap-2">@@ -9,16 +9,16 @@class="flex-1":scope-options="scopeOptions"/>- <NDropdown- trigger="hover"- :options="planCreationButtonOptions"- :disabled="!allowToCreatePlan"- @select="state.selectedPlanOnlyType = $event"+ <NButton+ v-if="allowToCreatePlan"+ type="primary"+ @click="showAddSpecDrawer = true">- <NButton type="primary" :disabled="!allowToCreatePlan">{{- $t("review-center.review-sql")- }}</NButton>- </NDropdown>+ <template #icon>+ <PlusIcon class="w-4 h-4" />+ </template>+ {{ $t("plan.new-plan") }}+ </NButton></div></div>@@ -32,59 +32,58 @@<PlanDataTable:loading="loading":plan-list="list"- :show-project="!specificProject"+ :show-project="false"/></template></PagedTable></div></div>- <Drawer- :auto-focus="true"- :show="state.selectedPlanOnlyType !== undefined"- @close="state.selectedPlanOnlyType = undefined"- >- <AlterSchemaPrepForm- :project-name="specificProject.name"- :type="state.selectedPlanOnlyType!"- :plan-only="true"- @dismiss="state.selectedPlanOnlyType = undefined"- />- </Drawer>+ <AddSpecDrawer+ v-model:show="showAddSpecDrawer"+ :title="$t('plan.new-plan')"+ @created="handleSpecCreated"+ /></template><script lang="ts" setup>-import { NButton, NDropdown, type DropdownOption } from "naive-ui";+import { head } from "lodash-es";+import { PlusIcon } from "lucide-vue-next";+import { NButton } from "naive-ui";import { computed, reactive, watch, ref } from "vue";import type { ComponentExposed } from "vue-component-type-helpers";-import { useI18n } from "vue-i18n";+import { useRouter } from "vue-router";import AdvancedSearch from "@/components/AdvancedSearch";import { useCommonSearchScopeOptions } from "@/components/AdvancedSearch/useCommonSearchScopeOptions";-import AlterSchemaPrepForm from "@/components/AlterSchemaPrepForm/";+import { targetsForSpec } from "@/components/Plan";+import AddSpecDrawer from "@/components/Plan/components/AddSpecDrawer.vue";import PlanDataTable from "@/components/Plan/components/PlanDataTable";-import { Drawer } from "@/components/v2";import PagedTable from "@/components/v2/Model/PagedTable.vue";+import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "@/router/dashboard/projectV1";import {+ useCurrentProjectV1,useCurrentUserV1,- useProjectByName,useRefreshPlanList,} from "@/store";-import { projectNamePrefix } from "@/store/modules/v1/common";import { usePlanStore } from "@/store/modules/v1/plan";import { buildPlanFindBySearchParams } from "@/store/modules/v1/plan";-import type { Plan } from "@/types/proto/v1/plan_service";+import { isValidDatabaseGroupName } from "@/types";import {+ Plan_ChangeDatabaseConfig_Type,+ type Plan,+ type Plan_Spec,+} from "@/types/proto/v1/plan_service";+import {+ extractDatabaseGroupName,+ extractDatabaseResourceName,extractProjectResourceName,+ generateIssueTitle,hasPermissionToCreatePlanInProject,type SearchParams,type SearchScope,type SearchScopeId,} from "@/utils";-const props = defineProps<{- projectId: string;-}>();-interface LocalState {params: SearchParams;selectedPlanOnlyType?:@@ -92,15 +91,14 @@ interface LocalState {| "bb.issue.database.data.update";}-const { project: specificProject } = useProjectByName(- computed(() => `${projectNamePrefix}${props.projectId}`)-);+const { project } = useCurrentProjectV1();+const showAddSpecDrawer = ref(false);const readonlyScopes = computed((): SearchScope[] => {return [{id: "project",- value: extractProjectResourceName(specificProject.value.name),+ value: extractProjectResourceName(project.value.name),readonly: true,},];@@ -114,33 +112,20 @@ const defaultSearchParams = () => {return params;};-const { t } = useI18n();+const router = useRouter();const currentUser = useCurrentUserV1();const state = reactive<LocalState>({params: defaultSearchParams(),});watch(- () => specificProject.value,+ () => project.value.name,() => (state.params = defaultSearchParams()));const planStore = usePlanStore();const planPagedTable = ref<ComponentExposed<typeof PagedTable<Plan>>>();-const planCreationButtonOptions = computed((): DropdownOption[] => {- return [- {- label: `${t("database.edit-schema")} (DDL)`,- key: "bb.issue.database.schema.update",- },- {- label: `${t("database.change-data")} (DML)`,- key: "bb.issue.database.data.update",- },- ];-});-const supportedScopes = computed(() => {// TODO(steven): support more scopes in backend and frontend: instance, database, planCheckRunStatusconst supportedScopes: SearchScopeId[] = [];@@ -158,10 +143,10 @@ const planSearchParams = computed(() => {},];// If specific project is provided, add project scope.- if (specificProject.value) {+ if (project.value) {defaultScopes.push({id: "project",- value: extractProjectResourceName(specificProject.value.name),+ value: extractProjectResourceName(project.value.name),});}return {@@ -202,6 +187,48 @@ useRefreshPlanList(() => planPagedTable.value?.refresh());const allowToCreatePlan = computed(() => {// Check if user has permission to create plan in specific project.- return hasPermissionToCreatePlanInProject(specificProject.value);+ return hasPermissionToCreatePlanInProject(project.value);});++const handleSpecCreated = async (spec: Plan_Spec) => {+ const template =+ spec.changeDatabaseConfig?.type === Plan_ChangeDatabaseConfig_Type.DATA+ ? "bb.issue.database.data.update"+ : "bb.issue.database.schema.update";+ const targets = targetsForSpec(spec);+ const isDatabaseGroup = targets.every((target) =>+ isValidDatabaseGroupName(target)+ );+ const query: Record<string, any> = {+ template,+ };+ if (isDatabaseGroup) {+ const databaseGroupName = head(targets);+ if (!databaseGroupName) {+ throw new Error("No valid database group name found in targets.");+ }+ query.databaseGroupName = databaseGroupName;+ query.name = generateIssueTitle(template, [+ extractDatabaseGroupName(databaseGroupName),+ ]);+ } else {+ query.databaseList = targets.join(",");+ query.name = generateIssueTitle(+ template,+ targets.map((db) => {+ const { databaseName } = extractDatabaseResourceName(db);+ return databaseName;+ })+ );+ }++ router.push({+ name: PROJECT_V1_ROUTE_PLAN_DETAIL,+ params: {+ projectId: extractProjectResourceName(project.value.name),+ planId: "create",+ },+ query,+ });+};</script>