Skip to content

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

fix: hide index advisor if not has permission (#10789)

ecmadaod3c6d1347f95
diff --git a/frontend/src/components/SlowQuery/Panel/DetailPanel.vue b/frontend/src/components/SlowQuery/Panel/DetailPanel.vue
index 1be5dc83b1..2d5dc6a879 100644
--- a/frontend/src/components/SlowQuery/Panel/DetailPanel.vue
+++ b/frontend/src/components/SlowQuery/Panel/DetailPanel.vue
@@ -62,7 +62,10 @@
</div>
</div>
</div>
- <IndexAdvisor v-if="slowQueryLog" :slow-query-log="slowQueryLog" />
+ <IndexAdvisor
+ v-if="slowQueryLog && hasIndexAdvisorPermission"
+ :slow-query-log="slowQueryLog"
+ />
<div
v-if="instanceV1HasSlowQueryDetail(database.instanceEntity)"
class="flex-1 overflow-auto border"
@@ -135,9 +138,11 @@ import {
Drawer,
DrawerContent,
} from "@/components/v2";
+import { useCurrentUserV1 } from "@/store";
import type { ComposedSlowQueryLog } from "@/types";
import type { SlowQueryDetails } from "@/types/proto/v1/database_service";
import { instanceV1HasSlowQueryDetail } from "@/utils";
+import { hasProjectPermissionV2 } from "@/utils";
import IndexAdvisor from "./IndexAdvisor.vue";
export type SlowQueryDetailsRow = BBGridRow<SlowQueryDetails>;
@@ -188,6 +193,13 @@ const columns = computed(() => {
const log = computed(() => props.slowQueryLog!.log);
const database = computed(() => props.slowQueryLog!.database);
const selectedDetail = shallowRef<SlowQueryDetails>();
+const hasIndexAdvisorPermission = computed(() =>
+ hasProjectPermissionV2(
+ database.value.projectEntity,
+ useCurrentUserV1().value,
+ "bb.databases.adviseIndex"
+ )
+);
const isSelectedRow = (item: SlowQueryDetails) => {
return selectedDetail.value === item;