Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Extract issue part of actionSentence into issueActivityActionSentence so that it can be reused by Inbox later
天舟7b2b96f27b0e
diff --git a/frontend/src/components/IssueActivityPanel.vue b/frontend/src/components/IssueActivityPanel.vueindex ee19fe69ee..e5c51e55bb 100644--- a/frontend/src/components/IssueActivityPanel.vue+++ b/frontend/src/components/IssueActivityPanel.vue@@ -555,16 +555,14 @@ import {Issue,Activity,ActionFieldUpdatePayload,- Principal,ActionTaskStatusUpdatePayload,UNKNOWN_ID,EMPTY_ID,SYSTEM_BOT_ID,- ActionIssueStatusUpdatePayload,ActivityCreate,IssueSubscriber,} from "../types";-import { findTaskById, issueSlug, sizeToFit, stageSlug } from "../utils";+import { findTaskById, issueActivityActionSentence, issueSlug, sizeToFit, stageSlug } from "../utils";import { IssueTemplate, IssueBuiltinFieldId } from "../plugins";interface LocalState {@@ -820,91 +818,10 @@ export default {};const actionSentence = (activity: Activity): string => {+ if (activity.actionType.startsWith("bb.issue")) {+ return issueActivityActionSentence(activity)+ }switch (activity.actionType) {- case "bb.issue.create":- return "created issue";- case "bb.issue.comment.create":- return "commented";- case "bb.issue.field.update": {- const update = activity.payload as ActionFieldUpdatePayload;-- let name = "Unknown Field";- let oldValue = undefined;- let newValue = undefined;-- switch (update.fieldId) {- case IssueBuiltinFieldId.ASSIGNEE: {- if (update.oldValue && update.newValue) {- const oldName = store.getters["principal/principalById"](- update.oldValue- ).name;-- const newName = store.getters["principal/principalById"](- update.newValue- ).name;-- return `reassigned issue from ${oldName} to ${newName}`;- } else if (!update.oldValue && update.newValue) {- const newName = store.getters["principal/principalById"](- update.newValue- ).name;-- return `assigned issue to ${newName}`;- } else if (update.oldValue && !update.newValue) {- const oldName = store.getters["principal/principalById"](- update.oldValue- ).name;-- return `unassigned issue from ${oldName}`;- } else {- return `invalid assignee update`;- }- }- // We don't display subscriber change for now- case IssueBuiltinFieldId.SUBSCRIBER_LIST:- break;- case IssueBuiltinFieldId.DESCRIPTION:- // Description could be very long, so we don't display it.- return "changed description";- case IssueBuiltinFieldId.NAME:- case IssueBuiltinFieldId.PROJECT:- case IssueBuiltinFieldId.SQL:- case IssueBuiltinFieldId.ROLLBACK_SQL: {- if (update.fieldId == IssueBuiltinFieldId.NAME) {- name = "name";- } else if (update.fieldId == IssueBuiltinFieldId.SQL) {- name = "SQL";- } else if (update.fieldId == IssueBuiltinFieldId.ROLLBACK_SQL) {- name = "Rollback SQL";- }-- oldValue = update.oldValue;- newValue = update.newValue;- if (oldValue && newValue) {- return `changed ${name} from "${oldValue}" to "${newValue}"`;- } else if (oldValue) {- return `unset "${name} from "${oldValue}"`;- } else if (newValue) {- return `set ${name} to "${newValue}"`;- } else {- return `changed ${name} update`;- }- }- }-- return "updated";- }- case "bb.issue.status.update": {- const update = activity.payload as ActionIssueStatusUpdatePayload;- switch (update.newStatus) {- case "OPEN":- return "reopened issue";- case "DONE":- return "resolved issue";- case "CANCELED":- return "canceled issue";- }- }case "bb.pipeline.task.status.update": {const payload = activity.payload as ActionTaskStatusUpdatePayload;var str = `changed`;diff --git a/frontend/src/utils/activity.ts b/frontend/src/utils/activity.tsnew file mode 100644index 0000000000..64e882de76--- /dev/null+++ b/frontend/src/utils/activity.ts@@ -0,0 +1,102 @@+import { Store } from "vuex";+import { IssueBuiltinFieldId } from "../plugins";+import {+ ActionFieldUpdatePayload,+ ActionIssueStatusUpdatePayload,+ Activity,+} from "../types";++let store: Store<any>;++export function registerStoreWithActivityUtil(theStore: Store<any>) {+ store = theStore;+}++export function issueActivityActionSentence(activity: Activity): string {+ switch (activity.actionType) {+ case "bb.issue.create":+ return "created issue";+ case "bb.issue.comment.create":+ return "commented";+ case "bb.issue.field.update": {+ const update = activity.payload as ActionFieldUpdatePayload;++ let name = "Unknown Field";+ let oldValue = undefined;+ let newValue = undefined;++ switch (update.fieldId) {+ case IssueBuiltinFieldId.ASSIGNEE: {+ if (update.oldValue && update.newValue) {+ const oldName = store.getters["principal/principalById"](+ update.oldValue+ ).name;++ const newName = store.getters["principal/principalById"](+ update.newValue+ ).name;++ return `reassigned issue from ${oldName} to ${newName}`;+ } else if (!update.oldValue && update.newValue) {+ const newName = store.getters["principal/principalById"](+ update.newValue+ ).name;++ return `assigned issue to ${newName}`;+ } else if (update.oldValue && !update.newValue) {+ const oldName = store.getters["principal/principalById"](+ update.oldValue+ ).name;++ return `unassigned issue from ${oldName}`;+ } else {+ return `invalid assignee update`;+ }+ }+ // We don't display subscriber change for now+ case IssueBuiltinFieldId.SUBSCRIBER_LIST:+ break;+ case IssueBuiltinFieldId.DESCRIPTION:+ // Description could be very long, so we don't display it.+ return "changed description";+ case IssueBuiltinFieldId.NAME:+ case IssueBuiltinFieldId.PROJECT:+ case IssueBuiltinFieldId.SQL:+ case IssueBuiltinFieldId.ROLLBACK_SQL: {+ if (update.fieldId == IssueBuiltinFieldId.NAME) {+ name = "name";+ } else if (update.fieldId == IssueBuiltinFieldId.SQL) {+ name = "SQL";+ } else if (update.fieldId == IssueBuiltinFieldId.ROLLBACK_SQL) {+ name = "Rollback SQL";+ }++ oldValue = update.oldValue;+ newValue = update.newValue;+ if (oldValue && newValue) {+ return `changed ${name} from "${oldValue}" to "${newValue}"`;+ } else if (oldValue) {+ return `unset "${name} from "${oldValue}"`;+ } else if (newValue) {+ return `set ${name} to "${newValue}"`;+ } else {+ return `changed ${name} update`;+ }+ }+ }++ return "updated";+ }+ case "bb.issue.status.update": {+ const update = activity.payload as ActionIssueStatusUpdatePayload;+ switch (update.newStatus) {+ case "OPEN":+ return "reopened issue";+ case "DONE":+ return "resolved issue";+ case "CANCELED":+ return "canceled issue";+ }+ }+ }+}diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.tsindex 672c337119..2dd1fe165d 100644--- a/frontend/src/utils/index.ts+++ b/frontend/src/utils/index.ts@@ -1,10 +1,11 @@+export * from "./activity";+export * from "./database";export * from "./environment";-export * from "./project";export * from "./instance";-export * from "./database";+export * from "./issue";export * from "./link";+export * from "./pipeline";+export * from "./project";export * from "./role";export * from "./slug";-export * from "./issue";-export * from "./pipeline";export * from "./util";