Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): generate a comment when rollbacking a task (#3524)
Liu Ji63b44030e76e
diff --git a/frontend/src/components/Issue/IssueActivityPanel.vue b/frontend/src/components/Issue/IssueActivityPanel.vueindex bda7b6735b..4736aeefd4 100644--- a/frontend/src/components/Issue/IssueActivityPanel.vue+++ b/frontend/src/components/Issue/IssueActivityPanel.vue@@ -231,7 +231,7 @@></textarea></template><template v-else>- {{ item.activity.comment }}+ <ActivityComment :activity="item.activity" /></template><templatev-if="@@ -353,6 +353,7 @@ import {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";interface LocalState {diff --git a/frontend/src/components/Issue/IssueRollbackButton.vue b/frontend/src/components/Issue/IssueRollbackButton.vueindex 27735eb944..f2cd3544bb 100644--- a/frontend/src/components/Issue/IssueRollbackButton.vue+++ b/frontend/src/components/Issue/IssueRollbackButton.vue@@ -19,6 +19,7 @@ import { useRouter } from "vue-router";import dayjs from "dayjs";import type {+ ActivityCreate,Issue,IssueCreate,RollbackContext,@@ -26,7 +27,7 @@ import type {TaskDatabaseDataUpdatePayload,} from "@/types";import { useIssueLogic } from "./logic";-import { useCurrentUser, useIssueStore } from "@/store";+import { useActivityStore, useCurrentUser, useIssueStore } from "@/store";import {absolutifyLink,buildIssueLinkWithTask,@@ -171,13 +172,37 @@ const tryRollbackTask = async () => {const createdIssue = await issueStore.createIssue(issueCreate);state.rollbackIssue = createdIssue;- await new Promise((resolve) => setTimeout(resolve, 1000));-state.buttonState = ButtonState.GENERATED;+ await createRollbackCommentActivity(task, issueEntity, createdIssue);+navigateToRollbackIssue();} catch {state.buttonState = ButtonState.DEFAULT;}};++const createRollbackCommentActivity = async (+ task: Task,+ issue: Issue,+ newIssue: Issue+) => {+ const comment = [+ "Rollback task",+ `[${task.name}]`,+ `in issue #${newIssue.id}`,+ ].join(" ");++ const createActivity: ActivityCreate = {+ type: "bb.issue.comment.create",+ containerId: issue.id,+ comment,+ };+ try {+ await useActivityStore().createActivity(createActivity);+ } catch {+ // do nothing+ // failing to comment to won't be too bad+ }+};</script>diff --git a/frontend/src/components/Issue/activity/Comment.ts b/frontend/src/components/Issue/activity/Comment.tsnew file mode 100644index 0000000000..f550748bc9--- /dev/null+++ b/frontend/src/components/Issue/activity/Comment.ts@@ -0,0 +1,41 @@+import { h, defineComponent, PropType } from "vue";+import { Activity } from "@/types";++export default defineComponent({+ name: "ActivityComment",+ props: {+ activity: {+ type: Object as PropType<Activity>,+ required: true,+ },+ },+ render() {+ const { comment } = this.$props.activity;+ if (!comment) return null;++ const pattern = /(#\d+)\b/;+ const parts = comment.split(pattern);++ return parts.map((part) => {+ if (part === "") return null;++ if (part.match(part)) {+ const id = parseInt(part.slice(1), 10);+ if (!Number.isNaN(id) && id > 0) {+ // we met a valid #{issue_id} in which issue_id is an integer and >= 0+ // render a link to the issue+ return h(+ "a",+ {+ href: `/issue/${id}`,+ class: "font-medium text-main whitespace-nowrap hover:underline",+ },+ part+ );+ }+ }++ return h("span", {}, part);+ });+ },+});