Skip to content

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

feat(frontend): issue activity list improvements (#5350)

Liu Jic161ecdfa9cd
diff --git a/frontend/src/components/Issue/IssueActivityPanel.vue b/frontend/src/components/Issue/IssueActivityPanel.vue
index 425045134d..52c17909eb 100644
--- a/frontend/src/components/Issue/IssueActivityPanel.vue
+++ b/frontend/src/components/Issue/IssueActivityPanel.vue
@@ -9,269 +9,84 @@
<div class="pt-6">
<!-- Activity feed-->
<ul>
- <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(item.activity) == 'system'">
- <div class="relative">
- <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"
- >
- <img
- class="mt-1"
- src="../../assets/logo-icon.svg"
- alt="Bytebase"
- />
- </div>
- </div>
- </div>
- </template>
- <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="item.activity.creator"
- :size="'SMALL'"
- />
- </div>
- </div>
- </template>
- <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"
- >
- <heroicons-solid:plus-sm class="w-5 h-5 text-control" />
- </div>
- </div>
- </template>
- <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"
- >
- <heroicons-solid:pencil class="w-4 h-4 text-control" />
- </div>
- </div>
- </template>
+ <ActivityItem
+ v-for="(item, index) in activityList"
+ :key="item.activity.id"
+ :activity-list="activityList"
+ :issue="issue"
+ :index="index"
+ :activity="item.activity"
+ :similar="item.similar"
+ >
+ <template v-if="allowEditActivity(item.activity)" #subject-suffix>
+ <div class="space-x-2 flex items-center text-control-light">
<template
- v-else-if="
- actionIcon(item.activity) == 'run' ||
- actionIcon(item.activity) == 'rollout'
+ v-if="
+ state.editCommentMode &&
+ state.activeActivity?.id === item.activity.id
"
>
- <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"
- >
- <heroicons-outline:play class="w-6 h-6 text-control" />
- </div>
- </div>
- </template>
- <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"
- >
- <heroicons-outline:thumb-up
- class="w-5 h-5 text-control"
- />
- </div>
- </div>
- </template>
- <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"
- >
- <heroicons-outline:minus class="w-5 h-5 text-control" />
- </div>
- </div>
- </template>
- <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"
- >
- <heroicons-outline:exclamation-circle
- class="w-6 h-6 text-error"
- />
- </div>
- </div>
- </template>
- <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"
- >
- <heroicons-outline:check-circle
- class="w-6 h-6 text-success"
- />
- </div>
- </div>
- </template>
- <template v-else-if="actionIcon(item.activity) == 'skip'">
- <div class="relative pl-1">
- <div
- class="w-6 h-6 bg-gray-200 rounded-full ring-4 ring-white flex items-center justify-center"
- >
- <SkipIcon class="w-5 h-5 text-gray-500" />
- </div>
- </div>
- </template>
- <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"
- >
- <heroicons-outline:code class="w-5 h-5 text-control" />
- </div>
- </div>
+ <button
+ type="button"
+ class="rounded-sm text-control hover:bg-control-bg-hover disabled:bg-control-bg disabled:opacity-50 disabled:cursor-not-allowed px-2 text-xs leading-5 font-normal focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-2"
+ @click.prevent="cancelEditComment"
+ >
+ {{ $t("common.cancel") }}
+ </button>
+ <button
+ type="button"
+ class="border border-control-border rounded-sm text-control bg-control-bg hover:bg-control-bg-hover disabled:bg-control-bg disabled:opacity-50 disabled:cursor-not-allowed px-2 text-xs leading-5 font-normal focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-2"
+ :disabled="!allowUpdateComment"
+ @click.prevent="doUpdateComment"
+ >
+ {{ $t("common.save") }}
+ </button>
</template>
- <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(item.activity) }}
- <router-link
- :to="actionSubject(item.activity).link"
- class="font-medium text-main whitespace-nowrap hover:underline"
- exact-active-class=""
- >{{ actionSubject(item.activity).name }}</router-link
- >
- <a
- :href="'#activity' + item.activity.id"
- class="ml-1 anchor-link whitespace-normal"
- >
- <ActivityActionSentence
- :issue="issue"
- :activity="item.activity"
- />
-
- <HumanizeTs
- :ts="item.activity.createdTs"
- class="ml-1"
- />
- <span
- v-if="
- item.activity.createdTs !=
- item.activity.updatedTs &&
- item.activity.type == 'bb.issue.comment.create'
- "
- >
- ({{ $t("common.edited") }}
- <HumanizeTs
- :ts="item.activity.updatedTs"
- class="ml-1"
- />)
- </span>
- </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(item.activity)"
- class="space-x-2 flex items-center text-control-light"
- >
- <template
- v-if="
- state.editCommentMode &&
- state.activeActivity?.id === item.activity.id
- "
- >
- <button
- type="button"
- class="rounded-sm text-control hover:bg-control-bg-hover disabled:bg-control-bg disabled:opacity-50 disabled:cursor-not-allowed px-2 text-xs leading-5 font-normal focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-2"
- @click.prevent="cancelEditComment"
- >
- {{ $t("common.cancel") }}
- </button>
- <button
- type="button"
- class="border border-control-border rounded-sm text-control bg-control-bg hover:bg-control-bg-hover disabled:bg-control-bg disabled:opacity-50 disabled:cursor-not-allowed px-2 text-xs leading-5 font-normal focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-2"
- :disabled="!allowUpdateComment"
- @click.prevent="doUpdateComment"
- >
- {{ $t("common.save") }}
- </button>
- </template>
- <!-- mr-2 is to vertical align with the text description edit button-->
- <div v-else class="mr-2 flex items-center space-x-2">
- <!-- Edit Comment Button-->
- <button
- class="btn-icon"
- @click.prevent="onUpdateComment(item.activity)"
- >
- <heroicons-outline:pencil class="w-4 h-4" />
- </button>
- </div>
- </div>
- </div>
- <div class="mt-2 text-sm text-control whitespace-pre-wrap">
- <template
- v-if="
- state.editCommentMode &&
- state.activeActivity?.id === item.activity.id
- "
- >
- <label for="comment" class="sr-only">
- {{ $t("issue.edit-comment") }}
- </label>
- <textarea
- ref="editCommentTextArea"
- v-model="editComment"
- rows="3"
- class="textarea block w-full resize-none"
- :placeholder="$t('issue.leave-a-comment')"
- @input="
- (e: any) => {
- sizeToFit(e.target);
- }
- "
- @focus="
- (e: any) => {
- sizeToFit(e.target);
- }
- "
- ></textarea>
- </template>
- <template v-else>
- <ActivityComment :activity="item.activity" />
- </template>
- <template
- v-if="
- item.activity.type == 'bb.pipeline.task.file.commit'
- "
- >
- <a
- :href="fileCommitActivityUrl(item.activity)"
- target="__blank"
- class="normal-link flex flex-row items-center"
- >
- {{ $t("issue.view-commit") }}
- <heroicons-outline:external-link class="w-4 h-4" />
- </a>
- </template>
- </div>
+ <!-- mr-2 is to vertical align with the text description edit button-->
+ <div v-else class="mr-2 flex items-center space-x-2">
+ <!-- Edit Comment Button-->
+ <button
+ class="btn-icon"
+ @click.prevent="onUpdateComment(item.activity)"
+ >
+ <heroicons-outline:pencil class="w-4 h-4" />
+ </button>
</div>
</div>
- </div>
- </li>
+ </template>
+
+ <template #comment>
+ <div
+ v-if="
+ state.editCommentMode &&
+ state.activeActivity?.id === item.activity.id
+ "
+ class="mt-2 text-sm text-control whitespace-pre-wrap"
+ >
+ <label for="comment" class="sr-only">
+ {{ $t("issue.edit-comment") }}
+ </label>
+ <textarea
+ ref="editCommentTextArea"
+ v-model="editComment"
+ rows="3"
+ class="textarea block w-full resize-none"
+ :placeholder="$t('issue.leave-a-comment')"
+ @input="
+ (e: any) => {
+ sizeToFit(e.target);
+ }
+ "
+ @focus="
+ (e: any) => {
+ sizeToFit(e.target);
+ }
+ "
+ />
+ </div>
+ <ActivityComment v-else :activity="item.activity" />
+ </template>
+ </ActivityItem>
</ul>
<div v-if="!state.editCommentMode">
@@ -338,24 +153,17 @@ import {
} from "vue";
import { useRoute } from "vue-router";
import PrincipalAvatar from "../PrincipalAvatar.vue";
-import HumanizeTs from "../misc/HumanizeTs.vue";
-import { SkipIcon } from "../Icon";
import type {
Issue,
Activity,
ActivityIssueFieldUpdatePayload,
- ActivityTaskStatusUpdatePayload,
- ActivityStageStatusUpdatePayload,
ActivityCreate,
IssueSubscriber,
- ActivityTaskFileCommitPayload,
Task,
ActivityIssueCommentCreatePayload,
} from "@/types";
-import { UNKNOWN_ID, EMPTY_ID, SYSTEM_BOT_ID } from "@/types";
-import { findTaskById, issueSlug, sizeToFit, taskSlug } from "@/utils";
+import { sizeToFit } from "@/utils";
import { IssueBuiltinFieldId } from "@/plugins";
-import { useI18n } from "vue-i18n";
import {
useCurrentUser,
useIssueSubscriberStore,
@@ -363,51 +171,28 @@ import {
} from "@/store";
import { useEventListener } from "@vueuse/core";
import { useExtraIssueLogic, useIssueLogic } from "./logic";
-import ActivityActionSentence from "./activity/ActionSentence.vue";
-import ActivityComment from "./activity/Comment";
-import { isSimilarActivity } from "./activity/utils";
+import {
+ ActivityItem,
+ DistinctActivity,
+ Comment as ActivityComment,
+ isSimilarActivity,
+} from "./activity";
interface LocalState {
editCommentMode: boolean;
activeActivity?: Activity;
}
-
-interface ActionSubject {
- name: string;
- link: string;
-}
-
-type ActionIconType =
- | "avatar"
- | "system"
- | "create"
- | "update"
- | "run"
- | "approve"
- | "rollout"
- | "cancel"
- | "fail"
- | "complete"
- | "skip"
- | "commit";
-
-type DistinctActivity = {
- activity: Activity;
- similar: Activity[];
-};
-
const emit = defineEmits<{
(event: "run-checks", task: Task): void;
}>();
-const { t } = useI18n();
const activityStore = useActivityStore();
const route = useRoute();
const newComment = ref("");
const newCommentTextArea = ref();
const editComment = ref("");
-const editCommentTextArea = ref();
+const editCommentTextArea = ref<HTMLTextAreaElement[]>();
const logic = useIssueLogic();
const issue = logic.issue as Ref<Issue>;
@@ -420,7 +205,7 @@ const state = reactive<LocalState>({
const keyboardHandler = (e: KeyboardEvent) => {
if (
state.editCommentMode &&
- editCommentTextArea.value === document.activeElement
+ editCommentTextArea.value?.[0] === document.activeElement
) {
if (e.code == "Escape") {
cancelEditComment();
@@ -539,7 +324,7 @@ const onUpdateComment = (activity: Activity) => {
state.activeActivity = activity;
state.editCommentMode = true;
nextTick(() => {
- editCommentTextArea.value?.focus();
+ editCommentTextArea.value?.[0]?.focus();
});
};
@@ -558,126 +343,6 @@ const allowUpdateComment = computed(() => {
return editComment.value != state.activeActivity!.comment;
});
-const actionIcon = (activity: Activity): ActionIconType => {
- if (activity.type == "bb.issue.create") {
- return "create";
- } else if (activity.type == "bb.issue.field.update") {
- return "update";
- } else if (activity.type == "bb.pipeline.task.status.update") {
- const payload = activity.payload as ActivityTaskStatusUpdatePayload;
- switch (payload.newStatus) {
- case "PENDING": {
- if (payload.oldStatus == "RUNNING") {
- return "cancel";
- } else if (payload.oldStatus == "PENDING_APPROVAL") {
- return "rollout";
- }
- break;
- }
- case "CANCELED": {
- return "cancel";
- }
- case "RUNNING": {
- return "run";
- }
- case "DONE": {
- if (payload.oldStatus === "RUNNING") {
- return "complete";
- } else {
- return "skip";
- }
- }
- case "FAILED": {
- return "fail";
- }
- case "PENDING_APPROVAL": {
- return "avatar"; // stale approval dismissed.
- }
- }
- } else if (activity.type == "bb.pipeline.stage.status.update") {
- const payload = activity.payload as ActivityStageStatusUpdatePayload;
- switch (payload.stageStatusUpdateType) {
- case "BEGIN": {
- return "run";
- }
- case "END": {
- return "complete";
- }
- }
- } else if (activity.type == "bb.pipeline.task.file.commit") {
- return "commit";
- } else if (activity.type == "bb.pipeline.task.statement.update") {
- return "update";
- } else if (
- activity.type == "bb.pipeline.task.general.earliest-allowed-time.update"
- ) {
- return "update";
- } else if (activity.type === "bb.issue.comment.create") {
- const payload = activity.payload as ActivityIssueCommentCreatePayload;
- if (payload.approvalEvent?.status === "APPROVED") {
- return "approve";
- }
- }
-
- return activity.creator.id == SYSTEM_BOT_ID ? "system" : "avatar";
-};
-
-const actionSubjectPrefix = (activity: Activity): string => {
- if (activity.creator.id == SYSTEM_BOT_ID) {
- if (activity.type == "bb.pipeline.task.status.update") {
- return `${t("activity.subject-prefix.task")} `;
- }
- if (activity.type == "bb.pipeline.stage.status.update") {
- return `${t("activity.subject-prefix.stage")}`;
- }
- }
- return "";
-};
-
-const actionSubject = (activity: Activity): ActionSubject => {
- if (activity.creator.id == SYSTEM_BOT_ID) {
- if (activity.type == "bb.pipeline.task.status.update") {
- if (issue.value.pipeline.id != EMPTY_ID) {
- const payload = activity.payload as ActivityTaskStatusUpdatePayload;
- const task = findTaskById(issue.value.pipeline, payload.taskId);
- let link = "";
- if (task.id != UNKNOWN_ID) {
- link = `/issue/${issueSlug(
- issue.value.name,
- issue.value.id
- )}?task=${taskSlug(task.name, task.id)}`;
- }
- return {
- name: `${task.name} (${task.stage.name})`,
- link,
- };
- }
- }
- if (activity.type == "bb.pipeline.stage.status.update") {
- const payload = activity.payload as ActivityStageStatusUpdatePayload;
- const link = `/issue/${issueSlug(
- issue.value.name,
- issue.value.id
- )}?stage=${payload.stageId}`;
- return {
- name: `${payload.stageName}`,
- link,
- };
- }
- }
- return {
- name: activity.creator.name,
- link: `/u/${activity.creator.id}`,
- };
-};
-
-const fileCommitActivityUrl = (activity: Activity) => {
- const payload = activity.payload as ActivityTaskFileCommitPayload;
- if (payload.vcsInstanceUrl.includes("https://github.com"))
- return `${payload.vcsInstanceUrl}/${payload.repositoryFullPath}/commit/${payload.commitId}`;
- return `${payload.vcsInstanceUrl}/${payload.repositoryFullPath}/-/commit/${payload.commitId}`;
-};
-
onMounted(() => {
watch(
() => route.hash,
diff --git a/frontend/src/components/Issue/PipelineGhostFlow.vue b/frontend/src/components/Issue/PipelineGhostFlow.vue
index 9ca82f83d8..8c61922aee 100644
--- a/frontend/src/components/Issue/PipelineGhostFlow.vue
+++ b/frontend/src/components/Issue/PipelineGhostFlow.vue
@@ -15,6 +15,7 @@
<div
class="task relative px-2 py-1 cursor-pointer border rounded lg:flex-1 flex justify-between items-center"
:class="taskClass(task)"
+ :data-task-id="create ? '' : (task as Task).id"
@click="onClickTask(task, i)"
>
<div class="flex-1 overflow-x-hidden">
diff --git a/frontend/src/components/Issue/PipelinePITRFlow.vue b/frontend/src/components/Issue/PipelinePITRFlow.vue
index be6c7aaaf5..ce6dbd4184 100644
--- a/frontend/src/components/Issue/PipelinePITRFlow.vue
+++ b/frontend/src/components/Issue/PipelinePITRFlow.vue
@@ -10,6 +10,7 @@
<div
class="task px-2 py-1 cursor-pointer border rounded lg:flex-1 flex justify-between items-center overflow-x-hidden"
:class="taskClass(task)"
+ :data-task-id="create ? '' : (task as Task).id"
@click="onClickTask(task, i)"
>
<div class="flex-1">
diff --git a/frontend/src/components/Issue/PipelineSimpleFlow.vue b/frontend/src/components/Issue/PipelineSimpleFlow.vue
index 2770a55aa1..a7427e83da 100644
--- a/frontend/src/components/Issue/PipelineSimpleFlow.vue
+++ b/frontend/src/components/Issue/PipelineSimpleFlow.vue
@@ -15,6 +15,7 @@
<div
class="task px-2 py-1 cursor-pointer border rounded lg:flex-1 justify-between items-center overflow-hidden"
:class="taskClass(task)"
+ :data-task-id="create ? '' : (task as Task).id"
@click="onClickTask(task, i)"
>
<div class="flex items-center pb-1">
diff --git a/frontend/src/components/Issue/PipelineTenantFlow.vue b/frontend/src/components/Issue/PipelineTenantFlow.vue
index 93eedcc17b..041aeebaf2 100644
--- a/frontend/src/components/Issue/PipelineTenantFlow.vue
+++ b/frontend/src/components/Issue/PipelineTenantFlow.vue
@@ -16,6 +16,7 @@
:key="j"
class="task px-2 py-1 cursor-pointer border rounded"
:class="taskClass(task)"
+ :data-task-id="create ? '' : (task as Task).id"
@click="onClickTask(task, j)"
>
<div class="flex items-center justify-between pb-1">
diff --git a/frontend/src/components/Issue/activity/ActionCreator.vue b/frontend/src/components/Issue/activity/ActionCreator.vue
new file mode 100644
index 0000000000..6780fc9502
--- /dev/null
+++ b/frontend/src/components/Issue/activity/ActionCreator.vue
@@ -0,0 +1,17 @@
+<template>
+ <router-link
+ v-if="activity.creator.id !== SYSTEM_BOT_ID"
+ :to="`/u/${activity.creator.id}`"
+ class="font-medium text-main whitespace-nowrap hover:underline"
+ exact-active-class=""
+ >{{ activity.creator.name }}</router-link
+ >
+</template>
+
+<script lang="ts" setup>
+import { Activity, SYSTEM_BOT_ID } from "@/types";
+
+defineProps<{
+ activity: Activity;
+}>();
+</script>
diff --git a/frontend/src/components/Issue/activity/ActionIcon.vue b/frontend/src/components/Issue/activity/ActionIcon.vue
new file mode 100644
index 0000000000..f3868858d5
--- /dev/null
+++ b/frontend/src/components/Issue/activity/ActionIcon.vue
@@ -0,0 +1,176 @@
+<template>
+ <div class="relative">
+ <div v-if="icon == 'system'" 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"
+ >
+ <img class="mt-1" src="../../assets/logo-icon.svg" alt="Bytebase" />
+ </div>
+ </div>
+ <div v-else-if="icon == 'avatar'" 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" :size="'SMALL'" />
+ </div>
+ </div>
+ <div v-else-if="icon == 'create'" 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"
+ >
+ <heroicons-solid:plus-sm class="w-5 h-5 text-control" />
+ </div>
+ </div>
+ <div v-else-if="icon == 'update'" 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"
+ >
+ <heroicons-solid:pencil class="w-4 h-4 text-control" />
+ </div>
+ </div>
+ <div v-else-if="icon == 'run' || icon == 'rollout'" 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"
+ >
+ <heroicons-outline:play class="w-6 h-6 text-control" />
+ </div>
+ </div>
+ <div v-else-if="icon == 'approve'" 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"
+ >
+ <heroicons-outline:thumb-up class="w-5 h-5 text-control" />
+ </div>
+ </div>
+ <div v-else-if="icon == 'cancel'" 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"
+ >
+ <heroicons-outline:minus class="w-5 h-5 text-control" />
+ </div>
+ </div>
+ <div v-else-if="icon == 'fail'" class="relative pl-0.5">
+ <div
+ class="w-7 h-7 bg-white rounded-full ring-4 ring-white flex items-center justify-center"
+ >
+ <heroicons-outline:exclamation-circle class="w-6 h-6 text-error" />
+ </div>
+ </div>
+ <div v-else-if="icon == 'complete'" class="relative pl-0.5">
+ <div
+ class="w-7 h-7 bg-white rounded-full ring-4 ring-white flex items-center justify-center"
+ >
+ <heroicons-outline:check-circle class="w-6 h-6 text-success" />
+ </div>
+ </div>
+ <div v-else-if="icon == 'skip'" class="relative pl-1">
+ <div
+ class="w-6 h-6 bg-gray-200 rounded-full ring-4 ring-white flex items-center justify-center"
+ >
+ <SkipIcon class="w-5 h-5 text-gray-500" />
+ </div>
+ </div>
+ <div v-else-if="icon == 'commit'" 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"
+ >
+ <heroicons-outline:code class="w-5 h-5 text-control" />
+ </div>
+ </div>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { computed } from "vue";
+import {
+ Activity,
+ ActivityIssueCommentCreatePayload,
+ ActivityStageStatusUpdatePayload,
+ ActivityTaskStatusUpdatePayload,
+ SYSTEM_BOT_ID,
+} from "@/types";
+import { SkipIcon } from "@/components/Icon";
+
+type ActionIconType =
+ | "avatar"
+ | "system"
+ | "create"
+ | "update"
+ | "run"
+ | "approve"
+ | "rollout"
+ | "cancel"
+ | "fail"
+ | "complete"
+ | "skip"
+ | "commit";
+
+const props = defineProps<{
+ activity: Activity;
+}>();
+
+const icon = computed((): ActionIconType => {
+ const { activity } = props;
+ if (activity.type == "bb.issue.create") {
+ return "create";
+ } else if (activity.type == "bb.issue.field.update") {
+ return "update";
+ } else if (activity.type == "bb.pipeline.task.status.update") {
+ const payload = activity.payload as ActivityTaskStatusUpdatePayload;
+ switch (payload.newStatus) {
+ case "PENDING": {
+ if (payload.oldStatus == "RUNNING") {
+ return "cancel";
+ } else if (payload.oldStatus == "PENDING_APPROVAL") {
+ return "rollout";
+ }
+ break;
+ }
+ case "CANCELED": {
+ return "cancel";
+ }
+ case "RUNNING": {
+ return "run";
+ }
+ case "DONE": {
+ if (payload.oldStatus === "RUNNING") {
+ return "complete";
+ } else {
+ return "skip";
+ }
+ }
+ case "FAILED": {
+ return "fail";
+ }
+ case "PENDING_APPROVAL": {
+ return "avatar"; // stale approval dismissed.
+ }
+ }
+ } else if (activity.type == "bb.pipeline.stage.status.update") {
+ const payload = activity.payload as ActivityStageStatusUpdatePayload;
+ switch (payload.stageStatusUpdateType) {
+ case "BEGIN": {
+ return "run";
+ }
+ case "END": {
+ return "complete";
+ }
+ }
+ } else if (activity.type == "bb.pipeline.task.file.commit") {
+ return "commit";
+ } else if (activity.type == "bb.pipeline.task.statement.update") {
+ return "update";
+ } else if (
+ activity.type == "bb.pipeline.task.general.earliest-allowed-time.update"
+ ) {
+ return "update";
+ } else if (activity.type === "bb.issue.comment.create") {
+ const payload = activity.payload as ActivityIssueCommentCreatePayload;
+ if (payload.approvalEvent?.status === "APPROVED") {
+ return "approve";
+ }
+ }
+
+ return activity.creator.id == SYSTEM_BOT_ID ? "system" : "avatar";
+});
+</script>
diff --git a/frontend/src/components/Issue/activity/ActionSentence.vue b/frontend/src/components/Issue/activity/ActionSentence.vue
index 63be93fe62..a5feb80fb5 100644
--- a/frontend/src/components/Issue/activity/ActionSentence.vue
+++ b/frontend/src/components/Issue/activity/ActionSentence.vue
@@ -4,6 +4,9 @@
<script lang="ts" setup>
import { defineComponent, h, PropType } from "vue";
+import dayjs from "dayjs";
+import { Translation, useI18n } from "vue-i18n";
+
import {
Activity,
ActivityIssueCommentCreatePayload,
@@ -15,10 +18,16 @@ import {
Issue,
SYSTEM_BOT_ID,
} from "@/types";
-import { findTaskById, issueActivityActionSentence } from "@/utils";
-import { Translation, useI18n } from "vue-i18n";
-import dayjs from "dayjs";
+import {
+ findStageById,
+ findTaskById,
+ issueActivityActionSentence,
+} from "@/utils";
+import TaskName from "./TaskName.vue";
import SQLPreviewPopover from "@/components/misc/SQLPreviewPopover.vue";
+import StageName from "./StageName.vue";
+
+type RenderedContent = string | ReturnType<typeof h>;
const props = defineProps({
activity: {
@@ -34,6 +43,10 @@ const props = defineProps({
const { t } = useI18n();
const renderActionSentence = () => {
+ const renderSpan = (content: string, props?: object) => {
+ return h("span", props, content);
+ };
+
const { activity, issue } = props;
if (activity.type.startsWith("bb.issue.")) {
if (activity.type === "bb.issue.comment.create") {
@@ -46,18 +59,21 @@ const renderActionSentence = () => {
imName = t("common.feishu");
break;
}
- return t("activity.sentence.external-approval-rejected", {
- stageName: payload.externalApprovalEvent.stageName,
- imName: imName,
- });
+ return renderSpan(
+ t("activity.sentence.external-approval-rejected", {
+ stageName: payload.externalApprovalEvent.stageName,
+ imName: imName,
+ })
+ );
}
}
if (payload.approvalEvent?.status === "APPROVED") {
- return t("custom-approval.issue-review.approved-issue");
+ return renderSpan(t("custom-approval.issue-review.approved-issue"));
}
}
+
const [tid, params] = issueActivityActionSentence(activity);
- return t(tid, params);
+ return renderSpan(t(tid, params));
}
switch (activity.type) {
case "bb.pipeline.task.status.update": {
@@ -73,56 +89,81 @@ const renderActionSentence = () => {
task: taskName,
});
}
-
- let str = t("activity.sentence.changed");
+ const params: VerbTypeTarget = {
+ activity,
+ verb: "",
+ type: t("common.task"),
+ target: "",
+ };
switch (payload.newStatus) {
case "PENDING": {
if (payload.oldStatus == "RUNNING") {
- str = t("activity.sentence.canceled");
+ params.verb = t("activity.sentence.canceled");
} else if (payload.oldStatus == "PENDING_APPROVAL") {
- str = t("activity.sentence.rolled-out");
+ params.verb = maybeAutomaticallyVerb(
+ activity,
+ t("activity.sentence.rolled-out")
+ );
}
break;
}
case "RUNNING": {
- str = t("activity.sentence.started");
+ params.verb = t("activity.sentence.started");
break;
}
case "DONE": {
if (payload.oldStatus === "RUNNING") {
- str = t("activity.sentence.completed");
+ params.verb = t("activity.sentence.completed");
} else {
- str = t("activity.sentence.skipped");
+ params.verb = t("activity.sentence.skipped");
}
break;
}
case "FAILED": {
- str = t("activity.sentence.failed");
+ params.verb = t("activity.sentence.failed");
break;
}
case "CANCELED": {
- str = t("activity.sentence.canceled");
+ params.verb = t("activity.sentence.canceled");
break;
}
+ default:
+ params.verb = t("activity.sentence.changed");
}
- if (activity.creator.id != SYSTEM_BOT_ID) {
- // If creator is not the robot (which means we do NOT use task name in the subject),
- // then we append the task name here.
- const task = findTaskById(issue.pipeline, payload.taskId);
- str += t("activity.sentence.task-name", { name: task.name });
+ const task = findTaskById(issue.pipeline, payload.taskId);
+ if (task) {
+ params.target = h(TaskName, { issue, task });
}
- return str;
+ return renderVerbTypeTarget(params, {
+ tag: "span",
+ });
}
case "bb.pipeline.stage.status.update": {
const payload = activity.payload as ActivityStageStatusUpdatePayload;
+ const stage = findStageById(issue.pipeline, payload.stageId);
+ const params: VerbTypeTarget = {
+ activity,
+ verb: "",
+ type: t("common.stage"),
+ target: h(StageName, { stage, issue }),
+ };
switch (payload.stageStatusUpdateType) {
case "BEGIN":
- return t("activity.sentence.started");
+ params.verb = maybeAutomaticallyVerb(
+ activity,
+ t("activity.sentence.started")
+ );
+ break;
case "END":
- return t("activity.sentence.completed");
+ params.verb = t("activity.sentence.completed");
+ break;
default:
- return t("activity.sentence.changed");
+ params.verb = t("activity.sentence.changed");
+ break;
}
+ return renderVerbTypeTarget(params, {
+ tag: "span",
+ });
}
case "bb.pipeline.task.file.commit": {
const payload = activity.payload as ActivityTaskFileCommitPayload;
@@ -137,15 +178,19 @@ const renderActionSentence = () => {
const payload = activity.payload as ActivityTaskStatementUpdatePayload;
return h(
- Translation,
- {
- keypath: "activity.sentence.changed-from-to",
- },
- {
- name: () => "SQL",
- oldValue: () => renderStatement(payload.oldStatement),
- newValue: () => renderStatement(payload.newStatement),
- }
+ "span",
+ {},
+ h(
+ Translation,
+ {
+ keypath: "activity.sentence.changed-from-to",
+ },
+ {
+ name: () => "SQL",
+ oldValue: () => renderStatement(payload.oldStatement),
+ newValue: () => renderStatement(payload.newStatement),
+ }
+ )
);
}
case "bb.pipeline.task.general.earliest-allowed-time.update": {
@@ -163,7 +208,42 @@ const renderActionSentence = () => {
return "";
};
+const maybeAutomaticallyVerb = (activity: Activity, verb: string): string => {
+ if (activity.creator.id !== SYSTEM_BOT_ID) {
+ return verb;
+ }
+ return t("activity.sentence.xxx-automatically", {
+ verb,
+ });
+};
+
+type VerbTypeTarget = {
+ activity: Activity;
+ verb: RenderedContent;
+ type: RenderedContent;
+ target?: RenderedContent;
+};
+const renderVerbTypeTarget = (params: VerbTypeTarget, props: object = {}) => {
+ const keypath =
+ params.activity.creator.id === SYSTEM_BOT_ID
+ ? "activity.sentence.verb-type-target-by-system-bot"
+ : "activity.sentence.verb-type-target-by-people";
+ return h(
+ Translation,
+ {
+ ...props,
+ keypath,
+ },
+ {
+ verb: () => params.verb,
+ type: () => params.type,
+ target: () => params.target,
+ }
+ );
+};
+
const Renderer = defineComponent({
+ name: "ActionSentenceRenderer",
render: renderActionSentence,
});
diff --git a/frontend/src/components/Issue/activity/ActivityAction.vue b/frontend/src/components/Issue/activity/ActivityAction.vue
new file mode 100644
index 0000000000..d49a2dd938
--- /dev/null
+++ b/frontend/src/components/Issue/activity/ActivityAction.vue
@@ -0,0 +1,81 @@
+<template>
+ <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 space-x-1">
+ <ActionCreator
+ v-if="activity.creator.id !== SYSTEM_BOT_ID"
+ :activity="activity"
+ />
+
+ <ActionSentence :issue="issue" :activity="activity" />
+
+ <HumanizeTs :ts="activity.createdTs" class="ml-1" />
+
+ <span
+ v-if="
+ activity.createdTs != activity.updatedTs &&
+ activity.type == 'bb.issue.comment.create'
+ "
+ >
+ <span>({{ $t("common.edited") }}</span>
+ <HumanizeTs :ts="activity.updatedTs" class="ml-1" />)
+ </span>
+
+ <span
+ v-if="similar.length > 0"
+ class="text-sm font-normal text-gray-400 ml-1"
+ >
+ {{
+ $t("activity.n-similar-activities", {
+ count: similar.length + 1,
+ })
+ }}
+ </span>
+ </div>
+
+ <slot name="subject-suffix"></slot>
+ </div>
+ <div class="mt-2 text-sm text-control whitespace-pre-wrap">
+ <slot name="comment">
+ <Comment :activity="activity" />
+ </slot>
+
+ <template v-if="activity.type == 'bb.pipeline.task.file.commit'">
+ <a
+ :href="fileCommitActivityUrl(activity)"
+ target="__blank"
+ class="normal-link flex flex-row items-center"
+ >
+ {{ $t("issue.view-commit") }}
+ <heroicons-outline:external-link class="w-4 h-4" />
+ </a>
+ </template>
+ </div>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import {
+ Issue,
+ Activity,
+ ActivityTaskFileCommitPayload,
+ SYSTEM_BOT_ID,
+} from "@/types";
+import Comment from "./Comment";
+import ActionCreator from "./ActionCreator.vue";
+import ActionSentence from "./ActionSentence.vue";
+
+defineProps<{
+ issue: Issue;
+ index: number;
+ activity: Activity;
+ similar: Activity[];
+}>();
+
+const fileCommitActivityUrl = (activity: Activity) => {
+ const payload = activity.payload as ActivityTaskFileCommitPayload;
+ if (payload.vcsInstanceUrl.includes("https://github.com"))
+ return `${payload.vcsInstanceUrl}/${payload.repositoryFullPath}/commit/${payload.commitId}`;
+ return `${payload.vcsInstanceUrl}/${payload.repositoryFullPath}/-/commit/${payload.commitId}`;
+};
+</script>
diff --git a/frontend/src/components/Issue/activity/ActivityItem.vue b/frontend/src/components/Issue/activity/ActivityItem.vue
new file mode 100644
index 0000000000..1369b25ac9
--- /dev/null
+++ b/frontend/src/components/Issue/activity/ActivityItem.vue
@@ -0,0 +1,44 @@
+<template>
+ <li>
+ <div :id="`#activity${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">
+ <ActionIcon :activity="activity" />
+
+ <ActivityAction
+ :issue="issue"
+ :index="index"
+ :activity="activity"
+ :similar="similar"
+ >
+ <template #subject-suffix>
+ <slot name="subject-suffix" />
+ </template>
+
+ <template #comment>
+ <slot name="comment" />
+ </template>
+ </ActivityAction>
+ </div>
+ </div>
+ </li>
+</template>
+
+<script lang="ts" setup>
+import { Issue, Activity } from "@/types";
+import ActionIcon from "./ActionIcon.vue";
+import ActivityAction from "./ActivityAction.vue";
+import { DistinctActivity } from "./common";
+
+defineProps<{
+ issue: Issue;
+ activityList: DistinctActivity[];
+ index: number;
+ activity: Activity;
+ similar: Activity[];
+}>();
+</script>
diff --git a/frontend/src/components/Issue/activity/Comment.ts b/frontend/src/components/Issue/activity/Comment.ts
index 260e948856..1688d99964 100644
--- a/frontend/src/components/Issue/activity/Comment.ts
+++ b/frontend/src/components/Issue/activity/Comment.ts
@@ -1,6 +1,7 @@
import { h, defineComponent, PropType } from "vue";
import { Activity } from "@/types";
+// Render activity comments and render "#{issue_id}" patterns as issue links.
export default defineComponent({
name: "ActivityComment",
props: {
diff --git a/frontend/src/components/Issue/activity/StageName.vue b/frontend/src/components/Issue/activity/StageName.vue
new file mode 100644
index 0000000000..6e5fb165ab
--- /dev/null
+++ b/frontend/src/components/Issue/activity/StageName.vue
@@ -0,0 +1,14 @@
+<template>
+ <span class="font-medium text-main">
+ {{ stage.name }}
+ </span>
+</template>
+
+<script lang="ts" setup>
+import { Issue, Stage } from "@/types";
+
+defineProps<{
+ issue: Issue;
+ stage: Stage;
+}>();
+</script>
diff --git a/frontend/src/components/Issue/activity/TaskName.vue b/frontend/src/components/Issue/activity/TaskName.vue
new file mode 100644
index 0000000000..fdad70f53c
--- /dev/null
+++ b/frontend/src/components/Issue/activity/TaskName.vue
@@ -0,0 +1,64 @@
+<template>
+ <router-link
+ :to="link"
+ exact-active-class=""
+ class="font-medium text-main hover:border-b hover:border-b-main"
+ @click="toTop"
+ >
+ <span>{{ task.name }}</span>
+ <template v-if="schemaVersion">
+ <span class="ml-1 text-control-placeholder">(</span>
+ <span class="lowercase text-control-placeholder">{{
+ $t("common.schema-version")
+ }}</span>
+ <span class="ml-1 text-control-placeholder">{{ schemaVersion }}</span>
+ <span class="text-control-placeholder">)</span>
+ </template>
+ </router-link>
+</template>
+
+<script lang="ts" setup>
+import { computed } from "vue";
+import scrollIntoView from "scroll-into-view-if-needed";
+import { Issue, Task } from "@/types";
+
+const props = defineProps<{
+ issue: Issue;
+ task: Task;
+}>();
+
+const schemaVersion = computed(() => {
+ const { task } = props;
+
+ const taskPayload = task.payload as { schemaVersion?: string };
+ return taskPayload.schemaVersion ?? "";
+});
+
+const link = computed(() => {
+ const { issue, task } = props;
+ const query: Record<string, any> = {
+ task: task.id,
+ };
+
+ const stageIndex = issue.pipeline.stageList.findIndex((stage) => {
+ return stage.taskList.findIndex((t) => t.id === task.id) >= 0;
+ });
+ if (stageIndex >= 0) {
+ query.stage = stageIndex + 1;
+ }
+
+ return {
+ path: `/issue/${issue.id}`,
+ query,
+ };
+});
+
+const toTop = (e: Event) => {
+ const taskElem = document.querySelector(`[data-task-id="${props.task.id}"]`);
+ if (taskElem) {
+ scrollIntoView(taskElem, {
+ scrollMode: "if-needed",
+ });
+ }
+};
+</script>
diff --git a/frontend/src/components/Issue/activity/common.ts b/frontend/src/components/Issue/activity/common.ts
new file mode 100644
index 0000000000..cd62485b2c
--- /dev/null
+++ b/frontend/src/components/Issue/activity/common.ts
@@ -0,0 +1,47 @@
+import type {
+ Activity,
+ ActivityTaskStatementUpdatePayload,
+ ActivityTaskStatusUpdatePayload,
+} from "@/types";
+
+export type DistinctActivity = {
+ activity: Activity;
+ similar: Activity[];
+};
+
+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" &&
+ a.containerId === b.containerId
+ ) {
+ const payloadA = a.payload as ActivityTaskStatementUpdatePayload;
+ const payloadB = b.payload as ActivityTaskStatementUpdatePayload;
+ if (
+ payloadA.oldStatement === payloadB.oldStatement &&
+ payloadB.newStatement === payloadB.newStatement
+ ) {
+ return true;
+ }
+ }
+
+ if (
+ a.type === "bb.pipeline.task.status.update" &&
+ b.type === "bb.pipeline.task.status.update" &&
+ a.containerId === b.containerId &&
+ a.creator.id === b.creator.id
+ ) {
+ const payloadA = a.payload as ActivityTaskStatusUpdatePayload;
+ const payloadB = b.payload as ActivityTaskStatusUpdatePayload;
+ if (
+ payloadA.oldStatus === payloadB.oldStatus &&
+ payloadB.newStatus === payloadB.newStatus
+ ) {
+ return true;
+ }
+ }
+
+ return false;
+};
diff --git a/frontend/src/components/Issue/activity/index.ts b/frontend/src/components/Issue/activity/index.ts
new file mode 100644
index 0000000000..d57ea34140
--- /dev/null
+++ b/frontend/src/components/Issue/activity/index.ts
@@ -0,0 +1,5 @@
+import ActivityItem from "./ActivityItem.vue";
+import Comment from "./Comment";
+
+export * from "./common";
+export { ActivityItem, Comment };
diff --git a/frontend/src/components/Issue/activity/utils.ts b/frontend/src/components/Issue/activity/utils.ts
deleted file mode 100644
index 3c44beeb1a..0000000000
--- a/frontend/src/components/Issue/activity/utils.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-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 1af2e5f1f7..b75c94c1c6 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -581,7 +581,11 @@
"dismissed-stale-approval": "dismissed stale approvals of {task}",
"external-approval-rejected": "rejected external approval from {imName} of stage \"{stageName}\"",
"skipped": "skipped",
- "rolled-out": "rolled out"
+ "rolled-out": "rolled out",
+ "schema-version": "schema version {version}",
+ "xxx-automatically": "{verb} automatically",
+ "verb-type-target-by-people": "{verb} {type} {target}",
+ "verb-type-target-by-system-bot": "{type} {target} {verb}"
},
"subject-prefix": {
"task": "Task",
@@ -698,7 +702,8 @@
"tooltip": "The approvers will review and approve the issue in the order specified in the flow. The issue can only be applied after all steps in the flow have been approved. You can configure a custom approval flow for each risk."
},
"waiting-to-roll-out": "Waiting to roll out",
- "waiting-for-review": "Waiting for review"
+ "waiting-for-review": "Waiting for review",
+ "issue-name": "Issue name"
},
"alter-schema": {
"vcs-enabled": "This project has enabled VCS based version control and selecting database below will navigate you to the corresponding Git repository to initiate the change process.",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index ec78261f4d..9b0b427ee4 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -579,7 +579,11 @@
"dismissed-stale-approval": "更新了{task},此前的批准已被撤销",
"external-approval-rejected": "拒绝阶段 \"{stageName}\" 的{imName}外部审批",
"skipped": "跳过",
- "rolled-out": "发布"
+ "rolled-out": "发布",
+ "schema-version": "schema 版本 {version}",
+ "xxx-automatically": "自动{verb}",
+ "verb-type-target-by-people": "{verb}{type} {target}",
+ "verb-type-target-by-system-bot": "{type} {target} {verb}"
},
"subject-prefix": {
"task": "任务",
@@ -696,7 +700,8 @@
"tooltip": "审批人需要按审批流指定的顺序审核和审批工单。只有审批流中所有步骤都完成审批后工单才可以执行。您可以为每个风险级别自定义审批流。"
},
"waiting-to-roll-out": "等待发布",
- "waiting-for-review": "等待审核"
+ "waiting-for-review": "等待审核",
+ "issue-name": "工单名称"
},
"alter-schema": {
"vcs-enabled": "该项目开启了基于 VCS 的版本管理,选择下面的数据库会将您导航到相应的 Git 仓库以发起变更流程。",
diff --git a/frontend/src/store/modules/activity.ts b/frontend/src/store/modules/activity.ts
index cdf722fa12..18af89943b 100644
--- a/frontend/src/store/modules/activity.ts
+++ b/frontend/src/store/modules/activity.ts
@@ -159,7 +159,7 @@ export const useActivityStore = defineStore("activity", {
return a.createdTs - b.createdTs;
}
- return a.id - b.id;
+ return +a.id - +b.id;
});
this.setActivityListForIssue({
diff --git a/frontend/src/utils/activity.ts b/frontend/src/utils/activity.ts
index ed1d0805d8..52ad419166 100644
--- a/frontend/src/utils/activity.ts
+++ b/frontend/src/utils/activity.ts
@@ -1,5 +1,6 @@
import { usePrincipalStore } from "@/store";
import { IssueBuiltinFieldId } from "../plugins";
+import { t } from "@/plugins/i18n";
import {
Activity,
ActivityIssueFieldUpdatePayload,
@@ -19,10 +20,21 @@ export function issueActivityActionSentence(
const update = activity.payload as ActivityIssueFieldUpdatePayload;
switch (update.fieldId) {
+ case IssueBuiltinFieldId.NAME: {
+ const oldName = update.oldValue ?? "";
+ const newName = update.newValue ?? "";
+ return [
+ "activity.sentence.changed-from-to",
+ {
+ name: t("issue.issue-name").toLowerCase(),
+ oldValue: oldName,
+ newValue: newName,
+ },
+ ];
+ }
case IssueBuiltinFieldId.ASSIGNEE: {
if (update.oldValue && update.newValue) {
const oldName = principalStore.principalById(+update.oldValue).name;
-
const newName = principalStore.principalById(+update.newValue).name;
return [
"activity.sentence.reassigned-issue",
@@ -57,7 +69,6 @@ export function issueActivityActionSentence(
case IssueBuiltinFieldId.DESCRIPTION:
// Description could be very long, so we don't display it.
return ["activity.sentence.changed-description", {}];
- case IssueBuiltinFieldId.NAME:
case IssueBuiltinFieldId.PROJECT:
case IssueBuiltinFieldId.SQL:
}
diff --git a/frontend/src/utils/pipeline.ts b/frontend/src/utils/pipeline.ts
index 14a305f501..98ace03964 100644
--- a/frontend/src/utils/pipeline.ts
+++ b/frontend/src/utils/pipeline.ts
@@ -7,6 +7,7 @@ import {
Pipeline,
PipelineCreate,
Stage,
+ StageId,
Task,
TaskId,
TaskStatus,
@@ -71,6 +72,10 @@ export function findTaskById(pipeline: Pipeline, taskId: TaskId): Task {
return unknown("TASK") as Task;
}
+export function findStageById(pipeline: Pipeline, stageId: StageId): Stage {
+ return pipeline.stageList.find((s) => s.id === stageId) ?? unknown("STAGE");
+}
+
export function activeStage(pipeline: Pipeline): Stage {
for (const stage of pipeline.stageList) {
for (const task of stage.taskList) {