Skip to content

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

chore: use data table for deployment config (#13551)

boojack6c781aaa5fea
diff --git a/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue b/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue
index 46ec059dc5..570410eb30 100644
--- a/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue
+++ b/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue
@@ -34,7 +34,7 @@
</NInputGroup>
</div>
<div class="w-full overflow-x-auto">
- <DeployDatabaseTable
+ <DeploymentMatrixDataTable
:database-list="filteredDatabaseList"
:label="state.label"
:environment-list="environmentList"
@@ -52,7 +52,10 @@ import type { ComposedDatabase } from "@/types";
import type { Environment } from "@/types/proto/v1/environment_service";
import type { DeploymentConfig } from "@/types/proto/v1/project_service";
import { filterDatabaseV1ByKeyword } from "@/utils";
-import { DeployDatabaseTable, YAxisRadioGroup } from "../TenantDatabaseTable";
+import {
+ YAxisRadioGroup,
+ DeploymentMatrixDataTable,
+} from "../TenantDatabaseTable";
import { SearchBox } from "../v2";
const props = withDefaults(
diff --git a/frontend/src/components/TenantDatabaseTable/DatabaseMatrixGroup.vue b/frontend/src/components/TenantDatabaseTable/DatabaseMatrixGroup.vue
new file mode 100644
index 0000000000..4d10429aa6
--- /dev/null
+++ b/frontend/src/components/TenantDatabaseTable/DatabaseMatrixGroup.vue
@@ -0,0 +1,63 @@
+<template>
+ <div class="flex flex-col items-start w-max space-y-2">
+ <div>
+ <DatabaseMatrixItem
+ v-for="item in shownDatabases"
+ :key="item.name"
+ :database="item"
+ />
+ </div>
+ <p v-if="databases.length > 1" class="textinfolabel space-x-1">
+ <span>{{
+ $t("deployment-config.matched-databases.n", { n: databases.length })
+ }}</span>
+ <NButton
+ v-if="showDisplayMore"
+ size="tiny"
+ @click="() => (state.showAll = true)"
+ >{{ $t("deployment-config.matched-databases.show-more") }}</NButton
+ >
+ </p>
+ </div>
+
+ <DatabaseMatrixGroupDrawer
+ v-if="state.showAll"
+ :databases="databases"
+ @dismiss="() => (state.showAll = false)"
+ />
+</template>
+
+<script lang="ts" setup>
+import { NButton } from "naive-ui";
+import type { PropType } from "vue";
+import { computed, reactive } from "vue";
+import type { ComposedDatabase } from "@/types";
+import DatabaseMatrixGroupDrawer from "./DatabaseMatrixGroupDrawer.vue";
+import DatabaseMatrixItem from "./DatabaseMatrixItem.vue";
+
+interface LocalState {
+ showAll: boolean;
+}
+
+// Show databases with limit.
+const MAX_DISPLAY_DATABASES = 10;
+
+const props = defineProps({
+ databases: {
+ type: Object as PropType<ComposedDatabase[]>,
+ required: true,
+ },
+});
+
+const state = reactive<LocalState>({
+ showAll: false,
+});
+
+const shownDatabases = computed(() => {
+ return props.databases.slice(0, MAX_DISPLAY_DATABASES);
+});
+
+const showDisplayMore = computed(() => {
+ return props.databases.length > MAX_DISPLAY_DATABASES;
+});
+</script>
diff --git a/frontend/src/components/TenantDatabaseTable/DatabaseMatrixGroupDrawer.vue b/frontend/src/components/TenantDatabaseTable/DatabaseMatrixGroupDrawer.vue
new file mode 100644
index 0000000000..d845c70d27
--- /dev/null
+++ b/frontend/src/components/TenantDatabaseTable/DatabaseMatrixGroupDrawer.vue
@@ -0,0 +1,36 @@
+<template>
+ <Drawer @close="$emit('dismiss')">
+ <DrawerContent
+ :title="$t('deployment-config.matched-databases.all')"
+ :content-props="{
+ bodyContentClass: 'relative',
+ }"
+ >
+ <div class="focus:outline-none w-auto" tabindex="0">
+ <div class="grid grid-cols-3 gap-3 border rounded-lg p-4">
+ <DatabaseMatrixItem
+ v-for="item in databases"
+ :key="item.name"
+ :database="item"
+ />
+ </div>
+ </div>
+ </DrawerContent>
+ </Drawer>
+</template>
+
+<script lang="ts" setup>
+import type { PropType } from "vue";
+import { Drawer, DrawerContent } from "@/components/v2";
+import type { ComposedDatabase } from "@/types";
+import DatabaseMatrixItem from "./DatabaseMatrixItem.vue";
+
+defineProps({
+ databases: {
+ type: Object as PropType<ComposedDatabase[]>,
+ required: true,
+ },
+});
+
+defineEmits(["dismiss"]);
+</script>
diff --git a/frontend/src/components/TenantDatabaseTable/DatabaseMatrixItem.vue b/frontend/src/components/TenantDatabaseTable/DatabaseMatrixItem.vue
index 6eae52184b..a7debc58c1 100644
--- a/frontend/src/components/TenantDatabaseTable/DatabaseMatrixItem.vue
+++ b/frontend/src/components/TenantDatabaseTable/DatabaseMatrixItem.vue
@@ -12,12 +12,9 @@
<div class="sync-status">
<heroicons-solid:check-circle
v-if="database.syncState === State.ACTIVE"
- class="p-1 w-8 h-8 text-success"
- />
- <heroicons-solid:exclamation
- v-else
- class="p-1 w-8 h-8 text-warning"
+ class="w-6 h-6 text-success"
/>
+ <heroicons-solid:exclamation v-else class="w-6 h-6 text-warning" />
</div>
<div class="flex flex-col items-start">
<router-link
diff --git a/frontend/src/components/TenantDatabaseTable/DeployDatabaseTable.vue b/frontend/src/components/TenantDatabaseTable/DeployDatabaseTable.vue
deleted file mode 100644
index 6f2ccd7429..0000000000
--- a/frontend/src/components/TenantDatabaseTable/DeployDatabaseTable.vue
+++ /dev/null
@@ -1,208 +0,0 @@
-<template>
- <div>
- <BBTable
- :data-source="groupedStageList"
- :show-header="true"
- :custom-header="true"
- :row-clickable="false"
- >
- <template #header>
- <tr>
- <BBTableHeaderCell compact class="w-1/12 pl-3 pr-2 whitespace-nowrap">
- {{ displayDeploymentMatchSelectorKey(label) }}
- </BBTableHeaderCell>
-
- <BBTableHeaderCell
- v-for="(xValue, i) in xAxisValueList"
- :key="xValue"
- :style="{ width: headerColumnWidth }"
- compact
- class="text-center py-2"
- >
- <NPopover placement="top" trigger="hover">
- <template #trigger>
- <span
- class="px-1.5 py-1 relative rounded inline-flex items-center hover:bg-control-bg-hover cursor-pointer select-none"
- >
- {{ xValue }}
- </span>
- </template>
- <div class="space-y-1">
- <div class="textlabel">
- {{ $t("deployment-config.selectors") }}
- </div>
- <DeploymentStage
- v-if="deployment.schedule"
- :allow-edit="false"
- :show-header="false"
- :deployment="deployment.schedule.deployments[i]"
- layout="compact"
- />
- </div>
- </NPopover>
- </BBTableHeaderCell>
-
- <BBTableHeaderCell v-if="hasRest" compact class="text-center py-2">
- <NPopover placement="top" trigger="hover">
- <template #trigger>
- <span
- class="px-1.5 py-1 relative rounded inline-flex items-center hover:bg-control-bg-hover cursor-pointer select-none"
- >
- {{ $t("deployment-config.wont-be-deployed") }}
- </span>
- </template>
- <div class="flex items-center text-sm max-w-[16rem]">
- {{ $t("deployment-config.wont-be-deployed-explanation") }}
- </div>
- </NPopover>
- </BBTableHeaderCell>
- </tr>
- </template>
-
- <template #body="{ rowData: matrix }">
- <BBTableCell
- :left-padding="4"
- class="pr-2 whitespace-nowrap"
- :class="{
- 'text-control-placeholder': !matrix.labelValue,
- }"
- >
- <template v-if="matrix.labelValue">{{ matrix.labelValue }}</template>
- <template v-else>{{ $t("label.empty-label-value") }}</template>
- </BBTableCell>
- <BBTableCell v-for="(dbList, i) in matrix.stages" :key="i">
- <div
- v-if="dbList.length > 0"
- class="flex flex-col items-start w-max mx-auto space-y-1"
- >
- <p v-if="dbList.length > 1" class="textinfolabel">
- {{ $t("deployment-config.n-databases", { n: dbList.length }) }}
- </p>
- <NVirtualList
- :items="dbList"
- :item-size="32"
- style="max-height: 240px"
- >
- <template #default="{ item }">
- <DatabaseMatrixItem :key="item.id" :database="item" />
- </template>
- </NVirtualList>
- </div>
- <div v-if="dbList.length === 0" class="text-center">-</div>
- </BBTableCell>
-
- <BBTableCell v-if="hasRest">
- <div
- v-if="databaseList.length > 0"
- class="flex flex-col items-start w-max mx-auto space-y-1"
- >
- <DatabaseMatrixItem
- v-for="db in matrix.rest"
- :key="db.id"
- :database="db"
- />
- </div>
- <div v-if="matrix.rest.length === 0" class="text-center">-</div>
- </BBTableCell>
- </template>
- </BBTable>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { groupBy } from "lodash-es";
-import { NPopover, NVirtualList } from "naive-ui";
-import { computed } from "vue";
-import { BBTable, BBTableCell, BBTableHeaderCell } from "@/bbkit";
-import type { ComposedDatabase } from "@/types";
-import type { Environment } from "@/types/proto/v1/environment_service";
-import type { DeploymentConfig } from "@/types/proto/v1/project_service";
-import {
- getLabelValuesFromDatabaseV1List,
- getPipelineFromDeploymentScheduleV1,
- displayDeploymentMatchSelectorKey,
- getSemanticLabelValue,
-} from "@/utils";
-import { DeploymentStage } from "../DeploymentConfigTool";
-import DatabaseMatrixItem from "./DatabaseMatrixItem.vue";
-
-const props = withDefaults(
- defineProps<{
- databaseList: ComposedDatabase[];
- label: string;
- environmentList: Environment[];
- deployment: DeploymentConfig;
- bordered?: boolean;
- showRest?: boolean;
- }>(),
- {
- bordered: true,
- showRest: true,
- }
-);
-
-const yAxisValueList = computed(() => {
- return getLabelValuesFromDatabaseV1List(
- props.label,
- props.databaseList,
- true /* withEmptyValue */
- );
-});
-
-const xAxisValueList = computed(() => {
- // x-axis is generated by deployment stages
- const deployments = props.deployment.schedule?.deployments ?? [];
- return deployments.map((dep) => dep.title);
-});
-
-const databaseGroupList = computed(() => {
- const key = props.label;
- const dict = groupBy(props.databaseList, (db) =>
- getSemanticLabelValue(db, key)
- );
- const rows = yAxisValueList.value.map((labelValue) => {
- const databaseList = dict[labelValue] || [];
- return {
- labelValue,
- databaseList,
- };
- });
-
- if (rows.length > 0 && rows[rows.length - 1].databaseList.length === 0) {
- // ignore "<empty value>" row if no databases
- rows.pop();
- }
-
- return rows;
-});
-
-const groupedStageList = computed(() => {
- return databaseGroupList.value.map(({ labelValue, databaseList }) => {
- const stages = getPipelineFromDeploymentScheduleV1(
- databaseList,
- props.deployment.schedule
- );
- const affectedNames = stages.flatMap((dbs) => dbs.map((db) => db.name));
- const dict = new Set(affectedNames);
- const rest = props.showRest
- ? databaseList.filter((db) => !dict.has(db.name))
- : [];
-
- return {
- labelValue,
- stages,
- rest,
- };
- });
-});
-
-const hasRest = computed(() => {
- return groupedStageList.value.some((group) => group.rest.length > 0);
-});
-
-const headerColumnWidth = computed(() => {
- let base = xAxisValueList.value.length;
- if (hasRest.value) base += 1;
- return `${(100 - 1 / 12) / base - 1}%`;
-});
-</script>
diff --git a/frontend/src/components/TenantDatabaseTable/DeploymentMatrixDataTable.vue b/frontend/src/components/TenantDatabaseTable/DeploymentMatrixDataTable.vue
new file mode 100644
index 0000000000..cbda7b49de
--- /dev/null
+++ b/frontend/src/components/TenantDatabaseTable/DeploymentMatrixDataTable.vue
@@ -0,0 +1,160 @@
+<template>
+ <NDataTable
+ key="database-table"
+ size="small"
+ :columns="columnList"
+ :data="groupedStageList"
+ :bordered="bordered"
+ :row-key="(data: DeploymentMatrixRowData) => data.labelValue"
+ ></NDataTable>
+</template>
+
+<script lang="tsx" setup>
+import { groupBy } from "lodash-es";
+import { NDataTable, type DataTableColumn } from "naive-ui";
+import { computed } from "vue";
+import type { ComposedDatabase } from "@/types";
+import type { Environment } from "@/types/proto/v1/environment_service";
+import type { DeploymentConfig } from "@/types/proto/v1/project_service";
+import {
+ displayDeploymentMatchSelectorKey,
+ getLabelValuesFromDatabaseV1List,
+ getPipelineFromDeploymentScheduleV1,
+ getSemanticLabelValue,
+} from "@/utils";
+import DatabaseMatrixGroup from "./DatabaseMatrixGroup.vue";
+
+type DeploymentMatrixRowData = {
+ labelValue: string;
+ stages: ComposedDatabase[][];
+ unmatched: ComposedDatabase[];
+};
+
+type DeploymentMatrixDataTableColumn =
+ DataTableColumn<DeploymentMatrixRowData> & {
+ hide?: boolean;
+ };
+
+const props = withDefaults(
+ defineProps<{
+ databaseList: ComposedDatabase[];
+ label: string;
+ environmentList: Environment[];
+ deployment: DeploymentConfig;
+ bordered?: boolean;
+ showRest?: boolean;
+ }>(),
+ {
+ bordered: true,
+ showRest: true,
+ }
+);
+
+const databaseGroupList = computed(() => {
+ const key = props.label;
+ const dict = groupBy(props.databaseList, (db) =>
+ getSemanticLabelValue(db, key)
+ );
+ const rows = getLabelValuesFromDatabaseV1List(
+ props.label,
+ props.databaseList,
+ true /* withEmptyValue */
+ ).map((labelValue) => {
+ const databaseList = dict[labelValue] || [];
+ return {
+ labelValue,
+ databaseList,
+ };
+ });
+
+ if (rows.length > 0 && rows[rows.length - 1].databaseList.length === 0) {
+ // ignore "<empty value>" row if no databases
+ rows.pop();
+ }
+
+ return rows;
+});
+
+const groupedStageList = computed(() => {
+ return databaseGroupList.value.map(({ labelValue, databaseList }) => {
+ const stages = getPipelineFromDeploymentScheduleV1(
+ databaseList,
+ props.deployment.schedule
+ );
+ const affectedNames = stages.flatMap((dbs) => dbs.map((db) => db.name));
+ const dict = new Set(affectedNames);
+ const unmatched = props.showRest
+ ? databaseList.filter((db) => !dict.has(db.name))
+ : [];
+
+ return {
+ labelValue,
+ stages,
+ unmatched,
+ };
+ });
+});
+
+const hasRest = computed(() => {
+ return groupedStageList.value.some((group) => group.unmatched.length > 0);
+});
+
+const columnList = computed((): DeploymentMatrixDataTableColumn[] => {
+ const ENVIRONTMENT_ID: DeploymentMatrixDataTableColumn = {
+ key: "environment-id",
+ title: displayDeploymentMatchSelectorKey(props.label),
+ hide: !(props.label === "environment"),
+ width: 160,
+ render: (data) => {
+ return data.labelValue;
+ },
+ };
+ const DATABASE_UNIT: DeploymentMatrixDataTableColumn = {
+ key: "database-unit",
+ title: displayDeploymentMatchSelectorKey(props.label),
+ hide: props.label === "environment",
+ width: 160,
+ render: (data) => {
+ return data.labelValue;
+ },
+ };
+
+ const deployments = props.deployment.schedule?.deployments ?? [];
+ const columnCount = hasRest.value
+ ? deployments.length + 1
+ : deployments.length;
+ const STAGE_LIST: DeploymentMatrixDataTableColumn[] = (deployments ?? []).map(
+ (dep, i) => ({
+ key: `stage-${i}`,
+ title: dep.title,
+ width: `${100 / columnCount}%`,
+ minWidth: 240,
+ render: (data) => {
+ const matched = data.stages[i];
+ if (matched.length === 0) {
+ return "-";
+ }
+ return <DatabaseMatrixGroup databases={matched} />;
+ },
+ })
+ );
+ const UNMATCHED_LIST: DeploymentMatrixDataTableColumn = {
+ key: `unmatched`,
+ title: "Unmatched",
+ width: `${100 / columnCount}%`,
+ minWidth: 240,
+ hide: !hasRest.value,
+ render: (data) => {
+ const unmatched = data.unmatched;
+ if (unmatched.length === 0) {
+ return "-";
+ }
+ return <DatabaseMatrixGroup databases={unmatched} />;
+ },
+ };
+
+ return [ENVIRONTMENT_ID, DATABASE_UNIT, ...STAGE_LIST, UNMATCHED_LIST].filter(
+ (col) => !col.hide
+ );
+});
+</script>
diff --git a/frontend/src/components/TenantDatabaseTable/index.ts b/frontend/src/components/TenantDatabaseTable/index.ts
index 98ebeafac8..2692ba3eeb 100644
--- a/frontend/src/components/TenantDatabaseTable/index.ts
+++ b/frontend/src/components/TenantDatabaseTable/index.ts
@@ -1,4 +1,4 @@
-import DeployDatabaseTable from "./DeployDatabaseTable.vue";
+import DeploymentMatrixDataTable from "./DeploymentMatrixDataTable.vue";
import YAxisRadioGroup from "./YAxisRadioGroup.vue";
-export { DeployDatabaseTable, YAxisRadioGroup };
+export { DeploymentMatrixDataTable, YAxisRadioGroup };
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index e94ea2a71f..df9cfccf23 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2226,7 +2226,12 @@
"wont-be-deployed": "Won't be deployed",
"pipeline-generated-from-deployment-config": "The deployment pipeline is generated according to the project's {deployment_config}.",
"preview-deployment-pipeline": "Preview Deployment Pipeline",
- "select-database-group": "Select database group"
+ "select-database-group": "Select database group",
+ "matched-databases": {
+ "all": "All matched databases",
+ "n": "{n} matched database | {n} matched databases",
+ "show-more": "Show more"
+ }
},
"data-source": {
"role-type": "Role Type",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 5d2e606e76..963102324e 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2226,7 +2226,12 @@
"wont-be-deployed": "No se implementará",
"pipeline-generated-from-deployment-config": "El pipeline de implementación se genera de acuerdo con la {deployment_config} del proyecto.",
"preview-deployment-pipeline": "Vista previa del pipeline de implementación",
- "select-database-group": "Seleccionar grupo de bases de datos"
+ "select-database-group": "Seleccionar grupo de bases de datos",
+ "matched-databases": {
+ "all": "Todas las bases de datos coincidentes",
+ "n": "{n} base de datos coincidente | {n} bases de datos coincidentes",
+ "show-more": "Mostrar más"
+ }
},
"data-source": {
"role-type": "Tipo de rol",
@@ -3681,4 +3686,4 @@
"worksheet": {
"self": "Hoja de trabajo"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 5e3e00b221..e4de505a05 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2226,7 +2226,12 @@
"wont-be-deployed": "導入には関与しない",
"pipeline-generated-from-deployment-config": "デプロイ パイプラインはプロジェクト {deployment_config} に基づいて生成されます。",
"preview-deployment-pipeline": "導入パイプラインのプレビュー",
- "select-database-group": "データベースグループの選択"
+ "select-database-group": "データベースグループの選択",
+ "matched-databases": {
+ "all": "一致したすべてのデータベース",
+ "n": "{n} 個の一致したデータベース | {n} 個の一致したデータベース",
+ "show-more": "もっと見る"
+ }
},
"data-source": {
"role-type": "権限の種類",
@@ -3681,4 +3686,4 @@
"worksheet": {
"self": "ワークシート"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 8fcebcd0e8..cd6a86a1ae 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2226,7 +2226,12 @@
"wont-be-deployed": "不参与部署",
"pipeline-generated-from-deployment-config": "部署的流水线根据项目的{deployment_config}生成。",
"preview-deployment-pipeline": "预览部署流水线",
- "select-database-group": "选择数据库分组"
+ "select-database-group": "选择数据库分组",
+ "matched-databases": {
+ "all": "所有匹配的数据库",
+ "n": "{n} 个匹配的数据库 | {n} 个匹配的数据库",
+ "show-more": "显示更多"
+ }
},
"data-source": {
"role-type": "权限类型",
@@ -3681,4 +3686,4 @@
"worksheet": {
"self": "工作表"
}
-}
+}
\ No newline at end of file