Skip to content

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

Use the default project for the admin database when creating instance

天舟babc2ecfe84e
diff --git a/frontend/src/components/InstanceForm.vue b/frontend/src/components/InstanceForm.vue
index 89a2876f19..4ed50b1c89 100644
--- a/frontend/src/components/InstanceForm.vue
+++ b/frontend/src/components/InstanceForm.vue
@@ -298,6 +298,7 @@ import {
ALL_DATABASE_NAME,
Principal,
InstancePatch,
+ DEFAULT_PROJECT_ID,
} from "../types";
interface LocalState {
@@ -385,6 +386,7 @@ export default {
const createdDatabase = await store.dispatch("database/createDatabase", {
name: ALL_DATABASE_NAME,
instanceId: createdInstance.id,
+ projectId: DEFAULT_PROJECT_ID,
creatorId: currentUser.value.id,
});
diff --git a/frontend/src/components/ProjectSelect.vue b/frontend/src/components/ProjectSelect.vue
index 470d6a18a5..9cf6c71aa3 100644
--- a/frontend/src/components/ProjectSelect.vue
+++ b/frontend/src/components/ProjectSelect.vue
@@ -44,7 +44,7 @@
<script lang="ts">
import { computed, ComputedRef, reactive, watch, watchEffect } from "vue";
import { useStore } from "vuex";
-import { Principal, Project, UNKNOWN_ID } from "../types";
+import { DEFAULT_PROJECT_ID, Principal, Project, UNKNOWN_ID } from "../types";
import { isDBAOrOwner } from "../utils";
interface LocalState {
@@ -93,9 +93,10 @@ export default {
watchEffect(prepareProjectList);
const projectList = computed((): Project[] => {
- return isDBAOrOwner(currentUser.value.role)
+ const list = isDBAOrOwner(currentUser.value.role)
? store.getters["project/projectList"]()
: store.getters["project/projectListByUser"](currentUser.value.id);
+ return list;
});
const selectedIdNotInList = computed((): boolean => {
diff --git a/frontend/src/components/ProvideContext.vue b/frontend/src/components/ProvideContext.vue
index 8285c24b56..3b80f9fa04 100644
--- a/frontend/src/components/ProvideContext.vue
+++ b/frontend/src/components/ProvideContext.vue
@@ -4,7 +4,7 @@
<script lang="ts">
import { useStore } from "vuex";
-import { Principal } from "../types";
+import { Principal, DEFAULT_PROJECT_ID } from "../types";
export default {
name: "ProvideContext",
@@ -20,6 +20,8 @@ export default {
store.dispatch("roleMapping/fetchRoleMappingList"),
// fetchPrincipalList relies on fetchRoleMappingList to find the role of the principal.
store.dispatch("principal/fetchPrincipalList"),
+ // The default project hosts databases not explicitly assigned to other users project.
+ store.dispatch("project/fetchProjectById", DEFAULT_PROJECT_ID),
store.dispatch("instance/fetchInstanceList"),
// [TODO] Fetches all databases. This may cause performance issue if the entire fleet
// has a lot of databases.
diff --git a/frontend/src/miragejs/fixtures/projectList.json b/frontend/src/miragejs/fixtures/projectList.json
index e45cfe9461..a369be5a58 100644
--- a/frontend/src/miragejs/fixtures/projectList.json
+++ b/frontend/src/miragejs/fixtures/projectList.json
@@ -1,20 +1,22 @@
[
{
"id": "1",
+ "rowStatus": "NORMAL",
"workspaceId": "1",
"creatorId": "1",
"updaterId": "1",
"createdTs": 1614528000000,
"lastUpdatedTs": 1614571200000,
- "name": "DBA Project"
+ "name": "Default"
},
{
"id": "2",
+ "rowStatus": "NORMAL",
"workspaceId": "101",
"creatorId": "4",
"updaterId": "4",
"createdTs": 1614528000000,
"lastUpdatedTs": 1614571200000,
- "name": "DBA Project2"
+ "name": "Default"
}
]
diff --git a/frontend/src/store/modules/project.ts b/frontend/src/store/modules/project.ts
index 70d41521a1..7859cb3d73 100644
--- a/frontend/src/store/modules/project.ts
+++ b/frontend/src/store/modules/project.ts
@@ -13,7 +13,6 @@ import {
ProjectRoleMappingPatch,
RoleMappingId,
PrincipalId,
- UNKNOWN_ID,
ResourceIdentifier,
} from "../../types";
diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.ts
index 55d9fb1348..7ea54389f3 100644
--- a/frontend/src/types/bytebase.ts
+++ b/frontend/src/types/bytebase.ts
@@ -4,6 +4,8 @@ import { FieldId } from "../plugins";
export const UNKNOWN_ID = "-1";
+export const DEFAULT_PROJECT_ID = "1";
+
export type ResourceType =
| "PRINCIPAL"
| "EXECUTION"