Skip to content

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

chore: update change history table (#8001)

ecmadaob12ebc6de11f
diff --git a/frontend/src/components/ChangeHistory/ChangeHistoryTable.vue b/frontend/src/components/ChangeHistory/ChangeHistoryTable.vue
index 724680a555..a16d7e8916 100644
--- a/frontend/src/components/ChangeHistory/ChangeHistoryTable.vue
+++ b/frontend/src/components/ChangeHistory/ChangeHistoryTable.vue
@@ -60,7 +60,10 @@
<ChangeHistoryStatusIcon class="mx-auto" :status="history.status" />
</BBTableCell>
<BBTableCell v-if="mode === 'DATABASE'">
- {{ changeHistory_SourceToJSON(history.source) }}
+ <div class="flex items-center gap-x-1">
+ {{ getHistoryChangeType(history.type) }}
+ <GitIcon v-if="history.pushEvent" class="w-4 h-4 text-control" />
+ </div>
</BBTableCell>
<BBTableCell>
{{ history.version }}
@@ -127,7 +130,6 @@ import { ComposedDatabase } from "@/types";
import { AffectedTable } from "@/types/changeHistory";
import {
ChangeHistory,
- changeHistory_SourceToJSON,
ChangeHistory_Status,
ChangeHistory_Type,
changeHistory_TypeToJSON,
@@ -138,6 +140,7 @@ import {
extractUserResourceName,
changeHistoryLink,
getAffectedTablesOfChangeHistory,
+ getHistoryChangeType,
} from "@/utils";
import ChangeHistoryStatusIcon from "./ChangeHistoryStatusIcon.vue";
@@ -168,7 +171,7 @@ const columnList = computed(() => {
title: "",
},
{
- title: t("change-history.workflow"),
+ title: t("change-history.change-type"),
},
{
title: t("common.version"),
diff --git a/frontend/src/components/DatabaseChangeHistoryPanel.vue b/frontend/src/components/DatabaseChangeHistoryPanel.vue
index 44bd030043..7e80f6b30a 100644
--- a/frontend/src/components/DatabaseChangeHistoryPanel.vue
+++ b/frontend/src/components/DatabaseChangeHistoryPanel.vue
@@ -11,6 +11,18 @@
/>
</div>
<div class="flex flex-row justify-end items-center grow space-x-2">
+ <label
+ v-for="item in CHANGE_TYPES"
+ :key="item"
+ class="flex items-center gap-x-2 text-sm text-gray-600"
+ >
+ <NCheckbox
+ :checked="state.selectedChangeType.has(item)"
+ @update:checked="toggleChangeType(item, $event)"
+ >
+ {{ item }}
+ </NCheckbox>
+ </label>
<div class="w-44">
<BBSelect
:selected-item="state.selectedAffectedTable"
@@ -98,6 +110,7 @@ import dayjs from "dayjs";
import saveAs from "file-saver";
import JSZip from "jszip";
import { isEqual, orderBy, uniqBy } from "lodash-es";
+import { NCheckbox } from "naive-ui";
import { computed, onBeforeMount, PropType, reactive } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
@@ -117,6 +130,7 @@ import { TenantMode } from "@/types/proto/v1/project_service";
import {
getAffectedTablesOfChangeHistory,
instanceV1HasAlterSchema,
+ getHistoryChangeType,
} from "@/utils";
const EmptyAffectedTable: AffectedTable = {
@@ -131,6 +145,7 @@ interface LocalState {
selectedChangeHistoryNameList: string[];
isExporting: boolean;
selectedAffectedTable: AffectedTable;
+ selectedChangeType: Set<string>;
}
const props = defineProps({
@@ -148,6 +163,7 @@ const { t } = useI18n();
const changeHistoryStore = useChangeHistoryStore();
const router = useRouter();
+const CHANGE_TYPES = ["DDL", "DML"];
const state = reactive<LocalState>({
showBaselineModal: false,
@@ -155,6 +171,7 @@ const state = reactive<LocalState>({
selectedChangeHistoryNameList: [],
isExporting: false,
selectedAffectedTable: EmptyAffectedTable,
+ selectedChangeType: new Set(CHANGE_TYPES),
});
const prepareChangeHistoryList = async () => {
@@ -207,6 +224,10 @@ const changeHistoryList = computed(() => {
const shownChangeHistoryList = computed(() => {
return changeHistoryList.value.filter((changeHistory) => {
+ const type = getHistoryChangeType(changeHistory.type);
+ if (!state.selectedChangeType.has(type)) {
+ return false;
+ }
if (
state.selectedAffectedTable &&
!isEqual(state.selectedAffectedTable, EmptyAffectedTable)
@@ -328,4 +349,9 @@ const doCreateBaseline = () => {
},
});
};
+
+const toggleChangeType = (type: string, checked: boolean) => {
+ if (checked) state.selectedChangeType.add(type);
+ else state.selectedChangeType.delete(type);
+};
</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 643a68b16a..ffc5b5924c 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1212,6 +1212,7 @@
"self": "Change History",
"select": "Schema version is recorded each time a schema change is applied via Bytebase",
"workflow": "Workflow",
+ "change-type": "Change Type",
"commit-info": "by {author} at {time}",
"no-schema-change": "this migration has no schema change",
"schema-drift": "Schema drift",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 3423e1d68a..2e0859073d 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1211,6 +1211,7 @@
"self": "Historial de cambios",
"select": "La versión del esquema se registra cada vez que se aplica un cambio de esquema a través de Bytebase",
"workflow": "Flujo de trabajo",
+ "change-type": "Tipo de cambio",
"commit-info": "por {author} a las {time}",
"no-schema-change": "esta migración no tiene cambios de esquema",
"schema-drift": "Desviación de esquema",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index bde7e287d4..11e30e64e9 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1209,6 +1209,7 @@
"self": "变更历史",
"select": "Schema 版本是在每次通过 Bytebase 执行 Schema 变更后被记录下来的",
"workflow": "工作流",
+ "change-type": "变更类型",
"commit-info": "由 {author} 于 {time}",
"no-schema-change": "本次变更没有任何 Schema 的改动",
"schema-drift": "Schema 偏差",
diff --git a/frontend/src/utils/v1/changeHistory.ts b/frontend/src/utils/v1/changeHistory.ts
index f40e72415d..53d6a351cc 100644
--- a/frontend/src/utils/v1/changeHistory.ts
+++ b/frontend/src/utils/v1/changeHistory.ts
@@ -2,7 +2,10 @@ import { isUndefined, orderBy, uniqBy } from "lodash-es";
import slug from "slug";
import { useDBSchemaV1Store, useDatabaseV1Store } from "@/store";
import { AffectedTable } from "@/types/changeHistory";
-import { ChangeHistory } from "@/types/proto/v1/database_service";
+import {
+ ChangeHistory,
+ ChangeHistory_Type,
+} from "@/types/proto/v1/database_service";
import { extractDatabaseResourceName } from "./database";
export const extractChangeHistoryUID = (name: string) => {
@@ -67,3 +70,18 @@ export const getAffectedTablesOfChangeHistory = (
(affectedTable) => `${affectedTable.schema}.${affectedTable.table}`
);
};
+
+export const getHistoryChangeType = (type: ChangeHistory_Type) => {
+ switch (type) {
+ case ChangeHistory_Type.BASELINE:
+ case ChangeHistory_Type.MIGRATE:
+ case ChangeHistory_Type.MIGRATE_SDL:
+ case ChangeHistory_Type.BRANCH:
+ case ChangeHistory_Type.MIGRATE_GHOST:
+ return "DDL";
+ case ChangeHistory_Type.DATA:
+ return "DML";
+ default:
+ return "-";
+ }
+};