Skip to content

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

feat(frontend): fold redundant similar activities (#3051)

Liu Jie82e29735cea
diff --git a/frontend/src/components/Issue/IssueActivityPanel.vue b/frontend/src/components/Issue/IssueActivityPanel.vue
index 026a6de832..ab89bebfc6 100644
--- a/frontend/src/components/Issue/IssueActivityPanel.vue
+++ b/frontend/src/components/Issue/IssueActivityPanel.vue
@@ -9,15 +9,15 @@
<div class="pt-6">
<!-- Activity feed-->
<ul>
- <li v-for="(activity, index) in activityList" :key="activity.id">
- <div :id="`#activity${activity.id}`" class="relative pb-4">
+ <li v-for="(item, index) in activityList" :key="item.activity.id">
+ <div :id="`#activity${item.activity.id}`" class="relative pb-4">
<span
v-if="index != activityList.length - 1"
class="absolute left-4 -ml-px h-full w-0.5 bg-block-border"
aria-hidden="true"
></span>
<div class="relative flex items-start">
- <template v-if="actionIcon(activity) == 'system'">
+ <template v-if="actionIcon(item.activity) == 'system'">
<div class="relative">
<div class="relative pl-0.5">
<div
@@ -32,19 +32,19 @@
</div>
</div>
</template>
- <template v-else-if="actionIcon(activity) == 'avatar'">
+ <template v-else-if="actionIcon(item.activity) == 'avatar'">
<div class="relative pl-0.5">
<div
class="w-7 h-7 bg-white rounded-full ring-4 ring-white flex items-center justify-center"
>
<PrincipalAvatar
- :principal="activity.creator"
+ :principal="item.activity.creator"
:size="'SMALL'"
/>
</div>
</div>
</template>
- <template v-else-if="actionIcon(activity) == 'create'">
+ <template v-else-if="actionIcon(item.activity) == 'create'">
<div class="relative pl-0.5">
<div
class="w-7 h-7 bg-control-bg rounded-full ring-4 ring-white flex items-center justify-center"
@@ -53,7 +53,7 @@
</div>
</div>
</template>
- <template v-else-if="actionIcon(activity) == 'update'">
+ <template v-else-if="actionIcon(item.activity) == 'update'">
<div class="relative pl-0.5">
<div
class="w-7 h-7 bg-control-bg rounded-full ring-4 ring-white flex items-center justify-center"
@@ -62,7 +62,7 @@
</div>
</div>
</template>
- <template v-else-if="actionIcon(activity) == 'run'">
+ <template v-else-if="actionIcon(item.activity) == 'run'">
<div class="relative pl-0.5">
<div
class="w-7 h-7 bg-control-bg rounded-full ring-4 ring-white flex items-center justify-center"
@@ -71,7 +71,7 @@
</div>
</div>
</template>
- <template v-else-if="actionIcon(activity) == 'approve'">
+ <template v-else-if="actionIcon(item.activity) == 'approve'">
<div class="relative pl-0.5">
<div
class="w-7 h-7 bg-control-bg rounded-full ring-4 ring-white flex items-center justify-center"
@@ -82,7 +82,7 @@
</div>
</div>
</template>
- <template v-else-if="actionIcon(activity) == 'cancel'">
+ <template v-else-if="actionIcon(item.activity) == 'cancel'">
<div class="relative pl-0.5">
<div
class="w-7 h-7 bg-control-bg rounded-full ring-4 ring-white flex items-center justify-center"
@@ -91,7 +91,7 @@
</div>
</div>
</template>
- <template v-else-if="actionIcon(activity) == 'fail'">
+ <template v-else-if="actionIcon(item.activity) == 'fail'">
<div class="relative pl-0.5">
<div
class="w-7 h-7 bg-white rounded-full ring-4 ring-white flex items-center justify-center"
@@ -102,7 +102,7 @@
</div>
</div>
</template>
- <template v-else-if="actionIcon(activity) == 'complete'">
+ <template v-else-if="actionIcon(item.activity) == 'complete'">
<div class="relative pl-0.5">
<div
class="w-7 h-7 bg-white rounded-full ring-4 ring-white flex items-center justify-center"
@@ -113,7 +113,7 @@
</div>
</div>
</template>
- <template v-else-if="actionIcon(activity) == 'commit'">
+ <template v-else-if="actionIcon(item.activity) == 'commit'">
<div class="relative pl-0.5">
<div
class="w-7 h-7 bg-control-bg rounded-full ring-4 ring-white flex items-center justify-center"
@@ -125,42 +125,53 @@
<div class="ml-3 min-w-0 flex-1">
<div class="min-w-0 flex-1 pt-1 flex justify-between">
<div class="text-sm text-control-light">
- {{ actionSubjectPrefix(activity) }}
+ {{ actionSubjectPrefix(item.activity) }}
<router-link
- :to="actionSubject(activity).link"
+ :to="actionSubject(item.activity).link"
class="font-medium text-main whitespace-nowrap hover:underline"
exact-active-class=""
- >{{ actionSubject(activity).name }}</router-link
+ >{{ actionSubject(item.activity).name }}</router-link
>
<a
- :href="'#activity' + activity.id"
+ :href="'#activity' + item.activity.id"
class="ml-1 anchor-link whitespace-normal"
>
<ActivityActionSentence
:issue="issue"
- :activity="activity"
+ :activity="item.activity"
/>
- {{ humanizeTs(activity.createdTs) }}
+ {{ humanizeTs(item.activity.createdTs) }}
<template
v-if="
- activity.createdTs != activity.updatedTs &&
- activity.type == 'bb.issue.comment.create'
+ item.activity.createdTs !=
+ item.activity.updatedTs &&
+ item.activity.type == 'bb.issue.comment.create'
"
>
({{ $t("common.edited") }}
- {{ humanizeTs(activity.updatedTs) }})
+ {{ humanizeTs(item.activity.updatedTs) }})
</template>
</a>
+ <span
+ v-if="item.similar.length > 0"
+ class="text-sm font-normal text-gray-400 ml-1"
+ >
+ {{
+ $t("activity.n-similar-activities", {
+ count: item.similar.length + 1,
+ })
+ }}
+ </span>
</div>
<div
- v-if="allowEditActivity(activity)"
+ v-if="allowEditActivity(item.activity)"
class="space-x-2 flex items-center text-control-light"
>
<template
v-if="
state.editCommentMode &&
- state.activeActivity?.id === activity.id
+ state.activeActivity?.id === item.activity.id
"
>
<button
@@ -184,7 +195,7 @@
<!-- Edit Comment Button-->
<button
class="btn-icon"
- @click.prevent="onUpdateComment(activity)"
+ @click.prevent="onUpdateComment(item.activity)"
>
<heroicons-outline:pencil class="w-4 h-4" />
</button>
@@ -195,7 +206,7 @@
<template
v-if="
state.editCommentMode &&
- state.activeActivity?.id === activity.id
+ state.activeActivity?.id === item.activity.id
"
>
<label for="comment" class="sr-only">
@@ -220,13 +231,15 @@
></textarea>
</template>
<template v-else>
- {{ activity.comment }}
+ {{ item.activity.comment }}
</template>
<template
- v-if="activity.type == 'bb.pipeline.task.file.commit'"
+ v-if="
+ item.activity.type == 'bb.pipeline.task.file.commit'
+ "
>
<a
- :href="fileCommitActivityUrl(activity)"
+ :href="fileCommitActivityUrl(item.activity)"
target="__blank"
class="normal-link flex flex-row items-center"
>
@@ -356,6 +369,7 @@ import {
import { useEventListener } from "@vueuse/core";
import { useExtraIssueLogic, useIssueLogic } from "./logic";
import ActivityActionSentence from "./activity/ActionSentence.vue";
+import { isSimilarActivity } from "./activity/utils";
interface LocalState {
showDeleteCommentModal: boolean;
@@ -380,6 +394,11 @@ type ActionIconType =
| "complete"
| "commit";
+type DistinctActivity = {
+ activity: Activity;
+ similar: Activity[];
+};
+
const emit = defineEmits<{
(event: "run-checks", task: Task): void;
}>();
@@ -432,17 +451,36 @@ const prepareActivityList = () => {
watchEffect(prepareActivityList);
// Need to use computed to make list reactive to activity list changes.
-const activityList = computed((): Activity[] => {
- const list = activityStore.getActivityListByIssue(issue.value.id);
- return list.filter((activity: Activity) => {
- if (activity.type == "bb.issue.field.update") {
- const containUserVisibleChange =
- (activity.payload as ActivityIssueFieldUpdatePayload).fieldId !=
- IssueBuiltinFieldId.SUBSCRIBER_LIST;
- return containUserVisibleChange;
+const activityList = computed((): DistinctActivity[] => {
+ const list = activityStore
+ .getActivityListByIssue(issue.value.id)
+ .filter((activity: Activity) => {
+ if (activity.type === "bb.issue.field.update") {
+ const containUserVisibleChange =
+ (activity.payload as ActivityIssueFieldUpdatePayload).fieldId !==
+ IssueBuiltinFieldId.SUBSCRIBER_LIST;
+ return containUserVisibleChange;
+ }
+ return true;
+ });
+
+ const distinctActivityList: DistinctActivity[] = [];
+ for (let i = 0; i < list.length; i++) {
+ const activity = list[i];
+ if (distinctActivityList.length === 0) {
+ distinctActivityList.push({ activity, similar: [] });
+ continue;
}
- return true;
- });
+
+ const prev = distinctActivityList[distinctActivityList.length - 1];
+ if (isSimilarActivity(prev.activity, activity)) {
+ prev.similar.push(activity);
+ } else {
+ distinctActivityList.push({ activity, similar: [] });
+ }
+ }
+
+ return distinctActivityList;
});
const subscriberList = computed((): IssueSubscriber[] => {
diff --git a/frontend/src/components/Issue/activity/utils.ts b/frontend/src/components/Issue/activity/utils.ts
new file mode 100644
index 0000000000..3c44beeb1a
--- /dev/null
+++ b/frontend/src/components/Issue/activity/utils.ts
@@ -0,0 +1,21 @@
+import type { Activity, ActivityTaskStatementUpdatePayload } from "@/types";
+
+export const isSimilarActivity = (a: Activity, b: Activity): boolean => {
+ // Now, we recognize two "Change SQL from .... to ...." activities are similar
+ // when they have the same "from" and "to" values.
+ if (
+ a.type === "bb.pipeline.task.statement.update" &&
+ b.type === "bb.pipeline.task.statement.update"
+ ) {
+ const payloadA = a.payload as ActivityTaskStatementUpdatePayload;
+ const payloadB = b.payload as ActivityTaskStatementUpdatePayload;
+ if (
+ payloadA.oldStatement === payloadB.oldStatement &&
+ payloadB.newStatement === payloadB.newStatement
+ ) {
+ return true;
+ }
+ }
+
+ return false;
+};
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 768f325e13..982d57d30c 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -451,7 +451,8 @@
},
"subject-prefix": {
"task": "Task"
- }
+ },
+ "n-similar-activities": "({count} similar activity) | ({count} similar activities)"
},
"issue": {
"waiting-approval": "Waiting Approval",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 4636c3df9d..b1da5f1845 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -451,7 +451,8 @@
},
"subject-prefix": {
"task": "任务"
- }
+ },
+ "n-similar-activities": "({count} 个相似的活动)"
},
"issue": {
"waiting-approval": "等待批准",