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: handle multiple targets (#18527)
ecmadao5d6592393dfd
diff --git a/frontend/src/components/Plan/components/Configuration/Configuration.vue b/frontend/src/components/Plan/components/Configuration/Configuration.vueindex 6a95058568..21e6ff3001 100644--- a/frontend/src/components/Plan/components/Configuration/Configuration.vue+++ b/frontend/src/components/Plan/components/Configuration/Configuration.vue@@ -32,7 +32,7 @@ import { provideTransactionModeSettingContext } from "./TransactionModeSection/cconst { project } = useCurrentProjectV1();const { isCreating, plan, events, issue, rollout, readonly } = usePlanContext();-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();const {shouldShow: shouldShowTransactionModeSection,diff --git a/frontend/src/components/Plan/components/Configuration/InstanceRoleSection/InstanceRoleSelect.vue b/frontend/src/components/Plan/components/Configuration/InstanceRoleSection/InstanceRoleSelect.vueindex a4bb46377f..12cfed98e5 100644--- a/frontend/src/components/Plan/components/Configuration/InstanceRoleSection/InstanceRoleSelect.vue+++ b/frontend/src/components/Plan/components/Configuration/InstanceRoleSection/InstanceRoleSelect.vue@@ -42,7 +42,7 @@ const {databases,events,} = useInstanceRoleSettingContext();-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();const { sheetStatement, sheet, sheetReady } = useSpecSheet(selectedSpec);const { plan, isCreating } = usePlanContext();diff --git a/frontend/src/components/Plan/components/Configuration/IsolationLevelSection/IsolationLevelSelect.vue b/frontend/src/components/Plan/components/Configuration/IsolationLevelSection/IsolationLevelSelect.vueindex 39bd119e76..4997de2104 100644--- a/frontend/src/components/Plan/components/Configuration/IsolationLevelSection/IsolationLevelSelect.vue+++ b/frontend/src/components/Plan/components/Configuration/IsolationLevelSection/IsolationLevelSelect.vue@@ -37,7 +37,7 @@ const {events,} = useIsolationLevelSettingContext();-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();const { sheetStatement, sheet, sheetReady } = useSpecSheet(selectedSpec);const { plan, isCreating } = usePlanContext();diff --git a/frontend/src/components/Plan/components/Configuration/TransactionModeSection/TransactionModeSwitch.vue b/frontend/src/components/Plan/components/Configuration/TransactionModeSection/TransactionModeSwitch.vueindex e44bd6d86a..179aece619 100644--- a/frontend/src/components/Plan/components/Configuration/TransactionModeSection/TransactionModeSwitch.vue+++ b/frontend/src/components/Plan/components/Configuration/TransactionModeSection/TransactionModeSwitch.vue@@ -24,7 +24,7 @@ import { useTransactionModeSettingContext } from "./context";const { allowChange, transactionMode, events } =useTransactionModeSettingContext();-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();const { sheetStatement, sheet, sheetReady } = useSpecSheet(selectedSpec);const { plan, isCreating } = usePlanContext();diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vueindex 389732d302..eadea3edf6 100644--- a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue@@ -30,7 +30,7 @@ import {const databaseStore = useDatabaseV1Store();const sheetStore = useSheetV1Store();-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();const { taskRuns } = usePlanContextWithRollout();const exportDataConfig = computed(() => {diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vueindex 1b0b12dd84..5f8df5a662 100644--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue@@ -49,7 +49,7 @@{{ affectedRows }}</span><CircleQuestionMarkIcon- class="size-[14px] text-control-light opacity-80"+ class="size-3.5 text-control-light opacity-80"/></div></NTag>@@ -97,7 +97,7 @@ import { useSpecSheet } from "../StatementSection/useSpecSheet";const currentUser = useCurrentUserV1();const { project } = useCurrentProjectV1();const { plan, planCheckRuns } = usePlanContext();-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();const { refreshResources } = useResourcePoller();const { statusCountString } = usePlanCheckStatus(plan);const { sheet } = useSpecSheet(selectedSpec);diff --git a/frontend/src/components/Plan/components/SQLCheckV1Section/SQLCheckV1Section.vue b/frontend/src/components/Plan/components/SQLCheckV1Section/SQLCheckV1Section.vueindex e8e3444f2c..fb5817757f 100644--- a/frontend/src/components/Plan/components/SQLCheckV1Section/SQLCheckV1Section.vue+++ b/frontend/src/components/Plan/components/SQLCheckV1Section/SQLCheckV1Section.vue@@ -128,7 +128,7 @@ import ChecksView from "../ChecksView/ChecksView.vue";import { useSelectedSpec } from "../SpecDetailView/context";const { plan } = usePlanContext();-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();const isRunningChecks = ref(false);const drawerVisible = ref(false);diff --git a/frontend/src/components/Plan/components/SpecDetailView/AllTargetsDrawer.vue b/frontend/src/components/Plan/components/SpecDetailView/AllTargetsDrawer.vueindex 70e6e54e43..c8dec3ce1c 100644--- a/frontend/src/components/Plan/components/SpecDetailView/AllTargetsDrawer.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/AllTargetsDrawer.vue@@ -69,8 +69,8 @@ import {useDBGroupStore,} from "@/store";import { isValidDatabaseGroupName, isValidDatabaseName } from "@/types";-import { usePlanContext } from "../../logic/context";import DatabaseDisplay from "../common/DatabaseDisplay.vue";+import { useSelectedSpec } from "./context";import DatabaseGroupTargetDisplay from "./DatabaseGroupTargetDisplay.vue";interface Props {@@ -90,23 +90,13 @@ defineEmits<{const databaseStore = useDatabaseV1Store();const dbGroupStore = useDBGroupStore();-const { plan } = usePlanContext();+const { getDatabaseTargets } = useSelectedSpec();const state = reactive<LocalState>({searchText: "",isLoading: false,});-// Get databases from deployment mapping for a database group-const getDatabasesForGroup = (groupName: string): string[] => {- const deployment = plan.value.deployment;- if (!deployment) return [];- const mapping = deployment.databaseGroupMappings.find(- (m: { databaseGroup: string }) => m.databaseGroup === groupName- );- return mapping?.databases ?? [];-};-const filteredTargets = computed(() => {if (!state.searchText) {return props.targets;@@ -131,20 +121,9 @@ const loadAllTargets = async () => {try {// Separate different types of targets for optimized fetching- const databaseTargets: string[] = [];- const dbGroupTargets: string[] = [];-- for (const target of props.targets) {- if (isValidDatabaseGroupName(target)) {- // If target is a valid database group name- dbGroupTargets.push(target);- // Also collect databases from deployment mapping for this group- const mappedDatabases = getDatabasesForGroup(target);- databaseTargets.push(...mappedDatabases);- } else if (isValidDatabaseName(target)) {- databaseTargets.push(target);- }- }+ const { databaseTargets, dbGroupTargets } = getDatabaseTargets(+ props.targets+ );// Batch fetch all targetsconst fetchPromises: Promise<any>[] = [];diff --git a/frontend/src/components/Plan/components/SpecDetailView/DataExportOptionsSection.vue b/frontend/src/components/Plan/components/SpecDetailView/DataExportOptionsSection.vueindex 6a86311563..1aa327f14e 100644--- a/frontend/src/components/Plan/components/SpecDetailView/DataExportOptionsSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/DataExportOptionsSection.vue@@ -32,7 +32,7 @@ import ExportPasswordInputer from "../ExportOption/ExportPasswordInputer.vue";import { useSelectedSpec } from "./context";const { isCreating } = usePlanContext();-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();const exportFormat = computed({get() {diff --git a/frontend/src/components/Plan/components/SpecDetailView/FailedTaskRunsSection.vue b/frontend/src/components/Plan/components/SpecDetailView/FailedTaskRunsSection.vueindex b7d410bbc2..8c21fcdd7e 100644--- a/frontend/src/components/Plan/components/SpecDetailView/FailedTaskRunsSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/FailedTaskRunsSection.vue@@ -84,7 +84,7 @@ const { t } = useI18n();const router = useRouter();const { project } = useCurrentProjectV1();const { rollout, taskRuns } = usePlanContextWithRollout();-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();const databaseStore = useDatabaseV1Store();const taskRunLogStore = useTaskRunLogStore();diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vueindex 539f6e29d0..6a40db4d72 100644--- a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue@@ -49,7 +49,7 @@ import TargetListSection from "./TargetListSection.vue";const { project } = useCurrentProjectV1();const { isCreating, plan, issue, rollout } = usePlanContext();-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();providePlanSQLCheckContext({project,diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vueindex e912d9d0d0..557d078b13 100644--- a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue@@ -97,7 +97,7 @@ const dialog = useDialog();const { t } = useI18n();const { plan, isCreating } = usePlanContext();const sheetStore = useSheetV1Store();-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();const { project } = useCurrentProjectV1();const { isSpecEmpty } = useSpecsValidation(computed(() => plan.value.specs));const { setEditingState } = useEditorState();diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vueindex a8463a81a4..af60f1b810 100644--- a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue@@ -97,15 +97,13 @@ import { extractProjectResourceName } from "@/utils";import { usePlanContext } from "../../logic/context";import DatabaseDisplay from "../common/DatabaseDisplay.vue";import AllTargetsDrawer from "./AllTargetsDrawer.vue";-import { useSelectedSpec } from "./context";+import { DEFAULT_VISIBLE_TARGETS, useSelectedSpec } from "./context";import DatabaseGroupTargetDisplay from "./DatabaseGroupTargetDisplay.vue";import TargetsSelectorDrawer from "./TargetsSelectorDrawer.vue";-const DEFAULT_VISIBLE_TARGETS = 20;-const { t } = useI18n();const { plan, isCreating, readonly } = usePlanContext();-const selectedSpec = useSelectedSpec();+const { selectedSpec, targets, getDatabaseTargets } = useSelectedSpec();const dbGroupStore = useDBGroupStore();const projectStore = useProjectV1Store();@@ -113,27 +111,6 @@ const isLoadingTargets = ref(false);const showTargetsSelector = ref(false);const showAllTargetsDrawer = ref(false);-const targets = computed(() => {- if (!selectedSpec.value) return [];- if (- selectedSpec.value.config.case === "changeDatabaseConfig" ||- selectedSpec.value.config.case === "exportDataConfig"- ) {- return selectedSpec.value.config.value.targets;- }- return [];-});--// Get databases from deployment mapping for a database group-const getDatabasesForGroup = (groupName: string): string[] => {- const deployment = plan.value.deployment;- if (!deployment) return [];- const mapping = deployment.databaseGroupMappings.find(- (m: { databaseGroup: string }) => m.databaseGroup === groupName- );- return mapping?.databases ?? [];-};-const project = computed(() => {if (!plan.value?.name) return undefined;const projectName = `${projectNamePrefix}${extractProjectResourceName(plan.value.name)}`;@@ -191,20 +168,9 @@ const loadTargetData = async () => {try {// Fetch data for visible targets only- const visibleTargets = targets.value.slice(0, DEFAULT_VISIBLE_TARGETS);- const databaseTargets: string[] = [];- const dbGroupTargets: string[] = [];-- for (const target of visibleTargets) {- if (isValidDatabaseGroupName(target)) {- dbGroupTargets.push(target);- // Also collect databases from deployment mapping for this group- const mappedDatabases = getDatabasesForGroup(target);- databaseTargets.push(...mappedDatabases);- } else {- databaseTargets.push(target);- }- }+ const { databaseTargets, dbGroupTargets } = getDatabaseTargets(+ visibleTargets.value+ );if (databaseTargets.length > 0) {await batchGetOrFetchDatabases(databaseTargets);diff --git a/frontend/src/components/Plan/components/SpecDetailView/context.ts b/frontend/src/components/Plan/components/SpecDetailView/context.tsindex 7d2bd195f2..c396c0b1d5 100644--- a/frontend/src/components/Plan/components/SpecDetailView/context.ts+++ b/frontend/src/components/Plan/components/SpecDetailView/context.ts@@ -1,8 +1,11 @@-import { head } from "lodash-es";+import { head, uniq } from "lodash-es";import { computed } from "vue";import { useRoute } from "vue-router";+import { isValidDatabaseGroupName } from "@/types";import { usePlanContext } from "../../logic";+export const DEFAULT_VISIBLE_TARGETS = 20;+export const useSelectedSpec = () => {const route = useRoute();const { plan } = usePlanContext();@@ -36,5 +39,45 @@ export const useSelectedSpec = () => {return foundSpec;});- return selectedSpec;+ const targets = computed(() => {+ if (!selectedSpec.value) return [];+ if (+ selectedSpec.value.config.case === "changeDatabaseConfig" ||+ selectedSpec.value.config.case === "exportDataConfig"+ ) {+ return selectedSpec.value.config.value.targets;+ }+ return [];+ });++ const getDatabasesForGroup = (groupName: string): string[] => {+ const deployment = plan.value.deployment;+ if (!deployment) return [];+ const mapping = deployment.databaseGroupMappings.find(+ (m: { databaseGroup: string }) => m.databaseGroup === groupName+ );+ return mapping?.databases ?? [];+ };++ const getDatabaseTargets = (+ targets: string[]+ ): { databaseTargets: string[]; dbGroupTargets: string[] } => {+ const databaseTargets: string[] = [];+ const dbGroupTargets: string[] = [];++ for (const target of targets) {+ if (isValidDatabaseGroupName(target)) {+ dbGroupTargets.push(target);+ // Also collect databases from deployment mapping for this group+ const mappedDatabases = getDatabasesForGroup(target);+ databaseTargets.push(...mappedDatabases);+ } else {+ databaseTargets.push(target);+ }+ }++ return { databaseTargets: uniq(databaseTargets), dbGroupTargets };+ };++ return { selectedSpec, targets, getDatabaseTargets };};diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vueindex 51f9b4a453..a9da057490 100644--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue@@ -22,7 +22,7 @@{{ $t("issue.upload-sql") }}</SQLUploadButton><NButton- v-if="shouldShowSchemaEditorButton"+ v-if="shouldShowSchemaEditorButton && targetDatabaseNames.length > 0"size="small"@click="handleOpenSchemaEditor">@@ -184,7 +184,7 @@<SchemaEditorDrawerv-if="shouldShowSchemaEditorButton"v-model:show="state.showSchemaEditorDrawer"- :databases="targetDatabases"+ :databaseNames="targetDatabaseNames":project="project"@insert="handleInsertSQL"/>@@ -221,7 +221,7 @@ import {useSheetV1Store,} from "@/store";import type { SQLDialect } from "@/types";-import { dialectOfEngineV1 } from "@/types";+import { dialectOfEngineV1, isValidDatabaseGroupName } from "@/types";import { UpdatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";import { SheetSchema } from "@/types/proto-es/v1/sheet_service_pb";@@ -249,7 +249,7 @@ const dialog = useDialog();const { project } = useCurrentProjectV1();const { isCreating, plan, planCheckRuns, rollout, events, readonly } =usePlanContext();-const selectedSpec = useSelectedSpec();+const { selectedSpec, getDatabaseTargets, targets } = useSelectedSpec();const editorState = useEditorState();const state = reactive<LocalState>({@@ -402,29 +402,17 @@ const shouldShowSchemaEditorButton = computed(() => {// Check if at least one target database supports schema editorconst databaseStore = useDatabaseV1Store();- const hasSupported = targets.some((targetName) => {+ return targets.some((targetName) => {+ if (isValidDatabaseGroupName(targetName)) {+ return false;+ }const db = databaseStore.getDatabaseByName(targetName);return engineSupportsSchemaEditor(db.instanceResource.engine);});-- if (!hasSupported) {- return false;- }-- return true;});-const targetDatabases = computed(() => {- const spec = selectedSpec.value;- if (!spec?.config || spec.config.case !== "changeDatabaseConfig") {- return [];- }-- const databaseStore = useDatabaseV1Store();- const targets = spec.config.value.targets || [];- return targets- .map((targetName) => databaseStore.getDatabaseByName(targetName))- .filter((db) => engineSupportsSchemaEditor(db.instanceResource.engine));+const targetDatabaseNames = computed(() => {+ return getDatabaseTargets(targets.value).databaseTargets;});const beginEdit = () => {diff --git a/frontend/src/components/Plan/components/StatementSection/ReleaseView/ReleaseView.vue b/frontend/src/components/Plan/components/StatementSection/ReleaseView/ReleaseView.vueindex a73c3e74cd..f83d89b0ef 100644--- a/frontend/src/components/Plan/components/StatementSection/ReleaseView/ReleaseView.vue+++ b/frontend/src/components/Plan/components/StatementSection/ReleaseView/ReleaseView.vue@@ -166,7 +166,7 @@ import { Release_File_Type } from "@/types/proto-es/v1/release_service_pb";import { useSelectedSpec } from "../../SpecDetailView/context";const { t } = useI18n();-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();const releaseName = computed(() => {if (selectedSpec.value?.config?.case === "changeDatabaseConfig") {diff --git a/frontend/src/components/Plan/components/StatementSection/SchemaEditorDrawer.vue b/frontend/src/components/Plan/components/StatementSection/SchemaEditorDrawer.vueindex 9069a81cf9..bafa20896c 100644--- a/frontend/src/components/Plan/components/StatementSection/SchemaEditorDrawer.vue+++ b/frontend/src/components/Plan/components/StatementSection/SchemaEditorDrawer.vue@@ -6,16 +6,27 @@><div class="flex flex-col gap-y-4 h-full"><!-- Database selector for multi-database scenarios -->- <div v-if="databases.length > 1" class="flex items-center gap-x-2">+ <div v-if="databaseNames.length > 1" class="flex items-center gap-x-2"><span class="text-sm text-control-light">{{ $t("schema-editor.template-database") }}:</span><NSelect- v-model:value="state.selectedDatabaseName"+ :value="state.selectedDatabaseName":options="databaseOptions"+ :disabled="state.isPreparingMetadata"class="w-64"@update:value="handleDatabaseChange"- />+ >+ <template #action>+ <NButton+ class="w-full!"+ quaternary+ :loading="state.isLoadingNextPage"+ @click="onNextPage">+ {{ $t("common.load-more") }}+ </NButton>+ </template>+ </NSelect></div><SchemaEditorLite@@ -46,6 +57,7 @@</template><script lang="ts" setup>+import { watchDebounced } from "@vueuse/core";import { cloneDeep } from "lodash-es";import { NButton, NSelect } from "naive-ui";import { computed, reactive, ref, watch } from "vue";@@ -54,13 +66,19 @@ import SchemaEditorLite, {generateDiffDDL,} from "@/components/SchemaEditorLite";import { Drawer, DrawerContent } from "@/components/v2";-import { useDBSchemaV1Store } from "@/store";-import type { ComposedDatabase } from "@/types";+import {+ batchGetOrFetchDatabases,+ useDatabaseV1Store,+ useDBSchemaV1Store,+} from "@/store";+import { DEBOUNCE_SEARCH_DELAY } from "@/types";import type { Project } from "@/types/proto-es/v1/project_service_pb";+import { engineSupportsSchemaEditor } from "@/utils/schemaEditor";+import { DEFAULT_VISIBLE_TARGETS } from "../SpecDetailView/context";const props = defineProps<{show: boolean;- databases: ComposedDatabase[];+ databaseNames: string[];project: Project;}>();@@ -76,25 +94,58 @@ const show = computed({const schemaEditorRef = ref<InstanceType<typeof SchemaEditorLite>>();const dbSchemaStore = useDBSchemaV1Store();+const databaseStore = useDatabaseV1Store();const state = reactive({isPreparingMetadata: false,+ isLoadingNextPage: false,targets: [] as EditTarget[],selectedDatabaseName: "",+ databaseSelectorPageIndex: 0,});-const databaseOptions = computed(() => {- return props.databases.map((db) => ({- label: `${db.databaseName} (${db.instanceResource.title})`,- value: db.name,- }));-});+const onNextPage = () => {+ state.isLoadingNextPage = true;+ state.databaseSelectorPageIndex++;+};++watchDebounced(+ () => state.databaseSelectorPageIndex,+ async (index) => {+ try {+ await batchGetOrFetchDatabases(+ props.databaseNames.slice(+ DEFAULT_VISIBLE_TARGETS * index,+ DEFAULT_VISIBLE_TARGETS * (index + 1)+ )+ );+ } catch {+ // fallback to previous page.+ state.databaseSelectorPageIndex = Math.max(0, index - 1);+ } finally {+ state.isLoadingNextPage = false;+ }+ },+ { immediate: true, debounce: DEBOUNCE_SEARCH_DELAY }+);-const selectedDatabase = computed(() => {- return (- props.databases.find((db) => db.name === state.selectedDatabaseName) ||- props.databases[0]+const databaseOptions = computed(() => {+ const pageIndex = Math.max(+ 0,+ state.isLoadingNextPage+ ? state.databaseSelectorPageIndex - 1+ : state.databaseSelectorPageIndex);+ return props.databaseNames+ .slice(0, DEFAULT_VISIBLE_TARGETS * (pageIndex + 1))+ .map((dbName) => {+ const db = databaseStore.getDatabaseByName(dbName);+ return {+ label: `${db.databaseName} (${db.instanceResource.title})`,+ value: db.name,+ disabled: !engineSupportsSchemaEditor(db.instanceResource.engine),+ };+ });});const editTargets = computed(() => state.targets);@@ -103,17 +154,20 @@ const hasPendingChanges = computed(() => {return schemaEditorRef.value?.isDirty ?? false;});-const prepareDatabaseMetadata = async (database: ComposedDatabase) => {- if (!database) return;+const prepareDatabaseMetadata = async (databaseName: string) => {+ if (!databaseName) return;state.isPreparingMetadata = true;state.targets = [];- const metadata = await dbSchemaStore.getOrFetchDatabaseMetadata({- database: database.name,- skipCache: true,- limit: 200,- });+ const [metadata, database] = await Promise.all([+ dbSchemaStore.getOrFetchDatabaseMetadata({+ database: databaseName,+ skipCache: true,+ limit: 200,+ }),+ databaseStore.getOrFetchDatabaseByName(databaseName),+ ]);state.targets = [{@@ -126,19 +180,19 @@ const prepareDatabaseMetadata = async (database: ComposedDatabase) => {state.isPreparingMetadata = false;};-const handleDatabaseChange = async () => {- if (selectedDatabase.value) {- await prepareDatabaseMetadata(selectedDatabase.value);+const handleDatabaseChange = async (selectedDatabaseName: string) => {+ if (selectedDatabaseName) {+ await prepareDatabaseMetadata(selectedDatabaseName);}+ state.selectedDatabaseName = selectedDatabaseName;};watch(() => props.show,(show) => {- if (show && props.databases.length > 0) {+ if (show && props.databaseNames.length > 0) {// Initialize with first database- state.selectedDatabaseName = props.databases[0].name;- prepareDatabaseMetadata(props.databases[0]);+ handleDatabaseChange(props.databaseNames[0]);}},{ immediate: true }diff --git a/frontend/src/components/Plan/components/StatementSection/StatementSection.vue b/frontend/src/components/Plan/components/StatementSection/StatementSection.vueindex 41a3ce6520..698bbb4db1 100644--- a/frontend/src/components/Plan/components/StatementSection/StatementSection.vue+++ b/frontend/src/components/Plan/components/StatementSection/StatementSection.vue@@ -12,7 +12,7 @@ import { useSelectedSpec } from "../SpecDetailView/context";import EditorView from "./EditorView";import ReleaseView from "./ReleaseView";-const selectedSpec = useSelectedSpec();+const { selectedSpec } = useSelectedSpec();const viewMode = computed((): "NONE" | "EDITOR" | "RELEASE" => {if (selectedSpec.value) {diff --git a/frontend/src/components/Plan/logic/base.ts b/frontend/src/components/Plan/logic/base.tsindex b24f32b558..f331c1a385 100644--- a/frontend/src/components/Plan/logic/base.ts+++ b/frontend/src/components/Plan/logic/base.ts@@ -1,5 +1,5 @@import Emittery from "emittery";-import { computed } from "vue";+import { type ComputedRef, computed } from "vue";import { State } from "@/types/proto-es/v1/common_pb";import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";import type { PlanContext, PlanEvents } from "./context";@@ -7,10 +7,10 @@ import type { PlanContext, PlanEvents } from "./context";export const useBasePlanContext = ({plan,issue,-}: Pick<- PlanContext,- "isCreating" | "plan" | "issue"->): Partial<PlanContext> => {+}: Pick<PlanContext, "isCreating" | "plan" | "issue">): {+ readonly: ComputedRef<boolean>;+ events: PlanEvents;+} => {const events: PlanEvents = new Emittery();const readonly = computed(() => {diff --git a/frontend/src/components/Plan/logic/context.ts b/frontend/src/components/Plan/logic/context.tsindex bcba0243ca..14bb182200 100644--- a/frontend/src/components/Plan/logic/context.ts+++ b/frontend/src/components/Plan/logic/context.ts@@ -72,7 +72,7 @@ export const usePlanContextWithRollout = () => {};};-export const providePlanContext = (context: Partial<PlanContext>) => {+export const providePlanContext = (context: PlanContext) => {provide(KEY, context as PlanContext);return context as PlanContext;};