Skip to content

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

feat: show a tips to configure risk rule if needed (#5490)

Liu Ji5367f9ee6bc2
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RiskTips.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RiskTips.vue
new file mode 100644
index 0000000000..8b20019a05
--- /dev/null
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RiskTips.vue
@@ -0,0 +1,42 @@
+<template>
+ <i18n-t
+ v-if="showTips"
+ tag="span"
+ keypath="custom-approval.approval-flow.risk-not-configured-tips"
+ >
+ <template #link>
+ <router-link to="/setting/risk-center" class="normal-link">
+ {{ $t("custom-approval.approval-flow.the-related-risk-rules") }}
+ </router-link>
+ </template>
+ </i18n-t>
+</template>
+
+<script lang="ts" setup>
+import { computed } from "vue";
+
+import type { Risk_Source } from "@/types/proto/v1/risk_service";
+import { useRiskStore } from "@/store";
+import { DEFAULT_RISK_LEVEL } from "@/types";
+
+const props = defineProps<{
+ level: number;
+ source: Risk_Source;
+ rule: string | undefined;
+}>();
+
+const riskStore = useRiskStore();
+
+const showTips = computed(() => {
+ const { level, source, rule } = props;
+ if (!rule) return false;
+ if (level === DEFAULT_RISK_LEVEL) return false;
+ const riskList = riskStore.riskList.filter(
+ (risk) => risk.active && risk.level === level && risk.source == source
+ );
+ // Show a tips to configure risk rules when
+ // - the approval flow is configured (not "Skip approval")
+ // - AND the number of corresponding risk rules is 0
+ return riskList.length === 0;
+});
+</script>
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue
index c36e8d52b4..9c3bbeaaba 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue
@@ -23,6 +23,7 @@
:link="true"
:on-update="(rule) => updateRow(row, rule)"
/>
+ <RiskTips :level="row.level" :source="source" :rule="row.rule" />
</div>
</template>
</BBGrid>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index e907128ea3..09696fc649 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2233,7 +2233,9 @@
"owner-dba-admin": "The system defines the approval process, first the project Owner approves, then the DBA approves, and finally the Administrator approves."
},
"view-approval-flow": "View approval flow",
- "skip": "Skip manual approval"
+ "skip": "Skip manual approval",
+ "risk-not-configured-tips": "Make sure you have defined {link}.",
+ "the-related-risk-rules": "the related risk rules"
},
"risk": {
"self": "Risk",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 5332fd1272..60005754a8 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2230,7 +2230,9 @@
"owner-dba-admin": "系统定义的流程。先由项目所有者审批,再由 DBA 审批,最后由管理员审批。"
},
"view-approval-flow": "查看审批流",
- "skip": "跳过人工审批"
+ "skip": "跳过人工审批",
+ "risk-not-configured-tips": "确保你已经定义了{link}。",
+ "the-related-risk-rules": "相关的风险规则"
},
"risk": {
"self": "风险",
diff --git a/frontend/src/views/SettingWorkspaceCustomApproval.vue b/frontend/src/views/SettingWorkspaceCustomApproval.vue
index 12d6492603..7752ab44c6 100644
--- a/frontend/src/views/SettingWorkspaceCustomApproval.vue
+++ b/frontend/src/views/SettingWorkspaceCustomApproval.vue
@@ -22,6 +22,7 @@ import {
featureToRef,
useWorkspaceApprovalSettingStore,
useCurrentUser,
+ useRiskStore,
} from "@/store";
import { hasWorkspacePermission } from "@/utils";
import {
@@ -37,7 +38,6 @@ interface LocalState {
showFeatureModal: boolean;
}
-const store = useWorkspaceApprovalSettingStore();
const state = reactive<LocalState>({
ready: false,
showFeatureModal: false,
@@ -64,7 +64,10 @@ provideCustomApprovalContext({
onMounted(async () => {
try {
- await Promise.all([store.fetchConfig()]);
+ await Promise.all([
+ useWorkspaceApprovalSettingStore().fetchConfig(),
+ useRiskStore().fetchRiskList(),
+ ]);
state.ready = true;
} catch {
// nothing