Skip to content

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

Follow up the last commit, we will allow Developer to create database issue directly unless DBA workflow is enabled (Enterprise version)

天舟a453da5255d0
diff --git a/frontend/src/components/CreateDatabasePrepForm.vue b/frontend/src/components/CreateDatabasePrepForm.vue
index 1fac09d016..56a00d4283 100644
--- a/frontend/src/components/CreateDatabasePrepForm.vue
+++ b/frontend/src/components/CreateDatabasePrepForm.vue
@@ -87,6 +87,22 @@
v-model="state.collation"
/>
</div>
+
+ <div v-if="showAssigneeSelect" class="col-span-2 col-start-2 w-64">
+ <label for="user" class="textlabel">
+ Assignee <span class="text-red-600">*</span>
+ </label>
+ <!-- DBA and Owner always have all access, so we only need to grant to developer -->
+ <PrincipalSelect
+ class="mt-1"
+ id="user"
+ name="user"
+ :allowedRoleList="['OWNER', 'DBA']"
+ :selectedId="state.assigneeId"
+ :placeholder="'Select assignee'"
+ @select-principal-id="selectAssignee"
+ />
+ </div>
</div>
<!-- Create button group -->
<div class="pt-4 flex justify-end">
@@ -130,8 +146,9 @@ import {
ProjectId,
IssueCreate,
SYSTEM_BOT_ID,
+ PrincipalId,
} from "../types";
-import { issueSlug } from "../utils";
+import { isDBAOrOwner, issueSlug } from "../utils";
interface LocalState {
projectId?: ProjectId;
@@ -140,6 +157,7 @@ interface LocalState {
databaseName?: string;
characterSet: string;
collation: string;
+ assigneeId?: PrincipalId;
}
export default {
@@ -160,6 +178,8 @@ export default {
const store = useStore();
const router = useRouter();
+ const currentUser = computed(() => store.getters["auth/currentUser"]());
+
const keyboardHandler = (e: KeyboardEvent) => {
if (e.code == "Escape") {
cancel();
@@ -181,10 +201,15 @@ export default {
watchEffect(prepareInstanceList);
+ const showAssigneeSelect = computed(() => {
+ return !isDBAOrOwner(currentUser.value.role);
+ });
+
const state = reactive<LocalState>({
projectId: props.projectId,
characterSet: "utf8mb4",
collation: "utf8mb4_0900_ai_ci",
+ assigneeId: showAssigneeSelect.value ? undefined : SYSTEM_BOT_ID,
});
const allowCreate = computed(() => {
@@ -194,7 +219,8 @@ export default {
state.environmentId &&
state.instanceId &&
!isEmpty(state.characterSet) &&
- !isEmpty(state.collation)
+ !isEmpty(state.collation) &&
+ state.assigneeId
);
});
@@ -215,6 +241,10 @@ export default {
state.instanceId = instanceId;
};
+ const selectAssignee = (assigneeId: PrincipalId) => {
+ state.assigneeId = assigneeId;
+ };
+
const cancel = () => {
emit("dismiss");
};
@@ -224,7 +254,7 @@ export default {
name: `Create database ${state.databaseName}`,
type: "bb.issue.database.create",
description: "",
- assigneeId: SYSTEM_BOT_ID,
+ assigneeId: state.assigneeId,
projectId: state.projectId!,
pipeline: {
stageList: [
@@ -234,7 +264,11 @@ export default {
taskList: [
{
name: `Create database ${state.databaseName}`,
- status: "PENDING",
+ // If current user is DBA or Owner, then the created task will start automatically,
+ // otherwise, it will require approval.
+ status: isDBAOrOwner(currentUser.value.role)
+ ? "PENDING"
+ : "PENDING_APPROVAL",
type: "bb.task.database.create",
instanceId: state.instanceId!,
statement: `CREATE DATABASE \`${state.databaseName}\`\nCHARACTER SET ${state.characterSet} COLLATE ${state.collation}`,
@@ -266,9 +300,11 @@ export default {
state,
allowCreate,
allowEditProject,
+ showAssigneeSelect,
selectProject,
selectEnvironment,
selectInstance,
+ selectAssignee,
cancel,
create,
};
diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vue
index cfcf6076d5..8da5eb2180 100644
--- a/frontend/src/components/QuickActionPanel.vue
+++ b/frontend/src/components/QuickActionPanel.vue
@@ -5,14 +5,10 @@
overflow-hidden
grid grid-cols-4
gap-x-2 gap-y-4
- md:inline-flex
- md:gap-x-0
+ md:inline-flex md:gap-x-0
"
>
- <template
- v-for="(quickAction, index) in effectiveQuickActionList"
- :key="index"
- >
+ <template v-for="(quickAction, index) in quickActionList" :key="index">
<div
v-if="quickAction == 'quickaction.bb.instance.create'"
class="flex flex-col items-center w-28"
@@ -381,15 +377,9 @@ import InstanceForm from "../components/InstanceForm.vue";
import AlterSchemaPrepForm from "../components/AlterSchemaPrepForm.vue";
import CreateDatabasePrepForm from "../components/CreateDatabasePrepForm.vue";
import RequestDatabasePrepForm from "../components/RequestDatabasePrepForm.vue";
-import { ProjectId, QuickActionType, UNKNOWN_ID } from "../types";
+import { ProjectId, QuickActionType } from "../types";
import { idFromSlug } from "../utils";
-// Quick action only applicable when DBA workflow feature is enabled.
-const DBA_WORKFLOW_APPLICABLE_QUICK_ACTION_LIST: QuickActionType[] = [
- "quickaction.bb.database.request",
- "quickaction.bb.database.troubleshoot",
-];
-
interface LocalState {
showModal: Boolean;
modalTitle: string;
@@ -423,16 +413,6 @@ export default {
quickActionType: "quickaction.bb.instance.create",
});
- const effectiveQuickActionList = computed((): QuickActionType[] => {
- if (store.getters["plan/feature"]("bb.dba-workflow")) {
- return props.quickActionList;
- }
-
- return props.quickActionList.filter((item: QuickActionType) => {
- return !DBA_WORKFLOW_APPLICABLE_QUICK_ACTION_LIST.includes(item);
- });
- });
-
const projectId = computed((): ProjectId | undefined => {
if (router.currentRoute.value.name == "workspace.project.detail") {
const parts = router.currentRoute.value.path.split("/");
@@ -486,7 +466,6 @@ export default {
return {
state,
- effectiveQuickActionList,
projectId,
createProject,
createInstance,
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 075a72e76e..48f05a8db8 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -18,7 +18,7 @@ import Activate from "../views/auth/Activate.vue";
import PasswordReset from "../views/auth/PasswordReset.vue";
import { store } from "../store";
import { isDev, idFromSlug, isDBAOrOwner } from "../utils";
-import { Principal, UNKNOWN_ID } from "../types";
+import { Principal, QuickActionType, UNKNOWN_ID } from "../types";
const HOME_MODULE = "workspace.home";
const AUTH_MODULE = "auth";
@@ -82,6 +82,20 @@ const routes: Array<RouteRecordRaw> = [
name: HOME_MODULE,
meta: {
quickActionListByRole: () => {
+ const developerList: QuickActionType[] = store.getters[
+ "plan/feature"
+ ]("bb.dba-workflow")
+ ? [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.request",
+ "quickaction.bb.database.troubleshoot",
+ "quickaction.bb.project.create",
+ ]
+ : [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.create",
+ "quickaction.bb.project.create",
+ ];
return new Map([
[
"OWNER",
@@ -104,15 +118,7 @@ const routes: Array<RouteRecordRaw> = [
"quickaction.bb.project.create",
],
],
- [
- "DEVELOPER",
- [
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.request",
- "quickaction.bb.database.troubleshoot",
- "quickaction.bb.project.create",
- ],
- ],
+ ["DEVELOPER", developerList],
]);
},
},
@@ -431,6 +437,18 @@ const routes: Array<RouteRecordRaw> = [
meta: {
title: () => "Database",
quickActionListByRole: () => {
+ const developerList: QuickActionType[] = store.getters[
+ "plan/feature"
+ ]("bb.dba-workflow")
+ ? [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.request",
+ "quickaction.bb.database.troubleshoot",
+ ]
+ : [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.create",
+ ];
return new Map([
[
"OWNER",
@@ -446,14 +464,7 @@ const routes: Array<RouteRecordRaw> = [
"quickaction.bb.database.create",
],
],
- [
- "DEVELOPER",
- [
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.request",
- "quickaction.bb.database.troubleshoot",
- ],
- ],
+ ["DEVELOPER", developerList],
]);
},
},