Skip to content

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

chore: update schema design table (#7819)

boojack747b42ca5e65
diff --git a/frontend/src/components/DatabaseInfo.vue b/frontend/src/components/DatabaseInfo.vue
new file mode 100644
index 0000000000..06e8e8911c
--- /dev/null
+++ b/frontend/src/components/DatabaseInfo.vue
@@ -0,0 +1,57 @@
+<template>
+ <div class="flex items-center flex-wrap gap-1" @click.stop.prevent>
+ <InstanceV1Name
+ :instance="database.instanceEntity"
+ :plain="true"
+ text-class="hover:underline"
+ >
+ <template
+ v-if="
+ database.instanceEntity.environment !== database.effectiveEnvironment
+ "
+ #prefix
+ >
+ <EnvironmentV1Name
+ :environment="database.instanceEntity.environmentEntity"
+ :plain="true"
+ :show-icon="false"
+ text-class="hover:underline text-control-light"
+ />
+ </template>
+ </InstanceV1Name>
+
+ <heroicons-outline:chevron-right class="text-control-light" />
+
+ <div class="flex items-center gap-x-1">
+ <heroicons-outline:database />
+
+ <template v-if="database">
+ <EnvironmentV1Name
+ :environment="database.effectiveEnvironmentEntity"
+ :plain="true"
+ :show-icon="false"
+ text-class="hover:underline text-control-light"
+ />
+
+ <DatabaseV1Name
+ :database="database"
+ :plain="true"
+ class="hover:underline"
+ />
+ </template>
+
+ <SQLEditorButtonV1 v-if="showSQLEditorButton" :database="database" />
+ </div>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { SQLEditorButtonV1 } from "@/components/DatabaseDetail";
+import { DatabaseV1Name, InstanceV1Name } from "@/components/v2";
+import { ComposedDatabase } from "@/types";
+
+defineProps<{
+ database: ComposedDatabase;
+ showSQLEditorButton?: boolean;
+}>();
+</script>
diff --git a/frontend/src/components/ProjectBranchesPanel.vue b/frontend/src/components/ProjectBranchesPanel.vue
new file mode 100644
index 0000000000..97e14829e6
--- /dev/null
+++ b/frontend/src/components/ProjectBranchesPanel.vue
@@ -0,0 +1,89 @@
+<template>
+ <div
+ class="space-y-3 w-full sm:w-[calc(100vw-16rem)] max-w-[calc(100vw-8rem)] overflow-x-auto"
+ >
+ <div
+ class="w-full border-b pb-2 mb-2 flex flex-row justify-between items-center"
+ >
+ <div class="flex flex-row justify-start items-center space-x-2"></div>
+ <div>
+ <NButton type="primary" @click="state.showCreatePanel = true">
+ <heroicons-solid:plus class="w-4 h-auto mr-0.5" />
+ <span>{{ $t("database.new-branch") }}</span>
+ </NButton>
+ </div>
+ </div>
+
+ <SchemaDesignTable
+ v-if="ready"
+ :schema-designs="sortedSchemaDesignList"
+ @click="handleSchemaDesignItemClick"
+ />
+ <div v-else class="w-full h-[20rem] flex items-center justify-center">
+ <BBSpin />
+ </div>
+ </div>
+
+ <CreateSchemaDesignPanel
+ v-if="state.showCreatePanel"
+ :project-id="projectId"
+ @dismiss="state.showCreatePanel = false"
+ @created="
+ (schemaDesign: SchemaDesign) => {
+ state.showCreatePanel = false;
+ handleSchemaDesignItemClick(schemaDesign);
+ }
+ "
+ />
+
+ <EditSchemaDesignPanel
+ v-if="state.selectedSchemaDesignName"
+ :schema-design-name="state.selectedSchemaDesignName"
+ @dismiss="state.selectedSchemaDesignName = undefined"
+ />
+</template>
+
+<script lang="ts" setup>
+import { orderBy } from "lodash-es";
+import { NButton } from "naive-ui";
+import { computed, reactive } from "vue";
+import CreateSchemaDesignPanel from "@/components/SchemaDesigner/CreateSchemaDesignPanel.vue";
+import EditSchemaDesignPanel from "@/components/SchemaDesigner/EditSchemaDesignPanel.vue";
+import SchemaDesignTable from "@/components/SchemaDesigner/PrepForm/SchemaDesignTable.vue";
+import { useProjectV1Store } from "@/store";
+import { useSchemaDesignList } from "@/store/modules/schemaDesign";
+import { SchemaDesign } from "@/types/proto/v1/schema_design_service";
+
+const props = defineProps<{
+ projectId?: string;
+}>();
+
+interface LocalState {
+ showCreatePanel: boolean;
+ selectedSchemaDesignName?: string;
+}
+
+const projectV1Store = useProjectV1Store();
+const { schemaDesignList, ready } = useSchemaDesignList();
+const state = reactive<LocalState>({
+ showCreatePanel: false,
+});
+
+const project = computed(() =>
+ projectV1Store.getProjectByUID(props.projectId || "")
+);
+
+const sortedSchemaDesignList = computed(() => {
+ return orderBy(
+ schemaDesignList.value.filter((schemaDesign) =>
+ schemaDesign.name.startsWith(project.value.name)
+ ),
+ "updateTime",
+ "desc"
+ );
+});
+
+const handleSchemaDesignItemClick = async (schemaDesign: SchemaDesign) => {
+ state.selectedSchemaDesignName = schemaDesign.name;
+};
+</script>
diff --git a/frontend/src/components/SchemaDesigner/PrepForm/SchemaDesignTable.vue b/frontend/src/components/SchemaDesigner/PrepForm/SchemaDesignTable.vue
index 398f54c2ea..781f0e14e8 100644
--- a/frontend/src/components/SchemaDesigner/PrepForm/SchemaDesignTable.vue
+++ b/frontend/src/components/SchemaDesigner/PrepForm/SchemaDesignTable.vue
@@ -9,40 +9,21 @@
>
<template #item="{ item: schemaDesign }: { item: SchemaDesign }">
<div class="bb-grid-cell">
- <div class="flex flex-row justify-start items-center">
- <EngineIcon
- class="mr-2"
- :engine="getFormatedValue(schemaDesign).engine"
- />
- <span>{{ schemaDesign.title }}</span>
- </div>
+ {{ projectV1Name(getFormatedValue(schemaDesign).project) }}
</div>
<div class="bb-grid-cell">
- {{ getFormatedValue(schemaDesign).project }}
+ {{ schemaDesign.title }}
</div>
<div class="bb-grid-cell">
- <div class="flex flex-row items-center">
- <BBAvatar
- :size="'TINY'"
- :username="getFormatedValue(schemaDesign).creator"
- />
- {{ getFormatedValue(schemaDesign).creator }}
- </div>
+ {{ getFormatedValue(schemaDesign).parentBranch }}
</div>
<div class="bb-grid-cell">
- <div class="flex flex-row items-center">
- <BBAvatar
- :size="'TINY'"
- :username="getFormatedValue(schemaDesign).updater"
- />
- {{ getFormatedValue(schemaDesign).updater }}
- </div>
+ <DatabaseInfo :database="getFormatedValue(schemaDesign).database" />
</div>
<div class="bb-grid-cell">
- <HumanizeTs
- :ts="(schemaDesign.updateTime?.getTime() ?? 0) / 1000"
- class="ml-1"
- />
+ <span class="text-gray-400">{{
+ getFormatedValue(schemaDesign).updatedTimeStr
+ }}</span>
</div>
</template>
</BBGrid>
@@ -54,9 +35,14 @@ import dayjs from "dayjs";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { BBGridColumn } from "@/bbkit";
-import { useProjectV1Store, useUserStore } from "@/store";
+import DatabaseInfo from "@/components/DatabaseInfo.vue";
+import { useDatabaseV1Store, useProjectV1Store, useUserStore } from "@/store";
+import { useSchemaDesignStore } from "@/store/modules/schemaDesign";
import { getProjectAndSchemaDesignSheetId } from "@/store/modules/v1/common";
-import { SchemaDesign } from "@/types/proto/v1/schema_design_service";
+import {
+ SchemaDesign,
+ SchemaDesign_Type,
+} from "@/types/proto/v1/schema_design_service";
import { projectV1Name } from "@/utils";
const emit = defineEmits<{
@@ -68,18 +54,21 @@ defineProps<{
}>();
const { t } = useI18n();
+const userV1Store = useUserStore();
const projectV1Store = useProjectV1Store();
+const databaseV1Store = useDatabaseV1Store();
+const schemaDesignStore = useSchemaDesignStore();
const COLUMN_LIST = computed(() => {
const columns: BBGridColumn[] = [
- { title: t("database.branch"), width: "1fr" },
{
title: t("common.project"),
- width: "1fr",
+ width: "minmax(auto, 8rem)",
},
- { title: t("common.creator"), width: "minmax(auto, 10rem)" },
- { title: t("common.updater"), width: "minmax(auto, 10rem)" },
- { title: t("common.updated-at"), width: "minmax(auto, 10rem)" },
+ { title: t("database.branch"), width: "minmax(auto, 8rem)" },
+ { title: t("schema-designer.parent-branch"), width: "minmax(auto, 8rem)" },
+ { title: t("common.database"), width: "1fr" },
+ { title: "", width: "1fr" },
];
return columns;
@@ -88,20 +77,32 @@ const COLUMN_LIST = computed(() => {
const getFormatedValue = (schemaDesign: SchemaDesign) => {
const [projectName] = getProjectAndSchemaDesignSheetId(schemaDesign.name);
const project = projectV1Store.getProjectByName(`projects/${projectName}`);
+ let parentBranch = "";
+ if (schemaDesign.type === SchemaDesign_Type.PERSONAL_DRAFT) {
+ const parentSchemaDesign = schemaDesignStore.getSchemaDesignByName(
+ schemaDesign.baselineSheetName
+ );
+ if (parentSchemaDesign) {
+ parentBranch = parentSchemaDesign.title;
+ }
+ }
- return {
- name: schemaDesign.title,
- project: projectV1Name(project),
- engine: schemaDesign.engine,
- creator:
- useUserStore().getUserByIdentifier(schemaDesign.creator)?.title ??
- schemaDesign.creator,
- updater:
- useUserStore().getUserByIdentifier(schemaDesign.updater)?.title ??
- schemaDesign.updater,
- updated: dayjs
+ const updater = userV1Store.getUserByEmail(
+ schemaDesign.updater.split("/")[1]
+ );
+ const updatedTimeStr = t("schema-designer.message.updated-time-by-user", {
+ time: dayjs
.duration((schemaDesign.updateTime ?? new Date()).getTime() - Date.now())
.humanize(true),
+ user: updater?.title,
+ });
+
+ return {
+ name: schemaDesign.title,
+ project: project,
+ database: databaseV1Store.getDatabaseByName(schemaDesign.baselineDatabase),
+ parentBranch: parentBranch,
+ updatedTimeStr,
};
};
diff --git a/frontend/src/layouts/ProjectLayout.vue b/frontend/src/layouts/ProjectLayout.vue
index 1295fcfca9..515d02eb5f 100644
--- a/frontend/src/layouts/ProjectLayout.vue
+++ b/frontend/src/layouts/ProjectLayout.vue
@@ -120,6 +120,7 @@ const projectTabItemList = computed((): ProjectTabItem[] => {
const list: (ProjectTabItem | null)[] = [
{ name: t("common.overview"), hash: "overview" },
+ { name: t("common.branches"), hash: "branches" },
{ name: t("common.databases"), hash: "databases" },
isTenantProject.value
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 068290d733..45aa49cfb5 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -258,7 +258,8 @@
"schedule": "Schedule",
"state": "State",
"condition": "Condition",
- "search-user": "Search user"
+ "search-user": "Search user",
+ "branches": "Branches"
},
"error-page": {
"go-back-home": "Go back home"
@@ -2814,6 +2815,7 @@
"schema-version": "Schema version",
"personal-draft": "Personal draft",
"baseline-version": "Baseline version",
+ "parent-branch": "Parent branch",
"save-draft": "Save draft",
"merge-to-main": "Merge to main",
"diff-editor": {
@@ -2833,7 +2835,8 @@
"message": {
"created-succeed": "Schema design created successfully",
"updated-succeed": "Schema design updated successfully",
- "merge-to-main-successfully": "Merge to main successfully"
+ "merge-to-main-successfully": "Merge to main successfully",
+ "updated-time-by-user": "Updated {time} by {user}"
}
},
"cel": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 72c4de45e1..19d1ce7109 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -258,7 +258,8 @@
"schedule": "Horario",
"state": "Estado",
"condition": "Condición",
- "search-user": "Buscar usuario"
+ "search-user": "Buscar usuario",
+ "branches": "Ramas"
},
"error-page": {
"go-back-home": "Volver al inicio"
@@ -2812,6 +2813,7 @@
"schema-version": "Versión del esquema",
"personal-draft": "Borrador personal",
"baseline-version": "Versión de referencia",
+ "parent-branch": "Rama principal",
"save-draft": "Guardar borrador",
"merge-to-main": "Fusionar a principal",
"diff-editor": {
@@ -2831,7 +2833,8 @@
"message": {
"created-succeed": "Diseño de esquema creado con éxito",
"updated-succeed": "Diseño de esquema actualizado con éxito",
- "merge-to-main-successfully": "Fusionar con el principal exitosamente"
+ "merge-to-main-successfully": "Fusionar con el principal exitosamente",
+ "updated-time-by-user": "Actualizado por {user} en {time}"
}
},
"cel": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index db38c7576c..3b16b81158 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -256,7 +256,8 @@
"schedule": "计划",
"state": "状态",
"condition": "条件",
- "search-user": "搜索用户"
+ "search-user": "搜索用户",
+ "branches": "分支"
},
"error-page": {
"go-back-home": "回到主页"
@@ -2807,6 +2808,7 @@
"schema-version": "Schema 版本",
"personal-draft": "个人草稿",
"baseline-version": "基线版本",
+ "parent-branch": "父分支",
"save-draft": "保存草稿",
"merge-to-main": "合并到主版本",
"diff-editor": {
@@ -2826,7 +2828,8 @@
"message": {
"created-succeed": "Schema 设计创建成功",
"updated-succeed": "Schema 设计更新成功",
- "merge-to-main-successfully": "成功合并到主版本"
+ "merge-to-main-successfully": "成功合并到主版本",
+ "updated-time-by-user": "由 {user} 于 {time} 更新"
}
},
"cel": {
diff --git a/frontend/src/store/modules/schemaDesign.ts b/frontend/src/store/modules/schemaDesign.ts
index fd3cee48d5..a566776e14 100644
--- a/frontend/src/store/modules/schemaDesign.ts
+++ b/frontend/src/store/modules/schemaDesign.ts
@@ -172,10 +172,7 @@ export const useSchemaDesignList = () => {
});
const schemaDesignList = computed(() => {
- // Only return main branch schema designs in the list.
- return store.schemaDesignList.filter((schemaDesign) => {
- return schemaDesign.type === SchemaDesign_Type.MAIN_BRANCH;
- });
+ return store.schemaDesignList;
});
return { schemaDesignList, ready };
diff --git a/frontend/src/views/ProjectDetail.vue b/frontend/src/views/ProjectDetail.vue
index c69fba7ef1..cc3d2ab31e 100644
--- a/frontend/src/views/ProjectDetail.vue
+++ b/frontend/src/views/ProjectDetail.vue
@@ -2,6 +2,9 @@
<template v-if="hash === 'overview'">
<ProjectOverviewPanel id="overview" :project="project" />
</template>
+ <template v-if="hash === 'branches'">
+ <ProjectBranchesPanel id="branches" :project-id="project.uid" />
+ </template>
<template v-if="hash === 'databases'">
<ProjectDeploymentConfigPanel
v-if="isTenantProject"
@@ -61,6 +64,7 @@
import { computed } from "vue";
import { useRoute } from "vue-router";
import ProjectDatabaseGroupPanel from "@/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue";
+import ProjectBranchesPanel from "@/components/ProjectBranchesPanel.vue";
import {
useSearchDatabaseV1List,
useDatabaseV1Store,
diff --git a/frontend/src/views/SyncDatabaseSchema/SchemaDesignSelector.vue b/frontend/src/views/SyncDatabaseSchema/SchemaDesignSelector.vue
index 5e91ba7545..795bf279de 100644
--- a/frontend/src/views/SyncDatabaseSchema/SchemaDesignSelector.vue
+++ b/frontend/src/views/SyncDatabaseSchema/SchemaDesignSelector.vue
@@ -25,29 +25,23 @@
<NRadio :checked="schemaDesign.name === selectedSchemaDesign?.name" />
</div>
<div class="bb-grid-cell">
- <div class="flex flex-row justify-start items-center">
- <EngineIcon
- class="mr-2"
- :engine="getFormatedValue(schemaDesign).engine"
- />
- <span>{{ schemaDesign.title }}</span>
- </div>
+ {{ projectV1Name(getFormatedValue(schemaDesign).project) }}
</div>
<div class="bb-grid-cell">
- {{ getFormatedValue(schemaDesign).project }}
+ {{ schemaDesign.title }}
</div>
<div class="bb-grid-cell">
- {{ getFormatedValue(schemaDesign).creator }}
+ {{ getFormatedValue(schemaDesign).parentBranch }}
</div>
<div class="bb-grid-cell">
- {{ getFormatedValue(schemaDesign).updater }}
+ <DatabaseInfo :database="getFormatedValue(schemaDesign).database" />
</div>
<div class="bb-grid-cell">
- <HumanizeTs
- :ts="(schemaDesign.updateTime?.getTime() ?? 0) / 1000"
- class="ml-1"
- />
+ <span class="text-gray-400">{{
+ getFormatedValue(schemaDesign).updatedTimeStr
+ }}</span>
</div>
+
<div class="bb-grid-cell">
<NButton
size="small"
@@ -86,12 +80,19 @@ import { NRadio } from "naive-ui";
import { computed, ref, reactive } from "vue";
import { useI18n } from "vue-i18n";
import { BBGridColumn } from "@/bbkit";
+import DatabaseInfo from "@/components/DatabaseInfo.vue";
import CreateSchemaDesignPanel from "@/components/SchemaDesigner/CreateSchemaDesignPanel.vue";
import EditSchemaDesignPanel from "@/components/SchemaDesigner/EditSchemaDesignPanel.vue";
-import { useProjectV1Store, useUserStore } from "@/store";
-import { useSchemaDesignList } from "@/store/modules/schemaDesign";
+import { useDatabaseV1Store, useProjectV1Store, useUserStore } from "@/store";
+import {
+ useSchemaDesignList,
+ useSchemaDesignStore,
+} from "@/store/modules/schemaDesign";
import { getProjectAndSchemaDesignSheetId } from "@/store/modules/v1/common";
-import { SchemaDesign } from "@/types/proto/v1/schema_design_service";
+import {
+ SchemaDesign,
+ SchemaDesign_Type,
+} from "@/types/proto/v1/schema_design_service";
import { projectV1Name } from "@/utils";
interface LocalState {
@@ -108,7 +109,10 @@ const props = defineProps<{
}>();
const { t } = useI18n();
+const userV1Store = useUserStore();
const projectV1Store = useProjectV1Store();
+const databaseV1Store = useDatabaseV1Store();
+const schemaDesignStore = useSchemaDesignStore();
const { schemaDesignList } = useSchemaDesignList();
const state = reactive<LocalState>({
showCreatePanel: false,
@@ -121,14 +125,14 @@ const selectedSchemaDesign = ref<SchemaDesign | undefined>(
const COLUMN_LIST = computed(() => {
const columns: BBGridColumn[] = [
{ title: "", width: "3rem" },
- { title: t("database.branch"), width: "1fr" },
{
title: t("common.project"),
- width: "1fr",
+ width: "minmax(auto, 8rem)",
},
- { title: t("common.creator"), width: "1fr" },
- { title: t("common.updater"), width: "1fr" },
- { title: t("common.updated-at"), width: "1fr" },
+ { title: t("database.branch"), width: "minmax(auto, 8rem)" },
+ { title: t("schema-designer.parent-branch"), width: "minmax(auto, 8rem)" },
+ { title: t("common.database"), width: "1fr" },
+ { title: "", width: "1fr" },
{ title: "", width: "5rem" },
];
@@ -138,20 +142,32 @@ const COLUMN_LIST = computed(() => {
const getFormatedValue = (schemaDesign: SchemaDesign) => {
const [projectName] = getProjectAndSchemaDesignSheetId(schemaDesign.name);
const project = projectV1Store.getProjectByName(`projects/${projectName}`);
+ let parentBranch = "";
+ if (schemaDesign.type === SchemaDesign_Type.PERSONAL_DRAFT) {
+ const parentSchemaDesign = schemaDesignStore.getSchemaDesignByName(
+ schemaDesign.baselineSheetName
+ );
+ if (parentSchemaDesign) {
+ parentBranch = parentSchemaDesign.title;
+ }
+ }
- return {
- name: schemaDesign.title,
- project: projectV1Name(project),
- engine: schemaDesign.engine,
- creator:
- useUserStore().getUserByIdentifier(schemaDesign.creator)?.title ??
- schemaDesign.creator,
- updater:
- useUserStore().getUserByIdentifier(schemaDesign.updater)?.title ??
- schemaDesign.updater,
- updated: dayjs
+ const updater = userV1Store.getUserByEmail(
+ schemaDesign.updater.split("/")[1]
+ );
+ const updatedTimeStr = t("schema-designer.message.updated-time-by-user", {
+ time: dayjs
.duration((schemaDesign.updateTime ?? new Date()).getTime() - Date.now())
.humanize(true),
+ user: updater?.title,
+ });
+
+ return {
+ name: schemaDesign.title,
+ project: project,
+ database: databaseV1Store.getDatabaseByName(schemaDesign.baselineDatabase),
+ parentBranch: parentBranch,
+ updatedTimeStr,
};
};