Skip to content

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

fix: put fetchPolicyList inside <DatabaseTable> (#3648)

Liu Ji5a2135e5809f
diff --git a/frontend/src/components/DatabaseTable.vue b/frontend/src/components/DatabaseTable.vue
index c01292cbcc..5b472295d4 100644
--- a/frontend/src/components/DatabaseTable.vue
+++ b/frontend/src/components/DatabaseTable.vue
@@ -225,7 +225,7 @@
</template>
<script lang="ts" setup>
-import { computed, PropType, reactive } from "vue";
+import { computed, PropType, reactive, ref, watchEffect } from "vue";
import { useRouter } from "vue-router";
import { NTooltip } from "naive-ui";
import { useI18n } from "vue-i18n";
@@ -241,7 +241,7 @@ import { DEFAULT_PROJECT_ID, UNKNOWN_ID } from "../types";
import { BBTableColumn } from "../bbkit/types";
import InstanceEngineIcon from "./InstanceEngineIcon.vue";
import TenantIcon from "./TenantIcon.vue";
-import { useCurrentUser } from "@/store";
+import { useCurrentUser, usePolicyStore } from "@/store";
type Mode =
| "ALL"
@@ -286,10 +286,6 @@ const props = defineProps({
required: true,
type: Object as PropType<Database[]>,
},
- policyList: {
- type: Array as PropType<Policy[]>,
- default: () => [],
- },
});
const emit = defineEmits(["select-database"]);
@@ -335,6 +331,19 @@ const mixedDatabaseList = computed(() => {
return tableList;
});
+const policyList = ref<Policy[]>([]);
+
+const preparePolicyList = () => {
+ if (showSQLEditorLink.value) {
+ usePolicyStore()
+ .fetchPolicyListByResourceTypeAndPolicyType(
+ "database",
+ "bb.policy.access-control"
+ )
+ .then((list) => (policyList.value = list));
+ }
+};
+
const columnListMap = computed(() => {
return new Map([
[
@@ -504,7 +513,7 @@ const showSQLEditorLink = computed(() => {
});
const allowQuery = (database: Database) => {
- return isDatabaseAccessible(database, props.policyList, currentUser.value);
+ return isDatabaseAccessible(database, policyList.value, currentUser.value);
};
const showTenantIcon = computed(() => {
@@ -554,4 +563,6 @@ const clickDatabase = (section: number, row: number, e: MouseEvent) => {
}
}
};
+
+watchEffect(preparePolicyList);
</script>
diff --git a/frontend/src/components/ProjectOverviewPanel.vue b/frontend/src/components/ProjectOverviewPanel.vue
index 4e11eb1408..f36d392e31 100644
--- a/frontend/src/components/ProjectOverviewPanel.vue
+++ b/frontend/src/components/ProjectOverviewPanel.vue
@@ -71,12 +71,7 @@
<NSpin />
</div>
</template>
- <DatabaseTable
- v-else
- :mode="'PROJECT'"
- :database-list="databaseList"
- :policy-list="accessControlPolicyList"
- />
+ <DatabaseTable v-else :mode="'PROJECT'" :database-list="databaseList" />
</template>
<div v-else class="text-center textinfolabel">
<i18n-t keypath="project.overview.no-db-prompt" tag="p">