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: optimize expr select with remote fetch (#15686)
ecmadao8b32b2808358
diff --git a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts b/frontend/src/components/CustomApproval/Settings/components/common/utils.tsindex c7dbb88c12..ccf09308e3 100644--- a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts+++ b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts@@ -268,7 +268,7 @@ export const getOptionConfigMap = (source: Risk_Source) => {const projectStore = useProjectV1Store();map.set(factor, {remote: true,- options: getProjectIdOptions(projectStore.getProjectList()),+ options: [],search: async (keyword: string) => {return projectStore.fetchProjectList({diff --git a/frontend/src/components/ExprEditor/components/MultiSelect.vue b/frontend/src/components/ExprEditor/components/MultiSelect.vueindex f032ba27e7..3aa12188a1 100644--- a/frontend/src/components/ExprEditor/components/MultiSelect.vue+++ b/frontend/src/components/ExprEditor/components/MultiSelect.vue@@ -33,7 +33,7 @@ import type { SelectOption } from "naive-ui";import { toRef, watch, reactive, computed, watchEffect } from "vue";import { type ConditionExpr } from "@/plugins/cel";import { useExprEditorContext } from "../context";-import { useSelectOptions } from "./common";+import { useSelectOptionConfig } from "./common";interface LocalState {loading: boolean;@@ -56,7 +56,7 @@ const state = reactive<LocalState>({rawOptionList: [],});-const optionConfig = useSelectOptions(toRef(props, "expr"));+const { optionConfig, factor } = useSelectOptionConfig(toRef(props, "expr"));watchEffect(() => {state.rawOptionList = [...optionConfig.value.options];@@ -88,7 +88,7 @@ const toggleCheckAll = (on: boolean) => {};watch(- [state.rawOptionList, () => props.value],+ [() => state.rawOptionList, () => props.value],() => {const values = new Set(state.rawOptionList.map((opt) => opt.value));const filtered = (props.value as any[]).filter((v) => values.has(v));@@ -101,7 +101,7 @@ watch();const handleSearch = useDebounceFn(async (search: string) => {- if (!search || !optionConfig.value.search) {+ if (!optionConfig.value.search) {state.rawOptionList = [...optionConfig.value.options];return;}@@ -113,5 +113,11 @@ const handleSearch = useDebounceFn(async (search: string) => {} finally {state.loading = false;}-}, 500);+}, 200);++watch(+ () => factor.value,+ () => handleSearch(""),+ { immediate: true }+);</script>diff --git a/frontend/src/components/ExprEditor/components/SingleSelect.vue b/frontend/src/components/ExprEditor/components/SingleSelect.vueindex 6f31f2eeaa..522e0617bd 100644--- a/frontend/src/components/ExprEditor/components/SingleSelect.vue+++ b/frontend/src/components/ExprEditor/components/SingleSelect.vue@@ -19,10 +19,10 @@import { useDebounceFn } from "@vueuse/core";import { NSelect } from "naive-ui";import type { SelectOption } from "naive-ui";-import { toRef, watch, reactive, watchEffect } from "vue";+import { toRef, watch, reactive } from "vue";import { type ConditionExpr } from "@/plugins/cel";import { useExprEditorContext } from "../context";-import { useSelectOptions } from "./common";+import { useSelectOptionConfig } from "./common";interface LocalState {loading: boolean;@@ -45,17 +45,16 @@ const state = reactive<LocalState>({rawOptionList: [],});-const optionConfig = useSelectOptions(toRef(props, "expr"));--watchEffect(() => {- state.rawOptionList = [...optionConfig.value.options];-});+const { optionConfig, factor } = useSelectOptionConfig(toRef(props, "expr"));watch(- [state.rawOptionList, () => props.value],+ [() => state.rawOptionList, () => props.value],() => {if (state.rawOptionList.length === 0) return;- if (!state.rawOptionList.find((opt) => opt.value === props.value)) {+ if (+ !props.value ||+ !state.rawOptionList.find((opt) => opt.value === props.value)+ ) {emit("update:value", state.rawOptionList[0].value!);}},@@ -63,7 +62,7 @@ watch();const handleSearch = useDebounceFn(async (search: string) => {- if (!search || !optionConfig.value.search) {+ if (!optionConfig.value.search) {state.rawOptionList = [...optionConfig.value.options];return;}@@ -75,5 +74,11 @@ const handleSearch = useDebounceFn(async (search: string) => {} finally {state.loading = false;}-}, 500);+}, 200);++watch(+ () => factor.value,+ () => handleSearch(""),+ { immediate: true }+);</script>diff --git a/frontend/src/components/ExprEditor/components/common.ts b/frontend/src/components/ExprEditor/components/common.tsindex f7f2b0987b..4e20118a02 100644--- a/frontend/src/components/ExprEditor/components/common.ts+++ b/frontend/src/components/ExprEditor/components/common.ts@@ -9,18 +9,24 @@ import {import { t, te } from "@/plugins/i18n";import { useExprEditorContext, type OptionConfig } from "../context";-export const useSelectOptions = (+export const useSelectOptionConfig = (expr: Ref<ConditionExpr>-): ComputedRef<OptionConfig> => {+): {+ optionConfig: ComputedRef<OptionConfig>;+ factor: ComputedRef<string>;+} => {const context = useExprEditorContext();const { optionConfigMap } = context;- const options = computed(() => {- const factor = expr.value.args[0];- return optionConfigMap.value.get(factor) || { remote: false, options: [] };+ const factor = computed(() => expr.value.args[0]);++ const optionConfig = computed(() => {+ return (+ optionConfigMap.value.get(factor.value) || { remote: false, options: [] }+ );});- return options;+ return { optionConfig, factor };};const stringifyFactor = (factor: Factor) => {diff --git a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vueindex 00e37ba7bd..4b2b36cf37 100644--- a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue+++ b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue@@ -363,7 +363,7 @@ const factorOptionsMap = computed((): Map<Factor, OptionConfig> => {const projectStore = useProjectV1Store();map.set(factor, {remote: true,- options: getProjectIdOptions(projectStore.getProjectList()),+ options: [],search: async (keyword: string) => {return projectStore.fetchProjectList({