Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Introduce “bytebase.dbaworkflow” feature set for extra dba workflow. This is available for enterprise.
天舟1098b5bd2b32
diff --git a/frontend/src/components/EnvironmentForm.vue b/frontend/src/components/EnvironmentForm.vueindex d7c4fd810f..4df92e6d6e 100644--- a/frontend/src/components/EnvironmentForm.vue+++ b/frontend/src/components/EnvironmentForm.vue@@ -87,7 +87,7 @@ import cloneDeep from "lodash-es/cloneDeep";import isEqual from "lodash-es/isEqual";import isEmpty from "lodash-es/isEmpty";import { Environment, EnvironmentNew, EnvironmentPatch } from "../types";-import { isDBA } from "../utils";+import { isDBAOrOwner } from "../utils";interface LocalState {environment: Environment | EnvironmentNew;@@ -132,7 +132,7 @@ export default {const allowEdit = computed(() => {return ((state.environment as Environment).rowStatus == "NORMAL" &&- isDBA(currentUser.value.role)+ isDBAOrOwner(currentUser.value.role));});diff --git a/frontend/src/components/MemberTable.vue b/frontend/src/components/MemberTable.vueindex eb7faf852a..aab4d8c003 100644--- a/frontend/src/components/MemberTable.vue+++ b/frontend/src/components/MemberTable.vue@@ -187,32 +187,43 @@ export default {roleMapping.updaterId),};- if (!hasAdminFeature.value || roleMappingUI.role === "DEVELOPER") {- developerList.push(roleMappingUI);- } else if (roleMappingUI.role === "OWNER") {++ if (roleMappingUI.role == "OWNER") {ownerList.push(roleMappingUI);- } else if (roleMappingUI.role === "DBA") {+ }++ if (roleMappingUI.role == "DBA") {dbaList.push(roleMappingUI);}++ if (roleMappingUI.role == "DEVELOPER") {+ developerList.push(roleMappingUI);+ }}+const dataSource: BBTableSectionDataSource<RoleMappingUI>[] = [];if (hasAdminFeature.value) {dataSource.push({title: "Owner",list: ownerList,});+dataSource.push({title: "DBA",list: dbaList,});+dataSource.push({title: "Developer",list: developerList,});} else {+ ownerList.push(...dbaList);+ ownerList.push(...developerList);+dataSource.push({title: "Member",- list: developerList,+ list: ownerList,});}return dataSource;diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vueindex e154b582a1..6d55300a31 100644--- a/frontend/src/components/QuickActionPanel.vue+++ b/frontend/src/components/QuickActionPanel.vue@@ -2,7 +2,10 @@<divclass="pt-1 overflow-hidden grid grid-cols-4 gap-x-2 gap-y-4 md:inline-flex md:gap-x-0">- <template v-for="(quickAction, index) in quickActionList" :key="index">+ <template+ v-for="(quickAction, index) in effectiveQuickActionList"+ :key="index"+ ><divv-if="quickAction == 'quickaction.bytebase.instance.create'"class="flex flex-col items-center w-28"@@ -323,13 +326,20 @@</template><script lang="ts">-import { reactive, PropType } from "vue";+import { reactive, PropType, computed } from "vue";+import { useRouter } from "vue-router";import { useStore } from "vuex";import ProjectNew from "../components/ProjectNew.vue";import InstanceForm from "../components/InstanceForm.vue";import RequestDatabasePrepForm from "../components/RequestDatabasePrepForm.vue";import { QuickActionType } from "../types";+// Quick action only applicable when DBA workflow feature is enabled.+const DBA_WORKFLOW_APPLICABLE_QUICK_ACTION_LIST: QuickActionType[] = [+ "quickaction.bytebase.database.request",+ "quickaction.bytebase.database.troubleshoot",+];+interface LocalState {showModal: Boolean;modalTitle: string;@@ -346,10 +356,11 @@ export default {props: {quickActionList: {required: true,- type: Object as PropType<String[]>,+ type: Object as PropType<QuickActionType[]>,},},- setup() {+ setup(props) {+ const router = useRouter();const store = useStore();const state = reactive<LocalState>({@@ -358,6 +369,16 @@ export default {quickActionType: "quickaction.bytebase.instance.create",});+ const effectiveQuickActionList = computed((): QuickActionType[] => {+ if (store.getters["plan/feature"]("bytebase.dbaworkflow")) {+ return props.quickActionList;+ }++ return props.quickActionList.filter((item: QuickActionType) => {+ return !DBA_WORKFLOW_APPLICABLE_QUICK_ACTION_LIST.includes(item);+ });+ });+const createProject = () => {state.modalTitle = "Create project";state.quickActionType = "quickaction.bytebase.project.create";@@ -370,12 +391,6 @@ export default {state.showModal = true;};- const createDatabase = () => {- state.modalTitle = "Create database";- state.quickActionType = "quickaction.bytebase.database.request";- state.showModal = true;- };-const requestDatabase = () => {state.modalTitle = "Request database";state.quickActionType = "quickaction.bytebase.database.request";@@ -392,9 +407,9 @@ export default {return {state,+ effectiveQuickActionList,createProject,createInstance,- createDatabase,requestDatabase,createEnvironment,reorderEnvironment,diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vueindex 7443822dc9..773a3df39e 100644--- a/frontend/src/layouts/BodyLayout.vue+++ b/frontend/src/layouts/BodyLayout.vue@@ -40,7 +40,7 @@<router-view name="leftSidebar" /></div><router-link- v-if="isCurrentUserDBA"+ v-if="isCurrentUserDBAOrOwner"to="/archive"class="outline-item group flex items-center px-4 py-2">@@ -100,7 +100,7 @@<router-view name="leftSidebar" /></div><router-link- v-if="isCurrentUserDBA"+ v-if="isCurrentUserDBAOrOwner"to="/archive"class="outline-item group flex items-center px-4 py-2">@@ -220,7 +220,7 @@ import Breadcrumb from "../components/Breadcrumb.vue";import Quickstart from "../components/Quickstart.vue";import QuickActionPanel from "../components/QuickActionPanel.vue";import { QuickActionType, RoleType } from "../types";-import { isDBA, isDeveloper, isOwner } from "../utils";+import { isDBA, isDBAOrOwner, isDeveloper, isOwner } from "../utils";interface LocalState {showMobileOverlay: boolean;@@ -282,8 +282,8 @@ export default {return list;});- const isCurrentUserDBA = computed((): boolean => {- return isDBA(currentUser.value.role);+ const isCurrentUserDBAOrOwner = computed((): boolean => {+ return isDBAOrOwner(currentUser.value.role);});const showBreadcrumb = computed(() => {@@ -298,7 +298,7 @@ export default {return {state,quickActionList,- isCurrentUserDBA,+ isCurrentUserDBAOrOwner,showBreadcrumb,showIntro,};diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex 512ff2523b..e9d2f7bc3d 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -17,7 +17,7 @@ import Signup from "../views/auth/Signup.vue";import Activate from "../views/auth/Activate.vue";import PasswordReset from "../views/auth/PasswordReset.vue";import { store } from "../store";-import { isDev, idFromSlug, isDBA } from "../utils";+import { isDev, idFromSlug, isDBAOrOwner } from "../utils";import { Principal } from "../types";const HOME_MODULE = "workspace.home";@@ -99,10 +99,10 @@ const routes: Array<RouteRecordRaw> = [["DEVELOPER",[- "quickaction.bytebase.database.troubleshoot","quickaction.bytebase.database.schema.update","quickaction.bytebase.database.request","quickaction.bytebase.project.create",+ "quickaction.bytebase.database.troubleshoot",],],]),@@ -595,18 +595,32 @@ router.beforeEach((to, from, next) => {to.name === "workspace.environment" ||to.name === "workspace.project" ||to.name === "workspace.database" ||- to.name === "workspace.database.create" ||to.name?.toString().startsWith("setting")) {next();return;}+ if (to.name === "workspace.database.create") {+ if (+ !store.getters["plan/feature"]("bytebase.dbaworkflow") ||+ isDBAOrOwner(loginUser.role)+ ) {+ next();+ } else {+ next({+ name: "error.403",+ replace: false,+ });+ }+ return;+ }+if (to.name === "workspace.archive" ||to.name?.toString().startsWith("workspace.instance")) {- if (isDBA(loginUser.role)) {+ if (isDBAOrOwner(loginUser.role)) {next();} else {next({@@ -618,7 +632,7 @@ router.beforeEach((to, from, next) => {}if (to.name?.toString().startsWith("workspace.database.datasource")) {- if (!isDBA(loginUser.role)) {+ if (!isDBAOrOwner(loginUser.role)) {next({name: "error.403",replace: false,diff --git a/frontend/src/store/modules/plan.ts b/frontend/src/store/modules/plan.tsindex 2fca71885e..fd3d933623 100644--- a/frontend/src/store/modules/plan.ts+++ b/frontend/src/store/modules/plan.ts@@ -3,6 +3,7 @@ import { FeatureType, PlanState, PlanType } from "../../types";// A map from the a particular feature to the respective enablement of a particular planconst FEATURE_MATRIX: Map<FeatureType, boolean[]> = new Map([["bytebase.admin", [false, true, true]],+ ["bytebase.dbaworkflow", [false, false, true]],]);const state: () => PlanState = () => ({diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.tsindex 681c1c5c8d..75e8c881ca 100644--- a/frontend/src/types/bytebase.ts+++ b/frontend/src/types/bytebase.ts@@ -827,8 +827,12 @@ export type ActivateInfo = {// Planexport type FeatureType =- // - Task can only be assigned to DBA and Owner- "bytebase.admin";+ // Support Owner and DBA role at the workspace level+ | "bytebase.admin"+ // Support DBA workflow, including+ // 1. Developers can't create database directly, they need to do this via a request db task.+ // 2. Allow developers to submit troubleshooting ticket.+ | "bytebase.dbaworkflow";export enum PlanType {FREE = 0,diff --git a/frontend/src/utils/database.ts b/frontend/src/utils/database.tsindex 94d13ad582..0bc9e0a87e 100644--- a/frontend/src/utils/database.ts+++ b/frontend/src/utils/database.ts@@ -5,14 +5,14 @@ import {DataSourceType,Principal,} from "../types";-import { isDBA } from "./role";+import { isDBAOrOwner } from "./role";export function allowDatabaseAccess(database: Database,principal: Principal,type: DataSourceType): boolean {- if (isDBA(principal.role)) {+ if (isDBAOrOwner(principal.role)) {return true;}diff --git a/frontend/src/utils/role.ts b/frontend/src/utils/role.tsindex 7a00cec783..09a062ce1c 100644--- a/frontend/src/utils/role.ts+++ b/frontend/src/utils/role.ts@@ -12,13 +12,13 @@ export function isOwner(role: RoleType): boolean {return !store.getters["plan/feature"]("bytebase.admin") || role == "OWNER";}-// Returns true if admin feature is NOT supported or the principal DBA or OWNER+// Returns true if admin feature is NOT supported or the principal is DBAexport function isDBA(role: RoleType): boolean {- return (- !store.getters["plan/feature"]("bytebase.admin") ||- role == "DBA" ||- role == "OWNER"- );+ return !store.getters["plan/feature"]("bytebase.admin") || role == "DBA";+}++export function isDBAOrOwner(role: RoleType): boolean {+ return isDBA(role) || isOwner(role);}// Returns true if admin feature is NOT supported or the principal is DEVELOPER@@ -28,6 +28,11 @@ export function isDeveloper(role: RoleType): boolean {);}+// Returns true if admin feature is NOT supported or the principal is GUEST+export function isGuest(role: RoleType): boolean {+ return !store.getters["plan/feature"]("bytebase.admin") || role == "GUEST";+}+export function roleName(role: RoleType): string {switch (role) {case "OWNER":diff --git a/frontend/src/views/DataSourceDetail.vue b/frontend/src/views/DataSourceDetail.vueindex ca0fef2eaf..dddd622a4a 100644--- a/frontend/src/views/DataSourceDetail.vue+++ b/frontend/src/views/DataSourceDetail.vue@@ -43,7 +43,7 @@{{ environmentName(dataSource.instance.environment) }}</router-link></dd>- <template v-if="isCurrentUserDBA">+ <template v-if="isCurrentUserDBAOrOwner"><dt class="sr-only">Instance</dt><dd class="flex items-center text-sm sm:mr-4"><span class="textlabel">Instance - </span>@@ -168,7 +168,7 @@ import cloneDeep from "lodash-es/cloneDeep";import isEqual from "lodash-es/isEqual";import DataSourceConnectionPanel from "../components/DataSourceConnectionPanel.vue";import DataSourceMemberTable from "../components/DataSourceMemberTable.vue";-import { idFromSlug, isDBA } from "../utils";+import { idFromSlug, isDBAOrOwner } from "../utils";import { DataSource, Principal } from "../types";interface LocalState {@@ -213,12 +213,12 @@ export default {});- const isCurrentUserDBA = computed((): boolean => {- return isDBA(currentUser.value.role);+ const isCurrentUserDBAOrOwner = computed((): boolean => {+ return isDBAOrOwner(currentUser.value.role);});const allowEdit = computed(() => {- return isDBA(currentUser.value.role);+ return isDBAOrOwner(currentUser.value.role);});const allowSave = computed(() => {@@ -279,7 +279,7 @@ export default {editNameTextField,state,dataSource,- isCurrentUserDBA,+ isCurrentUserDBAOrOwner,allowEdit,allowSave,editDataSource,diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vueindex 35ec54e936..91588beacd 100644--- a/frontend/src/views/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail.vue@@ -33,7 +33,7 @@{{ environmentName(database.instance.environment) }}</router-link></dd>- <template v-if="isCurrentUserDBA">+ <template v-if="isCurrentUserDBAOrOwner"><dt class="sr-only">Instance</dt><dd class="flex items-center text-sm md:mr-4"><span class="textlabel">Instance - </span>@@ -135,7 +135,7 @@<div v-for="(ds, index) of item.list" :key="index"><!-- Only displays the data source link for DBA. Since for nowwe don't need to expose the data source concept to the end user -->- <div v-if="isCurrentUserDBA" class="relative mb-2">+ <div v-if="isCurrentUserDBAOrOwner" class="relative mb-2"><divclass="absolute inset-0 flex items-center"aria-hidden="true"@@ -172,7 +172,7 @@ import DataSourceTable from "../components/DataSourceTable.vue";import DataSourceConnectionPanel from "../components/DataSourceConnectionPanel.vue";import PrincipalSelect from "../components/PrincipalSelect.vue";import ProjectSelect from "../components/ProjectSelect.vue";-import { idFromSlug, isDBA } from "../utils";+import { idFromSlug, isDBAOrOwner } from "../utils";import { PrincipalId, DataSource, ProjectId } from "../types";interface LocalState {@@ -212,26 +212,28 @@ export default {);});- const isCurrentUserDBA = computed((): boolean => {- return isDBA(currentUser.value.role);+ const isCurrentUserDBAOrOwner = computed((): boolean => {+ return isDBAOrOwner(currentUser.value.role);});const allowChangeProject = computed(() => {return (- currentUser.value.id == database.value.ownerId || isCurrentUserDBA.value+ currentUser.value.id == database.value.ownerId ||+ isCurrentUserDBAOrOwner.value);});const allowChangeOwner = computed(() => {return (- currentUser.value.id == database.value.ownerId || isCurrentUserDBA.value+ currentUser.value.id == database.value.ownerId ||+ isCurrentUserDBAOrOwner.value);});const dataSourceList = computed(() => {return database.value.dataSourceList.filter((dataSource: DataSource) => {return (- isCurrentUserDBA.value ||+ isCurrentUserDBAOrOwner.value ||// If the current user is not DBA, we will only show the granted data source.dataSource.memberList.find((item) => {return item.principal.id == currentUser.value.id;@@ -281,7 +283,7 @@ export default {return {state,database,- isCurrentUserDBA,+ isCurrentUserDBAOrOwner,allowChangeProject,allowChangeOwner,readWriteDataSourceList,diff --git a/frontend/src/views/Inbox.vue b/frontend/src/views/Inbox.vueindex 886fcffaac..2f8ef11497 100644--- a/frontend/src/views/Inbox.vue+++ b/frontend/src/views/Inbox.vue@@ -2,7 +2,7 @@<!-- This example requires Tailwind CSS v2.0+ --><div class="my-2 space-y-2 divide-y divide-block-border"><BBTableTabFilter- v-if="isCurrentUserDBA"+ v-if="isCurrentUserDBAOrOwner"class="mx-2":tabList="['General', 'Membership']":selectedIndex="state.selectedIndex"@@ -171,7 +171,7 @@ import {TaskUpdateStatusMessagePayload,UNKNOWN_ID,} from "../types";-import { isDBA, roleName } from "../utils";+import { isDBAOrOwner, roleName } from "../utils";const GENERAL_TAB = 0;const MEMBERSHIP_TAB = 1;@@ -219,8 +219,8 @@ export default {state.whitelist = [];});- const isCurrentUserDBA = computed((): boolean => {- return isDBA(currentUser.value.role);+ const isCurrentUserDBAOrOwner = computed((): boolean => {+ return isDBAOrOwner(currentUser.value.role);});const effectiveMessageList = computed(() => {@@ -377,7 +377,7 @@ export default {state,currentUser,principalFromId,- isCurrentUserDBA,+ isCurrentUserDBAOrOwner,effectiveMessageList,actionSentence,clickMessage,diff --git a/frontend/src/views/TaskSidebar.vue b/frontend/src/views/TaskSidebar.vueindex 602955a2d6..09ce285f41 100644--- a/frontend/src/views/TaskSidebar.vue+++ b/frontend/src/views/TaskSidebar.vue@@ -215,7 +215,7 @@ import {DatabaseFieldPayload,} from "../plugins";import { DatabaseId, EnvironmentId, Principal, Task } from "../types";-import { isDBA } from "../utils";+import { isDBAOrOwner } from "../utils";interface LocalState {}@@ -296,7 +296,7 @@ export default {props.new ||(props.task.status == "OPEN" &&(currentUser.value.id == props.task.assignee?.id ||- isDBA(currentUser.value.role)))+ isDBAOrOwner(currentUser.value.role))));});