Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Show QuickAction items based on role.
天舟5f2fcc38b7c3
diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vueindex 39e4cbd54a..2f4d24ecf6 100644--- a/frontend/src/components/QuickActionPanel.vue+++ b/frontend/src/components/QuickActionPanel.vue@@ -1,245 +1,252 @@<template><div class="pt-1 overflow-hidden grid grid-cols-3 gap-2 sm:inline-flex">- <div- v-if="quickActionList.includes('instance.create')"- class="flex flex-col items-center w-28"- >- <button class="btn-icon-primary p-3" @click.prevent="createInstance">- <svg- class="w-6 h-6"- fill="none"- stroke="currentColor"- viewBox="0 0 24 24"- xmlns="http://www.w3.org/2000/svg"- >- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M12 6v6m0 0v6m0-6h6m-6 0H6"- ></path>- </svg>- </button>- <h3 class="mt-1 text-base font-normal text-main tracking-tight">- Add Instance- </h3>- </div>-- <div- v-if="quickActionList.includes('user.manage')"- class="flex flex-col items-center w-28"- >- <router-link to="/setting/member" class="btn-icon-primary p-3">- <svg- class="w-6 h-6"- fill="none"- stroke="currentColor"- viewBox="0 0 24 24"- xmlns="http://www.w3.org/2000/svg"- >- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"- ></path>- </svg>- </router-link>- <h3- class="mt-1 text-center text-base font-normal text-main tracking-tight"+ <template v-for="(quickAction, index) in quickActionList" :key="index">+ <div+ v-if="quickAction == 'quickaction.bytebase.instance.create'"+ class="flex flex-col items-center w-28">- Manage User- </h3>- </div>+ <button class="btn-icon-primary p-3" @click.prevent="createInstance">+ <svg+ class="w-6 h-6"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M12 6v6m0 0v6m0-6h6m-6 0H6"+ ></path>+ </svg>+ </button>+ <h3 class="mt-1 text-base font-normal text-main tracking-tight">+ Add Instance+ </h3>+ </div>- <div- v-if="quickActionList.includes('datasource.query')"- class="flex flex-col items-center w-28"- >- <button class="btn-icon-primary p-3">- <svg- class="w-6 h-6"- fill="none"- stroke="currentColor"- viewBox="0 0 24 24"- xmlns="http://www.w3.org/2000/svg"- >- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"- ></path>- </svg>- </button>- <h3- class="mt-1 text-center text-base font-normal text-main tracking-tight"+ <div+ v-if="quickAction == 'quickaction.bytebase.user.manage'"+ class="flex flex-col items-center w-28">- Query- </h3>- </div>-- <div- v-if="quickActionList.includes('datasource.data.edit')"- class="flex flex-col items-center w-28"- >- <button class="btn-icon-primary p-3">- <svg- class="w-6 h-6"- fill="none"- stroke="currentColor"- viewBox="0 0 24 24"- xmlns="http://www.w3.org/2000/svg"+ <router-link to="/setting/member" class="btn-icon-primary p-3">+ <svg+ class="w-6 h-6"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"+ ></path>+ </svg>+ </router-link>+ <h3+ class="mt-1 text-center text-base font-normal text-main tracking-tight">- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"- ></path>- </svg>- </button>- <h3- class="mt-1 text-center text-base font-normal text-main tracking-tight"- >- Edit Data- </h3>- </div>+ Manage User+ </h3>+ </div>- <div- v-if="quickActionList.includes('datasource.request')"- class="flex flex-col items-center w-28"- >- <router-link- to="/task/new?template=bytebase.datasource.request"- class="p-3 btn-icon-primary"+ <div+ v-if="quickAction == 'quickaction.bytebase.database.query'"+ class="flex flex-col items-center w-28">- <svg- class="w-6 h-6"- fill="none"- stroke="currentColor"- viewBox="0 0 24 24"- xmlns="http://www.w3.org/2000/svg"+ <button class="btn-icon-primary p-3">+ <svg+ class="w-6 h-6"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"+ ></path>+ </svg>+ </button>+ <h3+ class="mt-1 text-center text-base font-normal text-main tracking-tight">- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"- ></path>- </svg>- </router-link>- <h3 class="mt-1 text-base font-normal text-main tracking-tight">- Request DB- </h3>- </div>+ Query+ </h3>+ </div>- <div- v-if="quickActionList.includes('datasource.schema.update')"- class="flex flex-col items-center w-28"- >- <router-link- to="/task/new?template=bytebase.datasource.schema.update"- class="btn-icon-primary p-3"+ <div+ v-if="quickAction == 'quickaction.bytebase.database.data.edit'"+ class="flex flex-col items-center w-28">- <svg- class="w-6 h-6"- fill="none"- stroke="currentColor"- viewBox="0 0 24 24"- xmlns="http://www.w3.org/2000/svg"+ <button class="btn-icon-primary p-3">+ <svg+ class="w-6 h-6"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"+ ></path>+ </svg>+ </button>+ <h3+ class="mt-1 text-center text-base font-normal text-main tracking-tight">- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"- ></path>- </svg>- </router-link>- <h3 class="mt-1 text-center text-base font-normal text-main">- Edit Schema- </h3>- </div>+ Edit Data+ </h3>+ </div>- <div- v-if="quickActionList.includes('ticket.create')"- class="flex flex-col items-center w-28"- >- <router-link to="/task/new" class="btn-icon-primary p-3">- <svg- class="w-6 h-6"- fill="none"- stroke="currentColor"- viewBox="0 0 24 24"- xmlns="http://www.w3.org/2000/svg"+ <div+ v-if="quickAction == 'quickaction.bytebase.database.request'"+ class="flex flex-col items-center w-28"+ >+ <router-link+ to="/task/new?template=bytebase.datasource.request"+ class="p-3 btn-icon-primary">- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M17.657 18.657A8 8 0 016.343 7.343S7 9 9 10c0-2 .5-5 2.986-7C14 5 16.09 5.777 17.656 7.343A7.975 7.975 0 0120 13a7.975 7.975 0 01-2.343 5.657z"- ></path>- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M9.879 16.121A3 3 0 1012.015 11L11 14H9c0 .768.293 1.536.879 2.121z"- ></path>- </svg>- </router-link>- <h3 class="mt-1 text-center text-base font-normal text-main">- Troubleshoot- </h3>- </div>+ <svg+ class="w-6 h-6"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"+ ></path>+ </svg>+ </router-link>+ <h3 class="mt-1 text-base font-normal text-main tracking-tight">+ Request DB+ </h3>+ </div>- <div- v-if="quickActionList.includes('environment.create')"- class="flex flex-col items-center w-36"- >- <button class="btn-icon-primary p-3" @click.prevent="createEnvironment">- <svg- class="w-6 h-6"- fill="none"- stroke="currentColor"- viewBox="0 0 24 24"- xmlns="http://www.w3.org/2000/svg"+ <div+ v-if="quickAction == 'quickaction.bytebase.database.schema.update'"+ class="flex flex-col items-center w-28"+ >+ <router-link+ to="/task/new?template=bytebase.datasource.schema.update"+ class="btn-icon-primary p-3">- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M12 6v6m0 0v6m0-6h6m-6 0H6"- ></path>- </svg>- </button>- <h3 class="mt-1 text-center text-base font-normal text-main">- Add Environment- </h3>- </div>+ <svg+ class="w-6 h-6"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"+ ></path>+ </svg>+ </router-link>+ <h3 class="mt-1 text-center text-base font-normal text-main">+ Edit Schema+ </h3>+ </div>++ <div+ v-if="quickAction == 'quickaction.bytebase.database.troubleshoot'"+ class="flex flex-col items-center w-28"+ >+ <router-link to="/task/new" class="btn-icon-primary p-3">+ <svg+ class="w-6 h-6"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M17.657 18.657A8 8 0 016.343 7.343S7 9 9 10c0-2 .5-5 2.986-7C14 5 16.09 5.777 17.656 7.343A7.975 7.975 0 0120 13a7.975 7.975 0 01-2.343 5.657z"+ ></path>+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M9.879 16.121A3 3 0 1012.015 11L11 14H9c0 .768.293 1.536.879 2.121z"+ ></path>+ </svg>+ </router-link>+ <h3 class="mt-1 text-center text-base font-normal text-main">+ Troubleshoot+ </h3>+ </div>- <div- v-if="quickActionList.includes('environment.reorder')"- class="flex flex-col items-center w-28"- >- <button class="btn-icon-primary p-3" @click.prevent="reorderEnvironment">- <svg- class="transform rotate-90 w-6 h-6"- fill="none"- stroke="currentColor"- viewBox="0 0 24 24"- xmlns="http://www.w3.org/2000/svg"+ <div+ v-if="quickAction == 'quickaction.bytebase.environment.create'"+ class="flex flex-col items-center w-36"+ >+ <button class="btn-icon-primary p-3" @click.prevent="createEnvironment">+ <svg+ class="w-6 h-6"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M12 6v6m0 0v6m0-6h6m-6 0H6"+ ></path>+ </svg>+ </button>+ <h3 class="mt-1 text-center text-base font-normal text-main">+ Add Environment+ </h3>+ </div>++ <div+ v-if="quickAction == 'quickaction.bytebase.environment.reorder'"+ class="flex flex-col items-center w-28"+ >+ <button+ class="btn-icon-primary p-3"+ @click.prevent="reorderEnvironment">- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M8 9l4-4 4 4m0 6l-4 4-4-4"- ></path>- </svg>- </button>- <h3 class="mt-1 text-center text-base font-normal text-main">Reorder</h3>- </div>+ <svg+ class="transform rotate-90 w-6 h-6"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M8 9l4-4 4 4m0 6l-4 4-4-4"+ ></path>+ </svg>+ </button>+ <h3 class="mt-1 text-center text-base font-normal text-main">+ Reorder+ </h3>+ </div>+ </template></div><BBModalv-if="state.showCreateInstanceModal"diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vueindex c0e2058f5e..43afaf3529 100644--- a/frontend/src/layouts/BodyLayout.vue+++ b/frontend/src/layouts/BodyLayout.vue@@ -206,7 +206,15 @@ export default {});const quickActionList = computed(() => {- return router.currentRoute.value.meta.quickActionList;+ const user = store.getters["auth/currentUser"]();+ const role = store.getters["roleMapping/roleMappingByPrincipalId"](+ user.id+ ).role;+ const listByRole = router.currentRoute.value.meta.quickActionListByRole;+ if (listByRole?.get(role)?.length > 0) {+ return listByRole.get(role);+ }+ return undefined;});const showBreadcrumb = computed(() => {diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex a7366b6a66..f066f5e332 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -77,13 +77,35 @@ const routes: Array<RouteRecordRaw> = [path: "",name: HOME_MODULE,meta: {- quickActionList: [- "instance.create",- "user.manage",- "datasource.request",- "datasource.schema.update",- "ticket.create",- ],+ quickActionListByRole: new Map([+ [+ "OWNER",+ [+ "quickaction.bytebase.user.manage",+ "quickaction.bytebase.instance.create",+ "quickaction.bytebase.database.schema.update",+ "quickaction.bytebase.database.request",+ "quickaction.bytebase.database.troubleshoot",+ ],+ ],+ [+ "DBA",+ [+ "quickaction.bytebase.instance.create",+ "quickaction.bytebase.database.schema.update",+ "quickaction.bytebase.database.request",+ "quickaction.bytebase.database.troubleshoot",+ ],+ ],+ [+ "DEVELOPER",+ [+ "quickaction.bytebase.database.troubleshoot",+ "quickaction.bytebase.database.schema.update",+ "quickaction.bytebase.database.request",+ ],+ ],+ ]),},components: {content: Home,@@ -224,7 +246,22 @@ const routes: Array<RouteRecordRaw> = [name: "workspace.environment",meta: {title: () => "Environment",- quickActionList: ["environment.create", "environment.reorder"],+ quickActionListByRole: new Map([+ [+ "OWNER",+ [+ "quickaction.bytebase.environment.create",+ "quickaction.bytebase.environment.reorder",+ ],+ ],+ [+ "DBA",+ [+ "quickaction.bytebase.environment.create",+ "quickaction.bytebase.environment.reorder",+ ],+ ],+ ]),},components: {content: () => import("../views/EnvironmentDashboard.vue"),@@ -237,7 +274,10 @@ const routes: Array<RouteRecordRaw> = [name: "workspace.instance",meta: {title: () => "Instance",- quickActionList: ["instance.create"],+ quickActionListByRole: new Map([+ ["OWNER", ["quickaction.bytebase.instance.create"]],+ ["DBA", ["quickaction.bytebase.instance.create"]],+ ]),},components: {content: () => import("../views/InstanceDashboard.vue"),diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.tsindex 0a4a2b6049..5524412663 100644--- a/frontend/src/types/bytebase.ts+++ b/frontend/src/types/bytebase.ts@@ -347,6 +347,7 @@ export type Command = {run: () => void;};+// Notification// "id" and "createdTs" is auto generated upon the notification store// receives.export type NewNotification = Omit<Notification, "id" | "createdTs">;@@ -356,6 +357,23 @@ export type NotificationFilter = {id?: string;};+// Quick Action Type+export type EnvironmentQuickActionType =+ | "quickaction.bytebase.environment.create"+ | "quickaction.bytebase.environment.reorder";+export type InstanceQuickActionType = "quickaction.bytebase.instance.create";+export type UserQuickActionType = "quickaction.bytebase.user.manage";+export type DatabaseQuickActionType =+ | "quickaction.bytebase.database.request"+ | "quickaction.bytebase.database.schema.update"+ | "quickaction.bytebase.database.troubleshoot";++export type QuickActionType =+ | EnvironmentQuickActionType+ | InstanceQuickActionType+ | UserQuickActionType+ | DatabaseQuickActionType;+// Storeexport interface AuthState {currentUser: User | undefined;