Skip to content

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

Change quickActionListByRole to a function for customized logic

天舟e2a908d1baf2
diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vue
index e6370625a1..70de6d2bee 100644
--- a/frontend/src/layouts/BodyLayout.vue
+++ b/frontend/src/layouts/BodyLayout.vue
@@ -8,13 +8,30 @@
</div>
<div
tabindex="0"
- class="relative flex-1 flex flex-col max-w-xs w-full bg-white focus:outline-none"
+ class="
+ relative
+ flex-1 flex flex-col
+ max-w-xs
+ w-full
+ bg-white
+ focus:outline-none
+ "
>
<div class="absolute top-0 right-0 -mr-12 pt-2">
<button
@click.prevent="state.showMobileOverlay = false"
type="button"
- class="ml-1 flex items-center justify-center h-10 w-10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white"
+ class="
+ ml-1
+ flex
+ items-center
+ justify-center
+ h-10
+ w-10
+ rounded-full
+ focus:outline-none
+ focus:ring-2 focus:ring-inset focus:ring-white
+ "
>
<span class="sr-only">Close sidebar</span>
<!-- Heroicon name: x -->
@@ -119,7 +136,12 @@
</router-link>
<div
v-if="showIntro"
- class="flex-shrink-0 flex justify-center border-t border-block-border py-2"
+ class="
+ flex-shrink-0 flex
+ justify-center
+ border-t border-block-border
+ py-2
+ "
>
<Quickstart />
</div>
@@ -155,13 +177,31 @@
<!-- Static sidebar for mobile -->
<aside class="md:hidden">
<div
- class="flex items-center justify-start bg-gray-50 border-b border-block-border px-4 py-1.5"
+ class="
+ flex
+ items-center
+ justify-start
+ bg-gray-50
+ border-b border-block-border
+ px-4
+ py-1.5
+ "
>
<div>
<button
@click.prevent="state.showMobileOverlay = true"
type="button"
- class="-mr-3 h-12 w-12 inline-flex items-center justify-center rounded-md text-gray-500 hover:text-gray-900"
+ class="
+ -mr-3
+ h-12
+ w-12
+ inline-flex
+ items-center
+ justify-center
+ rounded-md
+ text-gray-500
+ hover:text-gray-900
+ "
>
<span class="sr-only">Open sidebar</span>
<!-- Heroicon name: menu -->
@@ -243,19 +283,23 @@ export default {
const quickActionList = computed(() => {
const role = currentUser.value.role;
- const listByRole = router.currentRoute.value.meta.quickActionListByRole;
+ const quickActionListFunc =
+ router.currentRoute.value.meta.quickActionListByRole;
+ const listByRole = quickActionListFunc
+ ? quickActionListFunc(router.currentRoute.value)
+ : new Map();
const list: QuickActionType[] = [];
// We write this way because for free version, the user wears the three role hat,
// and we want to display all quick actions relevant to those three roles without duplication.
if (isOwner(role)) {
- for (const item of listByRole?.get("OWNER") || []) {
+ for (const item of listByRole.get("OWNER") || []) {
list.push(item);
}
}
if (isDBA(role)) {
- for (const item of listByRole?.get("DBA") || []) {
+ for (const item of listByRole.get("DBA") || []) {
if (
!list.find((myItem: QuickActionType) => {
return item == myItem;
@@ -267,7 +311,7 @@ export default {
}
if (isDeveloper(role)) {
- for (const item of listByRole?.get("DEVELOPER") || []) {
+ for (const item of listByRole.get("DEVELOPER") || []) {
if (
!list.find((myItem: QuickActionType) => {
return item == myItem;
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index e6154345ed..46f16b3d56 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -76,38 +76,40 @@ const routes: Array<RouteRecordRaw> = [
path: "",
name: HOME_MODULE,
meta: {
- quickActionListByRole: new Map([
- [
- "OWNER",
+ quickActionListByRole: () => {
+ return new Map([
[
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.create",
- "quickaction.bb.database.troubleshoot",
- "quickaction.bb.instance.create",
- "quickaction.bb.project.create",
- "quickaction.bb.user.manage",
+ "OWNER",
+ [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.create",
+ "quickaction.bb.database.troubleshoot",
+ "quickaction.bb.instance.create",
+ "quickaction.bb.project.create",
+ "quickaction.bb.user.manage",
+ ],
],
- ],
- [
- "DBA",
[
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.create",
- "quickaction.bb.database.troubleshoot",
- "quickaction.bb.instance.create",
- "quickaction.bb.project.create",
+ "DBA",
+ [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.create",
+ "quickaction.bb.database.troubleshoot",
+ "quickaction.bb.instance.create",
+ "quickaction.bb.project.create",
+ ],
],
- ],
- [
- "DEVELOPER",
[
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.request",
- "quickaction.bb.database.troubleshoot",
- "quickaction.bb.project.create",
+ "DEVELOPER",
+ [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.request",
+ "quickaction.bb.database.troubleshoot",
+ "quickaction.bb.project.create",
+ ],
],
- ],
- ]),
+ ]);
+ },
},
components: {
content: Home,
@@ -273,22 +275,24 @@ const routes: Array<RouteRecordRaw> = [
name: "workspace.environment",
meta: {
title: () => "Environment",
- quickActionListByRole: new Map([
- [
- "OWNER",
+ quickActionListByRole: () => {
+ return new Map([
[
- "quickaction.bb.environment.create",
- "quickaction.bb.environment.reorder",
+ "OWNER",
+ [
+ "quickaction.bb.environment.create",
+ "quickaction.bb.environment.reorder",
+ ],
],
- ],
- [
- "DBA",
[
- "quickaction.bb.environment.create",
- "quickaction.bb.environment.reorder",
+ "DBA",
+ [
+ "quickaction.bb.environment.create",
+ "quickaction.bb.environment.reorder",
+ ],
],
- ],
- ]),
+ ]);
+ },
},
components: {
content: () => import("../views/EnvironmentDashboard.vue"),
@@ -319,11 +323,13 @@ const routes: Array<RouteRecordRaw> = [
name: "workspace.project",
meta: {
title: () => "Project",
- quickActionListByRole: new Map([
- ["OWNER", ["quickaction.bb.project.create"]],
- ["DBA", ["quickaction.bb.project.create"]],
- ["DEVELOPER", ["quickaction.bb.project.create"]],
- ]),
+ quickActionListByRole: () => {
+ return new Map([
+ ["OWNER", ["quickaction.bb.project.create"]],
+ ["DBA", ["quickaction.bb.project.create"]],
+ ["DEVELOPER", ["quickaction.bb.project.create"]],
+ ]);
+ },
},
components: {
content: () => import("../views/ProjectDashboard.vue"),
@@ -340,11 +346,21 @@ const routes: Array<RouteRecordRaw> = [
return store.getters["project/projectById"](idFromSlug(slug))
.name;
},
- quickActionListByRole: new Map([
- ["OWNER", ["quickaction.bb.database.schema.update"]],
- ["DBA", ["quickaction.bb.database.schema.update"]],
- ["DEVELOPER", ["quickaction.bb.database.schema.update"]],
- ]),
+ quickActionListByRole: (route: RouteLocationNormalized) => {
+ const slug = route.params.projectSlug as string;
+ const project = store.getters["project/projectById"](
+ idFromSlug(slug)
+ );
+
+ if (project.rowStatus == "NORMAL") {
+ return new Map([
+ ["OWNER", ["quickaction.bb.database.schema.update"]],
+ ["DBA", ["quickaction.bb.database.schema.update"]],
+ ["DEVELOPER", ["quickaction.bb.database.schema.update"]],
+ ]);
+ }
+ return new Map();
+ },
allowBookmark: true,
},
components: {
@@ -358,10 +374,12 @@ const routes: Array<RouteRecordRaw> = [
name: "workspace.instance",
meta: {
title: () => "Instance",
- quickActionListByRole: new Map([
- ["OWNER", ["quickaction.bb.instance.create"]],
- ["DBA", ["quickaction.bb.instance.create"]],
- ]),
+ quickActionListByRole: () => {
+ return new Map([
+ ["OWNER", ["quickaction.bb.instance.create"]],
+ ["DBA", ["quickaction.bb.instance.create"]],
+ ]);
+ },
},
components: {
content: () => import("../views/InstanceDashboard.vue"),
@@ -374,30 +392,32 @@ const routes: Array<RouteRecordRaw> = [
name: "workspace.database",
meta: {
title: () => "Database",
- quickActionListByRole: new Map([
- [
- "OWNER",
+ quickActionListByRole: () => {
+ return new Map([
[
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.create",
+ "OWNER",
+ [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.create",
+ ],
],
- ],
- [
- "DBA",
[
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.create",
+ "DBA",
+ [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.create",
+ ],
],
- ],
- [
- "DEVELOPER",
[
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.request",
- "quickaction.bb.database.troubleshoot",
+ "DEVELOPER",
+ [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.request",
+ "quickaction.bb.database.troubleshoot",
+ ],
],
- ],
- ]),
+ ]);
+ },
},
components: {
content: () => import("../views/DatabaseDashboard.vue"),
diff --git a/frontend/src/shims-vue-router.d.ts b/frontend/src/shims-vue-router.d.ts
index fbae17d3f5..8a187b0621 100644
--- a/frontend/src/shims-vue-router.d.ts
+++ b/frontend/src/shims-vue-router.d.ts
@@ -5,6 +5,8 @@ export {};
declare module "vue-router" {
interface RouteMeta {
title?: (route: RouteLocationNormalized) => string;
- quickActionListByRole?: Map<RoleType, QuickActionType[]>;
+ quickActionListByRole?: (
+ route: RouteLocationNormalized
+ ) => Map<RoleType, QuickActionType[]>;
}
}