Skip to content

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

feat(frontend): support PITR activity type (#1672)

Liu Ji481414e45c17
diff --git a/frontend/src/components/ActivityTable.vue b/frontend/src/components/ActivityTable.vue
index 212184f693..773f8a2620 100644
--- a/frontend/src/components/ActivityTable.vue
+++ b/frontend/src/components/ActivityTable.vue
@@ -8,7 +8,7 @@
:right-bordered="true"
>
<template #body="{ rowData: activity }">
- <BBTableCell :left-padding="4" class="w-8">
+ <BBTableCell :left-padding="4" class="w-[20%]">
<div class="flex flew-row space-x-1">
<span
v-if="activity.level != `INFO`"
@@ -25,16 +25,16 @@
<ActivityTypeLink :activity="activity" />
</div>
</BBTableCell>
- <BBTableCell class="w-96">
+ <BBTableCell>
<div class="flex flex-row space-x-1">
<span>{{ activity.comment }}</span>
<ActivityCommentLink :activity="activity" />
</div>
</BBTableCell>
- <BBTableCell class="w-8">
+ <BBTableCell class="w-[12%]">
{{ humanizeTs(activity.createdTs) }}
</BBTableCell>
- <BBTableCell class="w-8">
+ <BBTableCell class="w-[12%]">
<div class="flex flex-row items-center">
<BBAvatar :size="'SMALL'" :username="activity.creator.name" />
<span class="ml-2">{{ activity.creator.name }}</span>
diff --git a/frontend/src/components/ProjectActivityPanel.vue b/frontend/src/components/ProjectActivityPanel.vue
index ffa43f359d..5222e2e4e4 100644
--- a/frontend/src/components/ProjectActivityPanel.vue
+++ b/frontend/src/components/ProjectActivityPanel.vue
@@ -10,7 +10,7 @@
</template>
<script lang="ts">
-import { defineComponent, PropType, reactive, watchEffect } from "vue";
+import { defineComponent, onBeforeMount, PropType, reactive } from "vue";
import { Activity, Project } from "../types";
import ActivityTable from "../components/ActivityTable.vue";
import { useActivityStore } from "@/store";
@@ -32,18 +32,26 @@ export default defineComponent({
const state = reactive<LocalState>({
activityList: [],
});
+ const activityStore = useActivityStore();
const prepareActivityList = () => {
- useActivityStore()
- .fetchActivityListForProject({
+ const requests = [
+ activityStore.fetchActivityListForDatabaseByProjectId({
projectId: props.project.id,
- })
- .then((list) => {
- state.activityList = list;
- });
+ }),
+ activityStore.fetchActivityListForProject({
+ projectId: props.project.id,
+ }),
+ ];
+
+ Promise.all(requests).then((lists) => {
+ const flattenList = lists.flatMap((list) => list);
+ flattenList.sort((a, b) => -(a.createdTs - b.createdTs)); // by createdTs DESC
+ state.activityList = flattenList;
+ });
};
- watchEffect(prepareActivityList);
+ onBeforeMount(prepareActivityList);
return {
state,
diff --git a/frontend/src/components/ProjectOverviewPanel.vue b/frontend/src/components/ProjectOverviewPanel.vue
index ab63ae8c8e..d05a0b2d35 100644
--- a/frontend/src/components/ProjectOverviewPanel.vue
+++ b/frontend/src/components/ProjectOverviewPanel.vue
@@ -113,6 +113,7 @@ import {
PropType,
computed,
defineComponent,
+ onBeforeMount,
} from "vue";
import { NSpin } from "naive-ui";
import ActivityTable from "../components/ActivityTable.vue";
@@ -164,16 +165,25 @@ export default defineComponent({
xAxisLabel: "bb.environment",
yAxisLabel: undefined,
});
+ const activityStore = useActivityStore();
const prepareActivityList = () => {
- useActivityStore()
- .fetchActivityListForProject({
+ const requests = [
+ activityStore.fetchActivityListForDatabaseByProjectId({
projectId: props.project.id,
limit: ACTIVITY_LIMIT,
- })
- .then((list) => {
- state.activityList = list;
- });
+ }),
+ activityStore.fetchActivityListForProject({
+ projectId: props.project.id,
+ limit: ACTIVITY_LIMIT,
+ }),
+ ];
+
+ Promise.all(requests).then((lists) => {
+ const flattenList = lists.flatMap((list) => list);
+ flattenList.sort((a, b) => -(a.createdTs - b.createdTs)); // by createdTs DESC
+ state.activityList = flattenList.slice(0, ACTIVITY_LIMIT);
+ });
};
const prepareIssueList = () => {
@@ -206,7 +216,7 @@ export default defineComponent({
prepareIssueList();
};
- watchEffect(prepare);
+ onBeforeMount(prepare);
const labelList = useLabelList();
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 2ccbfdd436..cd59cf2cc7 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -389,7 +389,8 @@
"project-member-create": "add project member",
"project-member-delete": "delete project member",
"project-member-role-update": "change project member role",
- "pipeline-task-earliest-allowed-time-update": "update earliest allowed time"
+ "pipeline-task-earliest-allowed-time-update": "update earliest allowed time",
+ "database-recovery-pitr-done": "restore database to point in time"
},
"sentence": {
"created-issue": "created issue",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 08884ef4ee..c64e5bb219 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -389,7 +389,8 @@
"project-member-create": "添加项目成员",
"project-member-delete": "删除项目成员",
"project-member-role-update": "变更项目成员角色",
- "pipeline-task-earliest-allowed-time-update": "更新最早允许执行时间"
+ "pipeline-task-earliest-allowed-time-update": "更新最早允许执行时间",
+ "database-recovery-pitr-done": "将数据库恢复到指定时间点"
},
"sentence": {
"created-issue": "创建工单",
diff --git a/frontend/src/store/modules/activity.ts b/frontend/src/store/modules/activity.ts
index 202bc0f880..6b969346db 100644
--- a/frontend/src/store/modules/activity.ts
+++ b/frontend/src/store/modules/activity.ts
@@ -146,6 +146,31 @@ export const useActivityStore = defineStore("activity", {
return activityList;
},
+ async fetchActivityListForDatabaseByProjectId({
+ projectId,
+ limit,
+ }: {
+ projectId: ProjectId;
+ limit?: number;
+ }) {
+ const queryList = [
+ "typePrefix=bb.database.",
+ `container=${projectId}`,
+ `order=DESC`,
+ ];
+ if (limit) {
+ queryList.push(`limit=${limit}`);
+ }
+ const data = (await axios.get(`/api/activity?${queryList.join("&")}`))
+ .data;
+ const activityList: Activity[] = data.data.map(
+ (activity: ResourceObject) => {
+ return convert(activity, data.included);
+ }
+ );
+
+ return activityList;
+ },
async createActivity(newActivity: ActivityCreate) {
const data = (
await axios.post(`/api/activity`, {
diff --git a/frontend/src/types/activity.ts b/frontend/src/types/activity.ts
index 177058de20..1919d21807 100644
--- a/frontend/src/types/activity.ts
+++ b/frontend/src/types/activity.ts
@@ -30,10 +30,13 @@ export type ProjectActivityType =
| "bb.project.member.delete"
| "bb.project.member.role.update";
+export type DatabaseActivityType = "bb.database.recovery.pitr.done";
+
export type ActivityType =
| IssueActivityType
| MemberActivityType
- | ProjectActivityType;
+ | ProjectActivityType
+ | DatabaseActivityType;
export function activityName(type: ActivityType): string {
switch (type) {
@@ -71,6 +74,8 @@ export function activityName(type: ActivityType): string {
return t("activity.type.project-member-delete");
case "bb.project.member.role.update":
return t("activity.type.project-member-role-update");
+ case "bb.database.recovery.pitr.done":
+ return t("activity.type.database-recovery-pitr-done");
}
}