Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: improve plan spec validation reactivity and auto-enable editing (#17269)
boojack0dc84a21c6ce
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vueindex e7fd566f31..a2dd2224b7 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue@@ -91,7 +91,7 @@ const policyV1Store = usePolicyV1Store();const editorState = useEditorState();// Use the validation hook for all specs-const { isSpecEmpty } = useSpecsValidation(plan.value.specs);+const { isSpecEmpty } = useSpecsValidation(computed(() => plan.value.specs));// Use plan check status for issue creation validationconst {diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vueindex 24592a99ea..064faf4d45 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue@@ -55,7 +55,7 @@ const sheetStore = useSheetV1Store();const loading = ref(false);// Use the validation hook for all specs-const { isSpecEmpty } = useSpecsValidation(plan.value.specs);+const { isSpecEmpty } = useSpecsValidation(computed(() => plan.value.specs));const planCreateErrorList = computed(() => {const errorList: string[] = [];diff --git a/frontend/src/components/Plan/components/HeaderSection/HeaderSection.vue b/frontend/src/components/Plan/components/HeaderSection/HeaderSection.vueindex 4103616203..615ea84655 100644--- a/frontend/src/components/Plan/components/HeaderSection/HeaderSection.vue+++ b/frontend/src/components/Plan/components/HeaderSection/HeaderSection.vue@@ -13,7 +13,7 @@</div></div><div v-if="showDescriptionInput" class="flex flex-col mt-2">- <label class="block text-sm text-control mb-1">+ <label class="block text-sm text-control-light mb-1">{{ $t("plan.description.add-a-description") }}</label><DescriptionInput />diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vueindex fd69aab15f..b08bac6f9e 100644--- a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue@@ -69,7 +69,7 @@import { create } from "@bufbuild/protobuf";import { PlusIcon, XIcon } from "lucide-vue-next";import { NTabs, NTab, NButton, useDialog, NTooltip } from "naive-ui";-import { ref, computed } from "vue";+import { ref, computed, nextTick } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import { planServiceClientConnect } from "@/grpcweb";@@ -78,6 +78,7 @@ import { pushNotification } from "@/store";import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";import { UpdatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";import { usePlanContext } from "../../logic/context";+import { useEditorState } from "../../logic/useEditorState";import { getSpecTitle } from "../../logic/utils";import AddSpecDrawer from "../AddSpecDrawer.vue";import { useSpecsValidation } from "../common";@@ -88,7 +89,8 @@ const dialog = useDialog();const { t } = useI18n();const { plan, isCreating } = usePlanContext();const selectedSpec = useSelectedSpec();-const { isSpecEmpty } = useSpecsValidation(plan.value.specs);+const { isSpecEmpty } = useSpecsValidation(computed(() => plan.value.specs));+const { setEditingState } = useEditorState();const showAddSpecDrawer = ref(false);@@ -139,19 +141,29 @@ const handleSpecCreated = async (spec: Plan_Spec) => {}}- gotoSpec(spec.id);+ gotoSpec(spec.id, true); // Auto-enable editing for new specs};-const gotoSpec = (specId: string) => {+const gotoSpec = (specId: string, enableEditing = false) => {const currentRoute = router.currentRoute.value;- router.push({- name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,- params: {- ...(currentRoute.params || {}),- specId,- },- query: currentRoute.query || {},- });+ router+ .push({+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,+ params: {+ ...(currentRoute.params || {}),+ specId,+ },+ query: currentRoute.query || {},+ })+ .then(() => {+ // Enable editing mode if requested (for newly created specs)+ if (enableEditing) {+ // Use nextTick to ensure the route navigation completes first+ nextTick(() => {+ setEditingState(true);+ });+ }+ });};const handleDeleteSpec = (spec: Plan_Spec) => {diff --git a/frontend/src/components/Plan/components/common/validateSpec.ts b/frontend/src/components/Plan/components/common/validateSpec.tsindex bbadaf9bbf..dd75b2a30d 100644--- a/frontend/src/components/Plan/components/common/validateSpec.ts+++ b/frontend/src/components/Plan/components/common/validateSpec.ts@@ -1,11 +1,11 @@-import { ref, watchEffect } from "vue";+import { ref, watchEffect, type Ref, unref } from "vue";import { getLocalSheetByName } from "@/components/Plan";import { useSheetV1Store } from "@/store";import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";import { extractSheetUID, getSheetStatement, sheetNameOfSpec } from "@/utils";// Hook to validate all specs in a plan-export const useSpecsValidation = (specs: Plan_Spec[]) => {+export const useSpecsValidation = (specs: Plan_Spec[] | Ref<Plan_Spec[]>) => {const sheetStore = useSheetV1Store();const validationMap = ref(new Map<string, boolean>());@@ -43,11 +43,12 @@ export const useSpecsValidation = (specs: Plan_Spec[]) => {};watchEffect(async () => {+ const currentSpecs = unref(specs);const newMap = new Map<string, boolean>();// Check all specsawait Promise.all(- specs.map(async (spec) => {+ currentSpecs.map(async (spec) => {const isEmpty = await checkSpecStatement(spec);newMap.set(spec.id, isEmpty);})