Skip to content

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

Introduce mode to DatabaseTable with “ALL”, “INSTANCE”, “PROJECT”

天舟017cc3442543
diff --git a/frontend/src/components/DatabaseTable.vue b/frontend/src/components/DatabaseTable.vue
index cf17d08abf..45144d7ce5 100644
--- a/frontend/src/components/DatabaseTable.vue
+++ b/frontend/src/components/DatabaseTable.vue
@@ -11,13 +11,13 @@
<BBTableCell :leftPadding="4" class="w-16">
{{ database.name }}
</BBTableCell>
- <BBTableCell class="w-16">
+ <BBTableCell v-if="mode != 'PROJECT'" class="w-16">
{{ projectName(database.project) }}
</BBTableCell>
- <BBTableCell v-if="!singleInstance" class="w-12">
+ <BBTableCell v-if="mode != 'INSTANCE'" class="w-12">
{{ environmentName(database.instance.environment) }}
</BBTableCell>
- <BBTableCell v-if="!singleInstance" class="w-24">
+ <BBTableCell v-if="mode == 'ALL'" class="w-24">
{{ instanceName(database.instance) }}
</BBTableCell>
<BBTableCell class="w-8" v-database-sync-status>
@@ -36,42 +36,69 @@ import { useStore } from "vuex";
import { useRouter } from "vue-router";
import { databaseSlug } from "../utils";
import { Database } from "../types";
+import { BBTableColumn } from "../bbkit/types";
-const COLUMN_LIST = [
- {
- title: "Name",
- },
- {
- title: "Project",
- },
- {
- title: "Environment",
- },
- {
- title: "Instance",
- },
- {
- title: "Sync status",
- },
- {
- title: "Last successful sync",
- },
-];
+type Mode = "ALL" | "INSTANCE" | "PROJECT";
-const COLUMN_LIST_SINGLE_INSTANCE = [
- {
- title: "Name",
- },
- {
- title: "Project",
- },
- {
- title: "Sync status",
- },
- {
- title: "Last successful sync",
- },
-];
+const columnListMap: Map<Mode, BBTableColumn[]> = new Map([
+ [
+ "ALL",
+ [
+ {
+ title: "Name",
+ },
+ {
+ title: "Project",
+ },
+ {
+ title: "Environment",
+ },
+ {
+ title: "Instance",
+ },
+ {
+ title: "Sync status",
+ },
+ {
+ title: "Last successful sync",
+ },
+ ],
+ ],
+ [
+ "INSTANCE",
+ [
+ {
+ title: "Name",
+ },
+ {
+ title: "Project",
+ },
+ {
+ title: "Sync status",
+ },
+ {
+ title: "Last successful sync",
+ },
+ ],
+ ],
+ [
+ "PROJECT",
+ [
+ {
+ title: "Name",
+ },
+ {
+ title: "Environment",
+ },
+ {
+ title: "Sync status",
+ },
+ {
+ title: "Last successful sync",
+ },
+ ],
+ ],
+]);
export default {
name: "DatabaseTable",
@@ -81,6 +108,10 @@ export default {
default: true,
type: Boolean,
},
+ mode: {
+ default: "ALL",
+ type: String as PropType<Mode>,
+ },
singleInstance: {
default: true,
type: Boolean,
@@ -100,9 +131,7 @@ export default {
};
return {
- columnList: props.singleInstance
- ? COLUMN_LIST_SINGLE_INSTANCE
- : COLUMN_LIST,
+ columnList: columnListMap.get(props.mode),
clickDatabase,
};
},
diff --git a/frontend/src/store/modules/database.ts b/frontend/src/store/modules/database.ts
index 070072ce0f..135dc6066c 100644
--- a/frontend/src/store/modules/database.ts
+++ b/frontend/src/store/modules/database.ts
@@ -147,6 +147,20 @@ const getters = {
return list;
},
+ databaseListByProjectId: (state: DatabaseState) => (
+ projectId: ProjectId
+ ): Database[] => {
+ const list: Database[] = [];
+ for (let [_, databaseList] of state.databaseListByInstanceId) {
+ databaseList.forEach((item: Database) => {
+ if (item.project.id == projectId) {
+ list.push(item);
+ }
+ });
+ }
+ return list;
+ },
+
// If caller provides scoped search in any of accepted idParams, we search that first.
// If none is found, we then do an exhaustive search.
// We have to do this because we store the fetched database info differently based on
diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vue
index 860a116e7f..0be686e3ff 100644
--- a/frontend/src/views/DatabaseDashboard.vue
+++ b/frontend/src/views/DatabaseDashboard.vue
@@ -11,11 +11,7 @@
@change-text="(text) => changeSearchText(text)"
/>
</div>
- <DatabaseTable
- :singleInstance="false"
- :bordered="false"
- :databaseList="filteredList"
- />
+ <DatabaseTable :bordered="false" :databaseList="filteredList" />
</div>
</template>
diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vue
index 95cc3d4481..bba58fd6c6 100644
--- a/frontend/src/views/InstanceDetail.vue
+++ b/frontend/src/views/InstanceDetail.vue
@@ -17,7 +17,7 @@
@add="tryAddDatabase"
/>
</div>
- <DatabaseTable :singleInstance="true" :databaseList="databaseList" />
+ <DatabaseTable :mode="'INSTANCE'" :databaseList="databaseList" />
</div>
<template v-if="instance.rowStatus == 'NORMAL'">
<BBButtonConfirm
diff --git a/frontend/src/views/ProjectDetail.vue b/frontend/src/views/ProjectDetail.vue
index 023bcce6ae..6d3ffaf8b1 100644
--- a/frontend/src/views/ProjectDetail.vue
+++ b/frontend/src/views/ProjectDetail.vue
@@ -16,38 +16,42 @@
}
"
/>
- <div class="max-w-4xl mx-auto py-6 px-4 space-y-4 sm:px-6 lg:px-8">
- <template v-if="state.selectedIndex == OVERVIEW_TAB"> </template>
+ <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
+ <template v-if="state.selectedIndex == OVERVIEW_TAB">
+ <DatabaseTable :mode="'PROJECT'" :databaseList="databaseList"
+ /></template>
<template v-else-if="state.selectedIndex == REPO_TAB"> </template>
<template v-else-if="state.selectedIndex == SETTING_TAB">
- <div class="divide-y divide-block-border space-y-6">
- <ProjectGeneralSettingPanel :project="project" />
- <ProjectMemberPanel class="pt-4" :project="project" />
- </div>
- <template v-if="allowArchiveOrRestore">
- <template v-if="project.rowStatus == 'NORMAL'">
- <BBButtonConfirm
- :style="'ARCHIVE'"
- :buttonText="'Archive this project'"
- :okText="'Archive'"
- :confirmTitle="`Archive project '${project.name}'?`"
- :confirmDescription="'Archived project will not be shown on the normal interface. You can still restore later from the Archive page.'"
- :requireConfirm="true"
- @confirm="archiveOrRestoreProject(true)"
- />
- </template>
- <template v-else-if="project.rowStatus == 'ARCHIVED'">
- <BBButtonConfirm
- :style="'RESTORE'"
- :buttonText="'Restore this project'"
- :okText="'Restore'"
- :confirmTitle="`Restore project '${project.name}' to normal state?`"
- :confirmDescription="''"
- :requireConfirm="true"
- @confirm="archiveOrRestoreProject(false)"
- />
+ <div class="max-w-3xl mx-auto space-y-4">
+ <div class="divide-y divide-block-border space-y-6">
+ <ProjectGeneralSettingPanel :project="project" />
+ <ProjectMemberPanel class="pt-4" :project="project" />
+ </div>
+ <template v-if="allowArchiveOrRestore">
+ <template v-if="project.rowStatus == 'NORMAL'">
+ <BBButtonConfirm
+ :style="'ARCHIVE'"
+ :buttonText="'Archive this project'"
+ :okText="'Archive'"
+ :confirmTitle="`Archive project '${project.name}'?`"
+ :confirmDescription="'Archived project will not be shown on the normal interface. You can still restore later from the Archive page.'"
+ :requireConfirm="true"
+ @confirm="archiveOrRestoreProject(true)"
+ />
+ </template>
+ <template v-else-if="project.rowStatus == 'ARCHIVED'">
+ <BBButtonConfirm
+ :style="'RESTORE'"
+ :buttonText="'Restore this project'"
+ :okText="'Restore'"
+ :confirmTitle="`Restore project '${project.name}' to normal state?`"
+ :confirmDescription="''"
+ :requireConfirm="true"
+ @confirm="archiveOrRestoreProject(false)"
+ />
+ </template>
</template>
- </template>
+ </div>
</template>
</div>
</template>
@@ -86,7 +90,7 @@ export default {
setup(props, { emit }) {
const store = useStore();
const state = reactive<LocalState>({
- selectedIndex: SETTING_TAB,
+ selectedIndex: OVERVIEW_TAB,
});
const currentUser = computed(() => store.getters["auth/currentUser"]());
@@ -97,6 +101,12 @@ export default {
);
});
+ const databaseList = computed(() => {
+ return store.getters["database/databaseListByInstanceId"](
+ project.value.id
+ );
+ });
+
// Only the project owner can archive/restore the project info.
// This means even the workspace owner won't be able to edit it.
// There seems to be no good reason that workspace owner needs to archive/restore the project.
@@ -130,6 +140,7 @@ export default {
SETTING_TAB,
state,
project,
+ databaseList,
allowArchiveOrRestore,
archiveOrRestoreProject,
};