Skip to content

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

fix: review config permission (#15605)

ecmadao5280166f8f66
diff --git a/frontend/src/components/SQLReview/SQLReviewCreation.vue b/frontend/src/components/SQLReview/SQLReviewCreation.vue
index b0ac3d932a..1ab6c9bb41 100644
--- a/frontend/src/components/SQLReview/SQLReviewCreation.vue
+++ b/frontend/src/components/SQLReview/SQLReviewCreation.vue
@@ -212,7 +212,11 @@ const changeStepIndex = (nextIndex: number) => {
};
const tryFinishSetup = async () => {
- if (!hasWorkspacePermissionV2("bb.policies.update")) {
+ if (
+ !hasWorkspacePermissionV2(
+ isUpdate.value ? "bb.reviewConfigs.update" : "bb.reviewConfigs.create"
+ )
+ ) {
pushNotification({
module: "bytebase",
style: "CRITICAL",
diff --git a/frontend/src/components/SQLReview/components/SQLReviewForResource.vue b/frontend/src/components/SQLReview/components/SQLReviewForResource.vue
index 2b14a6a33a..30977432d2 100644
--- a/frontend/src/components/SQLReview/components/SQLReviewForResource.vue
+++ b/frontend/src/components/SQLReview/components/SQLReviewForResource.vue
@@ -26,7 +26,7 @@
</span>
</div>
<NButton
- v-else-if="allowEditSQLReviewPolicy"
+ v-else-if="allowEditSQLReviewTag"
@click.prevent="showReviewSelectPanel = true"
>
{{ $t("sql-review.configure-policy") }}
@@ -81,6 +81,10 @@ const resetState = () => {
watchEffect(resetState);
const allowEditSQLReviewPolicy = computed(() => {
+ return props.allowEdit && hasWorkspacePermissionV2("bb.reviewConfigs.update");
+});
+
+const allowEditSQLReviewTag = computed(() => {
return props.allowEdit && hasWorkspacePermissionV2("bb.policies.update");
});
diff --git a/frontend/src/components/SQLReview/components/SQLReviewPolicyDataTable.vue b/frontend/src/components/SQLReview/components/SQLReviewPolicyDataTable.vue
index a8e51145e9..7cf773c77b 100644
--- a/frontend/src/components/SQLReview/components/SQLReviewPolicyDataTable.vue
+++ b/frontend/src/components/SQLReview/components/SQLReviewPolicyDataTable.vue
@@ -171,11 +171,11 @@ const rowProps = (review: SQLReviewPolicy) => {
};
const hasUpdatePolicyPermission = computed(() => {
- return hasWorkspacePermissionV2("bb.policies.update");
+ return hasWorkspacePermissionV2("bb.reviewConfigs.update");
});
const hasDeletePolicyPermission = computed(() => {
- return hasWorkspacePermissionV2("bb.policies.delete");
+ return hasWorkspacePermissionV2("bb.reviewConfigs.delete");
});
const toggleReviewEnabled = async (review: SQLReviewPolicy, on: boolean) => {
diff --git a/frontend/src/components/SQLReview/components/SQLReviewPolicySelectPanel.vue b/frontend/src/components/SQLReview/components/SQLReviewPolicySelectPanel.vue
index 865324a62a..1eeffaa301 100644
--- a/frontend/src/components/SQLReview/components/SQLReviewPolicySelectPanel.vue
+++ b/frontend/src/components/SQLReview/components/SQLReviewPolicySelectPanel.vue
@@ -72,7 +72,7 @@ watchEffect(() => {
});
const allowCreateSQLReviewPolicy = computed(() => {
- return hasWorkspacePermissionV2("bb.policies.create");
+ return hasWorkspacePermissionV2("bb.reviewConfigs.create");
});
const createPolicy = () => {
diff --git a/frontend/src/components/SQLReview/components/SQLReviewPolicyTable.vue b/frontend/src/components/SQLReview/components/SQLReviewPolicyTable.vue
index 7e5cd79a44..a8c16596ff 100644
--- a/frontend/src/components/SQLReview/components/SQLReviewPolicyTable.vue
+++ b/frontend/src/components/SQLReview/components/SQLReviewPolicyTable.vue
@@ -87,11 +87,11 @@ const router = useRouter();
const sqlReviewStore = useSQLReviewStore();
const hasUpdatePolicyPermission = computed(() => {
- return hasWorkspacePermissionV2("bb.policies.update");
+ return hasWorkspacePermissionV2("bb.reviewConfigs.update");
});
const hasDeletePolicyPermission = computed(() => {
- return hasWorkspacePermissionV2("bb.policies.delete");
+ return hasWorkspacePermissionV2("bb.reviewConfigs.delete");
});
const handleClickEdit = (review: SQLReviewPolicy) => {
diff --git a/frontend/src/router/dashboard/workspace.ts b/frontend/src/router/dashboard/workspace.ts
index 57953b7b62..dd8891d24c 100644
--- a/frontend/src/router/dashboard/workspace.ts
+++ b/frontend/src/router/dashboard/workspace.ts
@@ -152,7 +152,7 @@ const workspaceRoutes: RouteRecordRaw[] = [
name: WORKSPACE_ROUTE_SQL_REVIEW,
meta: {
title: () => t("sql-review.title"),
- requiredWorkspacePermissionList: () => ["bb.policies.get"],
+ requiredWorkspacePermissionList: () => ["bb.reviewConfigs.list"],
},
component: () => import("@/views/SettingWorkspaceSQLReview.vue"),
props: true,
@@ -162,7 +162,7 @@ const workspaceRoutes: RouteRecordRaw[] = [
name: WORKSPACE_ROUTE_SQL_REVIEW_CREATE,
meta: {
title: () => t("sql-review.create.breadcrumb"),
- requiredWorkspacePermissionList: () => ["bb.policies.create"],
+ requiredWorkspacePermissionList: () => ["bb.reviewConfigs.create"],
},
component: () => import("@/views/SettingWorkspaceSQLReviewCreate.vue"),
props: true,
@@ -172,7 +172,7 @@ const workspaceRoutes: RouteRecordRaw[] = [
name: WORKSPACE_ROUTE_SQL_REVIEW_DETAIL,
meta: {
title: () => t("sql-review.title"),
- requiredWorkspacePermissionList: () => ["bb.policies.get"],
+ requiredWorkspacePermissionList: () => ["bb.reviewConfigs.get"],
},
component: () => import("@/views/SettingWorkspaceSQLReviewDetail.vue"),
props: true,
diff --git a/frontend/src/views/SettingWorkspaceSQLReview.vue b/frontend/src/views/SettingWorkspaceSQLReview.vue
index 2213df1eec..b6f735c7d7 100644
--- a/frontend/src/views/SettingWorkspaceSQLReview.vue
+++ b/frontend/src/views/SettingWorkspaceSQLReview.vue
@@ -72,7 +72,7 @@ watchEffect(() => {
});
const hasCreatePolicyPermission = computed(() => {
- return hasWorkspacePermissionV2("bb.policies.create");
+ return hasWorkspacePermissionV2("bb.reviewConfigs.create");
});
const createSQLReview = () => {
diff --git a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
index d630e3ebd0..591045c663 100644
--- a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
+++ b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
@@ -18,7 +18,7 @@
>
<BBTextField
class="flex-1 !text-xl !pl-0 px-0.5 font-bold truncate sql-review-title"
- :disabled="!hasPermission"
+ :disabled="!hasUpdateReviwConfigPermission"
:required="true"
:focus-on-mount="false"
:ends-on-enter="true"
@@ -27,7 +27,7 @@
@on-focus="state.editingTitle = true"
@end-editing="changeName"
/>
- <div v-if="hasPermission" class="flex gap-x-2">
+ <div v-if="hasUpdateReviwConfigPermission" class="flex gap-x-2">
<NButton
v-if="reviewPolicy.enforce"
@click.prevent="state.showDisableModal = true"
@@ -38,7 +38,7 @@
{{ $t("common.enable") }}
</NButton>
<NButton
- v-if="reviewPolicy.resources.length > 0"
+ v-if="reviewPolicy.resources.length > 0 && hasTagPolicyPermission"
@click.prevent="state.showResourcePanel = true"
>
{{ $t("sql-review.attach-resource.change-resources") }}
@@ -78,7 +78,7 @@
<SQLRuleTableWithFilter
:engine="engine"
:rule-list="ruleListFilteredByEngine"
- :editable="hasPermission"
+ :editable="hasUpdateReviwConfigPermission"
@rule-upsert="markChange"
/>
</template>
@@ -86,7 +86,7 @@
<BBButtonConfirm
class="!my-4"
- :disabled="!hasPermission"
+ :disabled="!hasDeleteReviwConfigPermission"
:type="'DELETE'"
:button-text="$t('sql-review.delete')"
:ok-text="$t('common.delete')"
@@ -219,7 +219,15 @@ const state = reactive<LocalState>({
showResourcePanel: false,
});
-const hasPermission = computed(() => {
+const hasUpdateReviwConfigPermission = computed(() => {
+ return hasWorkspacePermissionV2("bb.reviewConfigs.update");
+});
+
+const hasDeleteReviwConfigPermission = computed(() => {
+ return hasWorkspacePermissionV2("bb.reviewConfigs.delete");
+});
+
+const hasTagPolicyPermission = computed(() => {
return hasWorkspacePermissionV2("bb.policies.update");
});
@@ -232,7 +240,7 @@ watchEffect(async () => {
});
onMounted(() => {
- if (route.query.attachResourcePanel && hasPermission.value) {
+ if (route.query.attachResourcePanel && hasTagPolicyPermission.value) {
nextTick(() => {
state.showResourcePanel = true;
});