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: expr editor intial value (#13202)
boojack9ed5132980b0
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskForm.vue b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskForm.vueindex d1eb0697f9..b5ed5b4190 100644--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskForm.vue+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskForm.vue@@ -90,23 +90,21 @@</template><script lang="ts" setup>-import { cloneDeep } from "lodash-es";+import { cloneDeep, head } from "lodash-es";import { NButton, NInput } from "naive-ui";import { computed, ref, watch } from "vue";import ExprEditor from "@/components/ExprEditor";import LearnMoreLink from "@/components/LearnMoreLink.vue";-import type { ConditionGroupExpr } from "@/plugins/cel";+import type { ConditionGroupExpr, SimpleExpr } from "@/plugins/cel";import {resolveCELExpr,buildCELExpr,wrapAsGroup,validateSimpleExpr,+ emptySimpleExpr,} from "@/plugins/cel";import { useCurrentUserV1 } from "@/store";-import {- Expr as CELExpr,- ParsedExpr,-} from "@/types/proto/google/api/expr/v1alpha1/syntax";+import { ParsedExpr } from "@/types/proto/google/api/expr/v1alpha1/syntax";import { Expr } from "@/types/proto/google/type/expr";import { Risk } from "@/types/proto/v1/risk_service";import {@@ -145,24 +143,27 @@ const currentUser = useCurrentUserV1();const state = ref<LocalState>({risk: Risk.fromPartial({}),- expr: wrapAsGroup(resolveCELExpr(CELExpr.fromPartial({}))),+ expr: wrapAsGroup(emptySimpleExpr()),});const mode = computed(() => context.dialog.value?.mode ?? "CREATE");const resolveLocalState = async () => {const risk = cloneDeep(context.dialog.value!.risk);- let expr = CELExpr.fromPartial({});+ let expr: SimpleExpr = emptySimpleExpr();if (risk.condition?.expression) {const parsedExprs = await batchConvertCELStringToParsedExpr([risk.condition.expression,]);- expr = parsedExprs[0].expr ?? CELExpr.fromPartial({});+ const celExpr = head(parsedExprs)?.expr;+ if (celExpr) {+ expr = resolveCELExpr(celExpr);+ }}state.value = {risk,- expr: wrapAsGroup(resolveCELExpr(expr)),+ expr: wrapAsGroup(expr),};};diff --git a/frontend/src/components/ExprEditor/ConditionGroup.vue b/frontend/src/components/ExprEditor/ConditionGroup.vueindex 9311b74c6f..d07b862995 100644--- a/frontend/src/components/ExprEditor/ConditionGroup.vue+++ b/frontend/src/components/ExprEditor/ConditionGroup.vue@@ -75,7 +75,7 @@@update="$emit('update')"/><RawString- v-if="enableRawExpression && isRawStringExpr(operand)"+ v-if="isRawStringExpr(operand)":expr="operand"@remove="removeRawString(operand)"@update="$emit('update')"@@ -144,6 +144,10 @@ import {isRawStringExpr,ExprType,type RawStringExpr,+ isNumberFactor,+ type Factor,+ isStringFactor,+ isTimestampFactor,} from "@/plugins/cel";import Condition from "./Condition.vue";import RawString from "./RawString.vue";@@ -198,7 +202,7 @@ const addCondition = () => {args.value.push({type: ExprType.Condition,operator: operators[0] ?? "",- args: [factor, ""],+ args: [factor, getDefaultValue(factor)],} as any);emit("update");};@@ -243,4 +247,12 @@ const removeRawString = (rawString: RawStringExpr) => {emit("update");}};++const getDefaultValue = (factor: Factor): any => {+ if (isNumberFactor(factor)) return 0;+ if (isStringFactor(factor)) return "";+ if (isTimestampFactor(factor)) return new Date();+ // Fall back to empty string.+ return "";+};</script>diff --git a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vueindex 1f60374daf..2b54f6cdda 100644--- a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue+++ b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue@@ -81,23 +81,22 @@</template><script lang="ts" setup>+import { head } from "lodash-es";import { TrashIcon } from "lucide-vue-next";import type { SelectOption } from "naive-ui";import { NSelect, NPopconfirm, NInput, NButton } from "naive-ui";import { computed, reactive, onMounted, nextTick } from "vue";import { useI18n } from "vue-i18n";import ExprEditor from "@/components/ExprEditor";-import type { ConditionGroupExpr, Factor } from "@/plugins/cel";+import type { ConditionGroupExpr, Factor, SimpleExpr } from "@/plugins/cel";import {resolveCELExpr,wrapAsGroup,buildCELExpr,validateSimpleExpr,+ emptySimpleExpr,} from "@/plugins/cel";-import {- Expr as CELExpr,- ParsedExpr,-} from "@/types/proto/google/api/expr/v1alpha1/syntax";+import { ParsedExpr } from "@/types/proto/google/api/expr/v1alpha1/syntax";import { Expr } from "@/types/proto/google/type/expr";import { MaskingLevel, maskingLevelToJSON } from "@/types/proto/v1/common";import type { MaskingRulePolicy_MaskingRule } from "@/types/proto/v1/org_policy_service";@@ -133,23 +132,26 @@ type LocalState = {const { t } = useI18n();const state = reactive<LocalState>({title: "",- expr: wrapAsGroup(resolveCELExpr(CELExpr.fromJSON({}))),+ expr: wrapAsGroup(emptySimpleExpr()),maskingLevel: MaskingLevel.FULL,dirty: false,});const resetLocalState = async (rule: MaskingRulePolicy_MaskingRule) => {- let expr = CELExpr.fromJSON({});+ let expr: SimpleExpr = emptySimpleExpr();if (rule.condition?.expression) {const parsedExprs = await batchConvertCELStringToParsedExpr([rule.condition.expression,]);- expr = parsedExprs[0].expr ?? CELExpr.fromJSON({});+ const celExpr = head(parsedExprs)?.expr;+ if (celExpr) {+ expr = resolveCELExpr(celExpr);+ }}state.dirty = false;state.title = rule.condition?.title ?? "";- state.expr = wrapAsGroup(resolveCELExpr(expr));+ state.expr = wrapAsGroup(expr);state.maskingLevel = rule.maskingLevel;};