Skip to content

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

chore: hide branch related permissions in frontend (#13246)

boojack829bc0eb158b
diff --git a/frontend/src/components/Role/Setting/RoleSetting.vue b/frontend/src/components/Role/Setting/RoleSetting.vue
index 41f1e395e4..f382d31574 100644
--- a/frontend/src/components/Role/Setting/RoleSetting.vue
+++ b/frontend/src/components/Role/Setting/RoleSetting.vue
@@ -53,11 +53,13 @@
</template>
<script lang="ts" setup>
+import { sortBy } from "lodash-es";
import { NButton } from "naive-ui";
import { computed, onMounted, reactive, ref } from "vue";
import { BBSpin } from "@/bbkit";
import { FeatureBadge, FeatureModal } from "@/components/FeatureGuard";
import { featureToRef, useCurrentUserV1, useRoleStore } from "@/store";
+import { PRESET_ROLES } from "@/types";
import { Role } from "@/types/proto/v1/role_service";
import { hasWorkspacePermissionV2 } from "@/utils";
import { RoleDataTable, RolePanel } from "./components";
@@ -95,9 +97,14 @@ const allowCreateRole = computed(() => {
});
const filteredRoleList = computed(() => {
+ const sortedRoles = sortBy(roleStore.roleList, (role) => {
+ return PRESET_ROLES.includes(role.name)
+ ? PRESET_ROLES.indexOf(role.name)
+ : roleStore.roleList.length;
+ });
const keyword = state.filter.keyword.trim().toLowerCase();
- if (!keyword) return roleStore.roleList;
- return roleStore.roleList.filter((role) => {
+ if (!keyword) return sortedRoles;
+ return sortedRoles.filter((role) => {
return (
role.name.toLowerCase().includes(keyword) ||
role.description.toLowerCase().includes(keyword)
diff --git a/frontend/src/components/Role/Setting/components/RoleDataTable/index.vue b/frontend/src/components/Role/Setting/components/RoleDataTable/index.vue
index 70585911e1..fa05d1fd21 100644
--- a/frontend/src/components/Role/Setting/components/RoleDataTable/index.vue
+++ b/frontend/src/components/Role/Setting/components/RoleDataTable/index.vue
@@ -8,10 +8,10 @@
/>
</template>
-<script lang="ts" setup>
+<script lang="tsx" setup>
import type { DataTableColumn } from "naive-ui";
import { NDataTable } from "naive-ui";
-import { computed, h } from "vue";
+import { computed } from "vue";
import { useI18n } from "vue-i18n";
import type { Role } from "@/types/proto/v1/role_service";
import { displayRoleDescription } from "@/utils";
@@ -35,9 +35,7 @@ const columns = computed(() => {
title: t("role.title"),
width: "16rem",
render: (role: Role) => {
- return h(RoleTitleCell, {
- role,
- });
+ return <RoleTitleCell role={role} />;
},
},
{
@@ -55,12 +53,12 @@ const columns = computed(() => {
title: "",
width: "10rem",
render: (role: Role) => {
- return h(RoleOperationsCell, {
- role,
- onEdit: () => {
- emit("select-role", role);
- },
- });
+ return (
+ <RoleOperationsCell
+ role={role}
+ onEdit={() => emit("select-role", role)}
+ />
+ );
},
},
] as DataTableColumn<Role>[];
diff --git a/frontend/src/components/Role/Setting/components/RolePanel.vue b/frontend/src/components/Role/Setting/components/RolePanel.vue
index 35251460e2..a33993fde7 100644
--- a/frontend/src/components/Role/Setting/components/RolePanel.vue
+++ b/frontend/src/components/Role/Setting/components/RolePanel.vue
@@ -159,10 +159,12 @@ const resourceId = computed({
});
const permissionOptions = computed(() => {
- return PERMISSIONS.sort().map((p) => ({
- label: displayPermissionTitle(p),
- value: p,
- }));
+ return PERMISSIONS.sort()
+ .filter((p) => !p.startsWith("bb.branches")) // Filter branch related permissions.
+ .map((p) => ({
+ label: displayPermissionTitle(p),
+ value: p,
+ }));
});
const allowSave = computed(() => {