Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: anchor and order (#2176)

ecmadaoeb5529ee63df
diff --git a/frontend/src/components/SQLReview/SQLReviewCreation.vue b/frontend/src/components/SQLReview/SQLReviewCreation.vue
index e7892b45a1..284ca5e72f 100644
--- a/frontend/src/components/SQLReview/SQLReviewCreation.vue
+++ b/frontend/src/components/SQLReview/SQLReviewCreation.vue
@@ -78,6 +78,7 @@ import {
Environment,
RuleTemplate,
TEMPLATE_LIST,
+ convertToCategoryList,
convertRuleTemplateToPolicyRule,
} from "@/types";
import {
@@ -145,9 +146,7 @@ const state = reactive<LocalState>({
currentStep: BASIC_INFO_STEP,
name: props.name || t("sql-review.create.basic-info.display-name-default"),
selectedEnvironment: props.selectedEnvironment,
- selectedRuleList: props.selectedRuleList.length
- ? [...props.selectedRuleList]
- : [...TEMPLATE_LIST[DEFAULT_TEMPLATE_INDEX].ruleList],
+ selectedRuleList: [...props.selectedRuleList],
ruleUpdated: false,
showAlertModal: false,
showFeatureModal: false,
@@ -155,6 +154,24 @@ const state = reactive<LocalState>({
pendingApplyTemplateIndex: -1,
});
+const onTemplateApply = (index: number) => {
+ if (index < 0 || index >= TEMPLATE_LIST.length) {
+ return;
+ }
+ state.templateIndex = index;
+ state.pendingApplyTemplateIndex = -1;
+
+ const categoryList = convertToCategoryList(TEMPLATE_LIST[index].ruleList);
+ state.selectedRuleList = categoryList.reduce((res, category) => {
+ res.push(...category.ruleList);
+ return res;
+ }, [] as RuleTemplate[]);
+};
+
+if (state.selectedRuleList.length === 0) {
+ onTemplateApply(DEFAULT_TEMPLATE_INDEX);
+}
+
const availableEnvironmentList = computed((): Environment[] => {
const environmentList = useEnvironmentList(["NORMAL"]);
@@ -246,15 +263,6 @@ const onEnvChange = (env: Environment) => {
state.selectedEnvironment = env;
};
-const onTemplateApply = (index: number) => {
- if (index < 0 || index >= TEMPLATE_LIST.length) {
- return;
- }
- state.templateIndex = index;
- state.pendingApplyTemplateIndex = -1;
- state.selectedRuleList = [...TEMPLATE_LIST[index].ruleList];
-};
-
const tryApplyTemplate = (index: number) => {
if (state.ruleUpdated || props.policyId) {
state.showAlertModal = true;
diff --git a/frontend/src/components/SQLReview/components/SQLRuleConfig.vue b/frontend/src/components/SQLReview/components/SQLRuleConfig.vue
index 575da4334b..455dac8062 100644
--- a/frontend/src/components/SQLReview/components/SQLRuleConfig.vue
+++ b/frontend/src/components/SQLReview/components/SQLRuleConfig.vue
@@ -1,5 +1,5 @@
<template>
- <div>
+ <div :id="selectedRule.type.replace(/\./g, '-')">
<div
class="flex justify-center items-center py-4 px-2 group cursor-pointer hover:bg-gray-100"
:class="active ? 'bg-gray-100' : ''"