Skip to content

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

refactor: move bb.feature.rbac to hasWorkspacePermission (#3163)

Tianzhou (天舟)d7dd2fa32afa
diff --git a/frontend/src/components/ProjectSelect.vue b/frontend/src/components/ProjectSelect.vue
index e76d18605f..ce945c64af 100644
--- a/frontend/src/components/ProjectSelect.vue
+++ b/frontend/src/components/ProjectSelect.vue
@@ -31,7 +31,7 @@ import {
unknown,
} from "../types";
import { hasWorkspacePermission } from "../utils";
-import { featureToRef, useCurrentUser, useProjectStore } from "@/store";
+import { useCurrentUser, useProjectStore } from "@/store";
interface LocalState {
selectedProject?: Project;
@@ -88,8 +88,6 @@ export default defineComponent({
watchEffect(prepareProjectList);
- const hasRBACFeature = featureToRef("bb.feature.rbac");
-
const rawProjectList = computed((): Project[] => {
let list = projectStore.getProjectListByUser(currentUser.value.id, [
"NORMAL",
@@ -107,7 +105,6 @@ export default defineComponent({
});
if (
- !hasRBACFeature.value ||
hasWorkspacePermission(
"bb.permission.workspace.manage-project",
currentUser.value.role
diff --git a/frontend/src/utils/role.ts b/frontend/src/utils/role.ts
index 4e4e2048d1..f5994b6ab8 100644
--- a/frontend/src/utils/role.ts
+++ b/frontend/src/utils/role.ts
@@ -33,11 +33,14 @@ export const WORKSPACE_FEATURE_MATRIX: Map<WorkspacePermissionType, boolean[]> =
["bb.permission.workspace.admin-sql-editor", [false, true, true]],
]);
-// Returns true if the particular role has the particular permission.
+// Returns true if RBAC is not enabled or the particular role has the particular permission.
export function hasWorkspacePermission(
permission: WorkspacePermissionType,
role: RoleType
): boolean {
+ if (!hasFeature("bb.feature.rbac")) {
+ return true;
+ }
switch (role) {
case "DEVELOPER":
return WORKSPACE_FEATURE_MATRIX.get(permission)![0];