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: show rule payload (#12793)
ecmadao89ee9eb37e80
diff --git a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vueindex aacd59fb34..8ff2d20c83 100644--- a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue+++ b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue@@ -218,7 +218,6 @@<SQLRuleEditDialogv-if="state.activeRule"- :editable="false":rule="state.activeRule":disabled="true"@cancel="state.activeRule = undefined"diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vueindex 7a943b293e..39939170b3 100644--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue@@ -96,7 +96,6 @@<SQLRuleEditDialogv-if="state.activeRule"- :editable="false":rule="state.activeRule":disabled="true"@cancel="state.activeRule = undefined"diff --git a/frontend/src/components/SQLReview/components/RuleConfigComponents/BooleanComponent.vue b/frontend/src/components/SQLReview/components/RuleConfigComponents/BooleanComponent.vueindex 17ee0c1505..904d57ab25 100644--- a/frontend/src/components/SQLReview/components/RuleConfigComponents/BooleanComponent.vue+++ b/frontend/src/components/SQLReview/components/RuleConfigComponents/BooleanComponent.vue@@ -9,13 +9,10 @@<script lang="ts" setup>import { NCheckbox } from "naive-ui";-import { computed } from "vue";-import { useI18n } from "vue-i18n";-import type { RuleConfigComponent, RuleTemplateV2 } from "@/types";-import { getRuleLocalizationKey } from "@/types/sqlReview";+import type { RuleConfigComponent } from "@/types";-const props = defineProps<{- rule: RuleTemplateV2;+defineProps<{+ title: string;config: RuleConfigComponent;value: boolean;disabled: boolean;@@ -24,14 +21,4 @@ const props = defineProps<{defineEmits<{(event: "update:value", value: boolean): void;}>();--const { t } = useI18n();--const title = computed(() => {- const { rule, config } = props;- const key = `sql-review.rule.${getRuleLocalizationKey(rule.type)}.component.${- config.key- }.title`;- return t(key);-});</script>diff --git a/frontend/src/components/SQLReview/components/RuleConfigComponents/RuleConfig.vue b/frontend/src/components/SQLReview/components/RuleConfigComponents/RuleConfig.vuenew file mode 100644index 0000000000..f053a606fc--- /dev/null+++ b/frontend/src/components/SQLReview/components/RuleConfigComponents/RuleConfig.vue@@ -0,0 +1,92 @@+<template>+ <div class="space-y-4">+ <div+ v-for="(config, index) in rule.componentList"+ :key="index"+ class="space-y-1"+ >+ <p+ :class="[+ 'font-medium',+ size !== 'small' && 'text-lg text-control mb-2',+ ]"+ >+ {{ configTitle(config) }}+ </p>+ <StringComponent+ v-if="config.payload.type === 'STRING'"+ :value="payload[index] as string"+ :config="config"+ :disabled="disabled"+ @update:value="payload[index] = $event"+ />+ <NumberComponent+ v-if="config.payload.type === 'NUMBER'"+ :value="payload[index] as number"+ :config="config"+ :disabled="disabled"+ @update:value="payload[index] = $event"+ />+ <BooleanComponent+ v-else-if="config.payload.type == 'BOOLEAN'"+ :title="configTitle(config)"+ :value="payload[index] as boolean"+ :config="config"+ :disabled="disabled"+ @update:value="payload[index] = $event"+ />+ <StringArrayComponent+ v-else-if="+ config.payload.type == 'STRING_ARRAY' && Array.isArray(payload[index])+ "+ :value="payload[index] as string[]"+ :config="config"+ :disabled="disabled"+ @update:value="payload[index] = $event"+ />+ <TemplateComponent+ v-else-if="config.payload.type == 'TEMPLATE'"+ :rule-type="rule.type"+ :value="payload[index] as string"+ :config="config"+ :disabled="disabled"+ @update:value="payload[index] = $event"+ />+ </div>+ </div>+</template>++<script setup lang="ts">+import { ref, watch } from "vue";+import { useI18n } from "vue-i18n";+import type { RuleConfigComponent, RuleTemplateV2 } from "@/types/sqlReview";+import { getRuleLocalizationKey } from "@/types/sqlReview";+import type { PayloadValueType } from "./types";+import { getRulePayload } from "./utils";++const props = defineProps<{+ rule: RuleTemplateV2;+ disabled: boolean;+ size: "small" | "medium";+}>();++const { t } = useI18n();+const payload = ref<PayloadValueType[]>([]);++const configTitle = (config: RuleConfigComponent): string => {+ const key = `sql-review.rule.${getRuleLocalizationKey(+ props.rule.type+ )}.component.${config.key}.title`;+ return t(key);+};++watch(+ () => props.rule.componentList,+ () => (payload.value = getRulePayload(props.rule)),+ { immediate: true }+);++defineExpose({+ payload,+});+</script>diff --git a/frontend/src/components/SQLReview/components/RuleConfigComponents/StringArrayComponent.vue b/frontend/src/components/SQLReview/components/RuleConfigComponents/StringArrayComponent.vueindex d8605561dd..6f57116f84 100644--- a/frontend/src/components/SQLReview/components/RuleConfigComponents/StringArrayComponent.vue+++ b/frontend/src/components/SQLReview/components/RuleConfigComponents/StringArrayComponent.vue@@ -5,15 +5,14 @@v-for="(val, i) in value":key="i":text="`${val}`"- :can-remove="!disabled && editable"+ :can-remove="!disabled"@remove="remove(val)"/></div><BBTextField- v-if="editable"+ v-if="!disabled"v-model:value="inputValue"pattern="[a-z]+"- :disabled="disabled":placeholder="$t('sql-review.input-then-press-enter')"@keyup.enter="push($event)"/>@@ -28,7 +27,6 @@ const props = defineProps<{config: RuleConfigComponent;value: string[];disabled: boolean;- editable: boolean;}>();const emit = defineEmits<{diff --git a/frontend/src/components/SQLReview/components/RuleConfigComponents/TemplateComponent.vue b/frontend/src/components/SQLReview/components/RuleConfigComponents/TemplateComponent.vueindex 21ff3c4896..5622746069 100644--- a/frontend/src/components/SQLReview/components/RuleConfigComponents/TemplateComponent.vue+++ b/frontend/src/components/SQLReview/components/RuleConfigComponents/TemplateComponent.vue@@ -14,15 +14,11 @@ import {InputWithTemplate,type Template,} from "@/components/InputWithTemplate";-import type {- RuleConfigComponent,- RuleTemplateV2,- TemplatePayload,-} from "@/types";+import type { RuleConfigComponent, TemplatePayload } from "@/types";import { getRuleLocalizationKey } from "@/types";const props = defineProps<{- rule: RuleTemplateV2;+ ruleType: string;config: RuleConfigComponent;value: string;disabled: boolean;@@ -35,12 +31,12 @@ defineEmits<{const { t } = useI18n();const templateList = computed(() => {- const { rule, config } = props;+ const { ruleType, config } = props;const payload = config.payload as TemplatePayload;return payload.templateList.map<Template>((id) => ({id,description: t(- `sql-review.rule.${getRuleLocalizationKey(rule.type)}.component.${+ `sql-review.rule.${getRuleLocalizationKey(ruleType)}.component.${config.key}.template.${id}`),diff --git a/frontend/src/components/SQLReview/components/RuleConfigComponents/utils.ts b/frontend/src/components/SQLReview/components/RuleConfigComponents/utils.tsnew file mode 100644index 0000000000..878f1b58ca--- /dev/null+++ b/frontend/src/components/SQLReview/components/RuleConfigComponents/utils.ts@@ -0,0 +1,22 @@+import type { RuleTemplateV2 } from "@/types/sqlReview";+import type { PayloadValueType } from "./types";++export const getRulePayload = (rule: RuleTemplateV2): PayloadValueType[] => {+ const { componentList } = rule;++ if (componentList.length === 0) {+ return [];+ }++ const basePayload = componentList.reduce<+ { key: string; value: PayloadValueType }[]+ >((list, component) => {+ list.push({+ key: component.key,+ value: component.payload.value ?? component.payload.default,+ });+ return list;+ }, []);++ return basePayload.map((val) => val.value);+};diff --git a/frontend/src/components/SQLReview/components/SQLReviewAttachResourcesPanel.vue b/frontend/src/components/SQLReview/components/SQLReviewAttachResourcesPanel.vueindex 1c21e4099d..dea7269c43 100644--- a/frontend/src/components/SQLReview/components/SQLReviewAttachResourcesPanel.vue+++ b/frontend/src/components/SQLReview/components/SQLReviewAttachResourcesPanel.vue@@ -22,7 +22,9 @@:environment-names="environmentNames":multiple="true":render-suffix="getResourceAttachedConfigName"- @update:environment-names="onResourcesChange($event, projectNames)"+ @update:environment-names="+ onResourcesChange($event, environmentNames)+ "/></div><div class="flex items-center space-x-2">@@ -43,7 +45,7 @@:project-names="projectNames":multiple="true":render-suffix="getResourceAttachedConfigName"- @update:project-names="onResourcesChange($event, environmentNames)"+ @update:project-names="onResourcesChange($event, projectNames)"/></div></div>@@ -70,7 +72,12 @@import { NDivider } from "naive-ui";import { watch, ref, computed } from "vue";import { useI18n } from "vue-i18n";-import { Drawer, DrawerContent, EnvironmentSelect, ProjectSelect } from "@/components/v2";+import {+ Drawer,+ DrawerContent,+ EnvironmentSelect,+ ProjectSelect,+} from "@/components/v2";import { useSQLReviewStore, pushNotification, useCurrentUserV1 } from "@/store";import {environmentNamePrefix,diff --git a/frontend/src/components/SQLReview/components/SQLReviewCategoryTabFilter.vue b/frontend/src/components/SQLReview/components/SQLReviewCategoryTabFilter.vueindex 2751f4aedf..087c3d5b49 100644--- a/frontend/src/components/SQLReview/components/SQLReviewCategoryTabFilter.vue+++ b/frontend/src/components/SQLReview/components/SQLReviewCategoryTabFilter.vue@@ -1,14 +1,9 @@<template><NTabs- :value="state.selectedTab"+ :value="value":size="'small'":type="tabType"- @update:value="- (val: string) => {- state.selectedTab = val;- $emit('update:value', val == 'all' ? undefined : state.selectedTab);- }- "+ @update:value="$emit('update:value', $event)"><NTabPane v-for="data in tabItemList" :key="data.value" :name="data.value"><template #tab>@@ -26,7 +21,7 @@<script lang="ts" setup>import { useWindowSize } from "@vueuse/core";import { NTabs, NTabPane } from "naive-ui";-import { computed, reactive, watch } from "vue";+import { computed } from "vue";import { useI18n } from "vue-i18n";import type { RuleTemplateV2 } from "@/types";import { convertToCategoryMap } from "@/types";@@ -37,30 +32,17 @@ export interface RuleListWithCategory {ruleList: RuleTemplateV2[];}-interface LocalState {- selectedTab: string;-}--const props = withDefaults(- defineProps<{- value?: string;- ruleList: RuleTemplateV2[];- }>(),- {- value: undefined,- }-);+const props = defineProps<{+ value: string;+ ruleList: RuleTemplateV2[];+}>();defineEmits<{- (event: "update:value", value: string | undefined): void;+ (event: "update:value", value: string): void;}>();const { t } = useI18n();-const state = reactive<LocalState>({- selectedTab: "all",-});-const { width: winWidth } = useWindowSize();const tabType = computed(() => {@@ -70,13 +52,6 @@ const tabType = computed(() => {return "line";});-watch(- () => props.value,- (selected) => {- state.selectedTab = selected ?? "all";- }-);-const tabItemList = computed(() => {const list: RuleListWithCategory[] = [{diff --git a/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue b/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vueindex 756c86c059..8450de8b05 100644--- a/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue+++ b/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue@@ -29,7 +29,7 @@</a></div></div>- <div v-if="editable" class="space-y-1">+ <div class="space-y-1"><h3 class="text-lg text-control font-medium">{{ $t("sql-review.rule.active") }}</h3>@@ -49,12 +49,11 @@<RuleLevelSwitch:level="state.level":disabled="disabled"- :editable="editable"@level-change="state.level = $event"/></div></div>- <div v-if="editable" class="space-y-1">+ <div class="space-y-1"><h3 class="text-lg text-control font-medium">{{ $t("common.description") }}</h3>@@ -71,68 +70,13 @@/></div></div>- <div v-else-if="displayDescription" class="space-y-1">- <h3 class="text-lg text-control font-medium">- {{ $t("common.description") }}- </h3>- <div class="flex flex-col gap-x-2">- {{ displayDescription }}- </div>- </div>- <div- v-for="(config, index) in rule.componentList"- :key="index"- class="space-y-1"- >- <p class="text-lg text-control font-medium mb-2">- {{ configTitle(config) }}- </p>- <StringComponent- v-if="config.payload.type === 'STRING'"- :value="state.payload[index] as string"- :config="config"- :disabled="disabled || !editable"- @update:value="state.payload[index] = $event"- />- <NumberComponent- v-if="config.payload.type === 'NUMBER'"- :value="state.payload[index] as number"- :config="config"- :disabled="disabled || !editable"- @update:value="state.payload[index] = $event"- />- <BooleanComponent- v-else-if="config.payload.type == 'BOOLEAN'"- :rule="rule"- :value="state.payload[index] as boolean"- :config="config"- :disabled="disabled || !editable"- @update:value="state.payload[index] = $event"- />- <StringArrayComponent- v-else-if="- config.payload.type == 'STRING_ARRAY' &&- Array.isArray(state.payload[index])- "- :value="state.payload[index] as string[]"- :config="config"- :disabled="disabled"- :editable="editable"- @update:value="state.payload[index] = $event"- />- <TemplateComponent- v-else-if="config.payload.type == 'TEMPLATE'"- :rule="rule"- :value="state.payload[index] as string"- :config="config"- :disabled="disabled || !editable"- @update:value="state.payload[index] = $event"- />- </div>- <div- v-if="editable"- class="mt-4 pt-2 border-t flex justify-end space-x-3"- >+ <RuleConfig+ ref="ruleConfig"+ :disabled="disabled"+ :rule="rule"+ :size="'medium'"+ />+ <div class="mt-4 pt-2 border-t flex justify-end space-x-3"><NButton @click.prevent="$emit('cancel')">{{ $t("common.cancel") }}</NButton>@@ -146,30 +90,20 @@<script lang="ts" setup>import { NSwitch } from "naive-ui";-import { computed, nextTick, reactive, watch } from "vue";-import { useI18n } from "vue-i18n";+import { nextTick, reactive, watch, ref } from "vue";import { payloadValueListToComponentList } from "@/components/SQLReview/components";import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";-import type { RuleConfigComponent, RuleTemplateV2 } from "@/types/sqlReview";-import { getRuleLocalization, getRuleLocalizationKey } from "@/types/sqlReview";-import type { PayloadValueType } from "./RuleConfigComponents";-import {- StringComponent,- NumberComponent,- BooleanComponent,- StringArrayComponent,- TemplateComponent,-} from "./RuleConfigComponents";+import type { RuleTemplateV2 } from "@/types/sqlReview";+import { getRuleLocalization } from "@/types/sqlReview";+import RuleConfig from "./RuleConfigComponents/RuleConfig.vue";import RuleLevelSwitch from "./RuleLevelSwitch.vue";type LocalState = {- payload: PayloadValueType[];level: SQLReviewRuleLevel;comment: string;};const props = defineProps<{- editable: boolean;rule: RuleTemplateV2;disabled: boolean;}>();@@ -179,46 +113,14 @@ const emit = defineEmits<{(event: "cancel"): void;}>();-const { t } = useI18n();--const getRulePayload = (): PayloadValueType[] => {- const { componentList } = props.rule;-- if (componentList.length === 0) {- return [];- }-- const basePayload = componentList.reduce<- { key: string; value: PayloadValueType }[]- >((list, component) => {- list.push({- key: component.key,- value: component.payload.value ?? component.payload.default,- });- return list;- }, []);-- return basePayload.map((val) => val.value);-};+const ruleConfig = ref<InstanceType<typeof RuleConfig>>();const state = reactive<LocalState>({- payload: getRulePayload(),level: props.rule.level,comment:props.rule.comment || getRuleLocalization(props.rule.type).description,});-const displayDescription = computed(() => {- return state.comment || getRuleLocalization(props.rule.type).description;-});--const configTitle = (config: RuleConfigComponent): string => {- const key = `sql-review.rule.${getRuleLocalizationKey(- props.rule.type- )}.component.${config.key}.title`;- return t(key);-};-const toggleActivity = (on: boolean) => {state.level = on ? SQLReviewRuleLevel.WARNING : SQLReviewRuleLevel.DISABLED;};@@ -232,7 +134,10 @@ watch(const confirm = () => {emit("update:rule", {- componentList: payloadValueListToComponentList(props.rule, state.payload),+ componentList: payloadValueListToComponentList(+ props.rule,+ ruleConfig.value?.payload ?? []+ ),level: state.level,comment: state.comment,});diff --git a/frontend/src/components/SQLReview/components/SQLRuleFilter.vue b/frontend/src/components/SQLReview/components/SQLRuleFilter.vueindex 6ec5477eac..cf1ef1137d 100644--- a/frontend/src/components/SQLReview/components/SQLRuleFilter.vue+++ b/frontend/src/components/SQLReview/components/SQLRuleFilter.vue@@ -53,7 +53,7 @@ const props = defineProps<{defineEmits<{(event: "toggle-checked-level", level: SQLReviewRuleLevel): void;- (event: "change-category", category: string | undefined): void;+ (event: "change-category", category: string): void;(event: "change-search-text", keyword: string): void;}>();diff --git a/frontend/src/components/SQLReview/components/SQLRuleTable.vue b/frontend/src/components/SQLReview/components/SQLRuleTable.vueindex 020f46a465..79728e870d 100644--- a/frontend/src/components/SQLReview/components/SQLRuleTable.vue+++ b/frontend/src/components/SQLReview/components/SQLRuleTable.vue@@ -95,8 +95,7 @@v-if="!hideLevel"class="text-xs":level="rule.level"- :disabled="!isRuleAvailable(rule)"- :editable="editable"+ :disabled="!editable || !isRuleAvailable(rule)"@level-change="updateLevel(rule, $event)"/><p class="textinfolabel">@@ -108,9 +107,8 @@<SQLRuleEditDialogv-if="state.activeRule"- :editable="editable":rule="state.activeRule"- :disabled="!isRuleAvailable(state.activeRule)"+ :disabled="!editable || !isRuleAvailable(state.activeRule)"@cancel="state.activeRule = undefined"@update:rule="onRuleChanged"/>@@ -119,7 +117,7 @@<script lang="tsx" setup>import { ExternalLinkIcon, PencilIcon } from "lucide-vue-next";-import { NSwitch, NCheckbox, NDataTable, NButton } from "naive-ui";+import { NSwitch, NCheckbox, NDataTable, NButton, NDivider } from "naive-ui";import type { DataTableColumn } from "naive-ui";import { computed, reactive } from "vue";import { useI18n } from "vue-i18n";@@ -131,6 +129,7 @@ import {planTypeToString,} from "@/types";import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";+import RuleConfig from "./RuleConfigComponents/RuleConfig.vue";import RuleLevelSwitch from "./RuleLevelSwitch.vue";import type { RuleListWithCategory } from "./SQLReviewCategoryTabFilter.vue";import SQLRuleEditDialog from "./SQLRuleEditDialog.vue";@@ -190,12 +189,31 @@ const columns = computed(() => {{type: "expand",expandable: (rule: RuleTemplateV2) => {- return !!(rule.comment || getRuleLocalization(rule.type).description);+ return !!(+ rule.comment ||+ getRuleLocalization(rule.type).description ||+ rule.componentList.length > 0+ );},renderExpand: (rule: RuleTemplateV2) => {const comment =rule.comment || getRuleLocalization(rule.type).description;- return <p class="w-full text-left pl-10 text-gray-500">{comment}</p>;+ return (+ <div class="px-10">+ <p class="w-full text-left text-gray-500">{comment}</p>+ {rule.componentList.length > 0 && !!comment && (+ <NDivider class={"!my-4"} />+ )}+ {rule.componentList.length > 0 && (+ <RuleConfig+ disabled={true}+ rule={rule}+ size={"small"}+ class={"mb-3"}+ />+ )}+ </div>+ );},cellProps: (rule: RuleTemplateV2) => {return {@@ -248,8 +266,7 @@ const columns = computed(() => {return (<RuleLevelSwitchlevel={rule.level}- disabled={!isRuleAvailable(rule)}- editable={props.editable}+ disabled={!props.editable || !isRuleAvailable(rule)}onLevel-change={(on) => updateLevel(rule, on)}/>);diff --git a/frontend/src/components/SQLReview/components/useSQLRuleFilter.ts b/frontend/src/components/SQLReview/components/useSQLRuleFilter.tsindex 9b973a0ae6..f2d58de9e7 100644--- a/frontend/src/components/SQLReview/components/useSQLRuleFilter.ts+++ b/frontend/src/components/SQLReview/components/useSQLRuleFilter.ts@@ -4,7 +4,7 @@ import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";export type SQLRuleFilterParams = {checkedLevel: Set<SQLReviewRuleLevel>;- selectedCategory: string | undefined;+ selectedCategory: string;searchText: string;};@@ -14,7 +14,7 @@ export const useSQLRuleFilter = () => {checkedLevel: new Set([]),selectedCategory: route.query.category? (route.query.category as string)- : undefined,+ : "all",searchText: "",});const events = {@@ -25,14 +25,14 @@ export const useSQLRuleFilter = () => {params.checkedLevel.add(level);}},- changeCategory(category: string | undefined) {+ changeCategory(category: string) {params.selectedCategory = category;},changeSearchText(keyword: string) {params.searchText = keyword;},reset() {- this.changeCategory(undefined);+ this.changeCategory("all");params.checkedLevel = new Set([]);},};