Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Move comment outside of payload and put it under activity field directly.
天舟136d32d691e9
diff --git a/frontend/src/miragejs/factories/activity.js b/frontend/src/miragejs/factories/activity.jsindex ce5553d1f6..a06f57b674 100644--- a/frontend/src/miragejs/factories/activity.js+++ b/frontend/src/miragejs/factories/activity.js@@ -17,8 +17,8 @@ export default {creatorId() {return "100";},- payload() {- return {};+ comment() {+ return "";},}),};diff --git a/frontend/src/miragejs/factories/taskPatch.js b/frontend/src/miragejs/factories/taskPatch.jsindex daa2d6fcf0..1ea223e9f4 100644--- a/frontend/src/miragejs/factories/taskPatch.js+++ b/frontend/src/miragejs/factories/taskPatch.js@@ -26,6 +26,9 @@ export default {},];},+ comment() {+ return "my update comment";+ },payload() {return {// Requested Database namediff --git a/frontend/src/miragejs/routes/index.js b/frontend/src/miragejs/routes/index.jsindex 6280e6cdec..e1cc54eb1b 100644--- a/frontend/src/miragejs/routes/index.js+++ b/frontend/src/miragejs/routes/index.js@@ -210,6 +210,7 @@ export default function routes() {actionType: "bytebase.task.create",containerId: createdTask.id,creatorId: attrs.creatorId,+ comment: "",workspaceId: WORKSPACE_ID,});@@ -290,20 +291,27 @@ export default function routes() {}}- const ts = Date.now();- const updatedTask = task.update({ ...attrs, lastUpdatedTs: ts });-- schema.activities.create({- createdTs: ts,- lastUpdatedTs: ts,- actionType: "bytebase.task.field.update",- containerId: updatedTask.id,- creatorId: attrs.updaterId,- payload: changeList.length > 0 ? { changeList } : undefined,- workspaceId: WORKSPACE_ID,- });-- return updatedTask;+ if (changeList.length) {+ const ts = Date.now();+ const updatedTask = task.update({ ...attrs, lastUpdatedTs: ts });++ const payload = {+ changeList,+ };++ schema.activities.create({+ createdTs: ts,+ lastUpdatedTs: ts,+ actionType: "bytebase.task.field.update",+ containerId: updatedTask.id,+ creatorId: attrs.updaterId,+ comment: attrs.comment,+ payload,+ workspaceId: WORKSPACE_ID,+ });+ return updatedTask;+ }+ return task;}return new Response(404,diff --git a/frontend/src/miragejs/seeds/index.ts b/frontend/src/miragejs/seeds/index.tsindex a1a0e598ec..75e3eb3f8a 100644--- a/frontend/src/miragejs/seeds/index.ts+++ b/frontend/src/miragejs/seeds/index.ts@@ -97,9 +97,7 @@ const workspacesSeeder = (server: any) => {id: user.id,name: user.name,},- payload: {- comment: faker.fake("{{lorem.paragraph}}"),- },+ comment: faker.fake("{{lorem.paragraph}}"),workspace: workspace1,});}@@ -145,9 +143,7 @@ const workspacesSeeder = (server: any) => {actionType: "bytebase.task.comment.create",containerId: task.id,creatorId: user.id,- payload: {- comment: faker.fake("{{lorem.paragraph}}"),- },+ comment: faker.fake("{{lorem.paragraph}}"),workspace: workspace1,});}@@ -179,9 +175,7 @@ const workspacesSeeder = (server: any) => {actionType: "bytebase.task.comment.create",containerId: task.id,creatorId: user.id,- payload: {- comment: faker.fake("{{lorem.paragraph}}"),- },+ comment: faker.fake("{{lorem.paragraph}}"),workspace: workspace1,});}@@ -213,9 +207,7 @@ const workspacesSeeder = (server: any) => {actionType: "bytebase.task.comment.create",containerId: task.id,creatorId: user.id,- payload: {- comment: faker.fake("{{lorem.paragraph}}"),- },+ comment: faker.fake("{{lorem.paragraph}}"),workspace: workspace1,});}@@ -244,9 +236,7 @@ const workspacesSeeder = (server: any) => {actionType: "bytebase.task.comment.create",containerId: task.id,creatorId: user.id,- payload: {- comment: faker.fake("{{lorem.paragraph}}"),- },+ comment: faker.fake("{{lorem.paragraph}}"),workspace: workspace1,});}diff --git a/frontend/src/store/modules/activity.ts b/frontend/src/store/modules/activity.tsindex e63c304943..b321bdb471 100644--- a/frontend/src/store/modules/activity.ts+++ b/frontend/src/store/modules/activity.ts@@ -94,9 +94,7 @@ const actions = {data: {type: "activitypatch",attributes: {- payload: {- comment: updatedComment,- },+ comment: updatedComment,},},})diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.tsindex 4343b316d9..f7189d1f33 100644--- a/frontend/src/types/bytebase.ts+++ b/frontend/src/types/bytebase.ts@@ -179,6 +179,7 @@ export type TaskPatch = {assigneeId?: PrincipalId;stageProgress?: StageProgressPatch;payload?: TaskPayload;+ comment?: string;};export type TaskStatusTransitionType = "RESOLVE" | "ABORT" | "REOPEN";@@ -227,10 +228,6 @@ export type TaskActionType =export type ActionType = TaskActionType;-export type ActionTaskCommentCreatePayload = {- comment: string;-};-export type ActionTaskFieldUpdatePayload = {changeList: {fieldId: TaskFieldId;@@ -239,9 +236,7 @@ export type ActionTaskFieldUpdatePayload = {}[];};-export type ActionPayloadType =- | ActionTaskCommentCreatePayload- | ActionTaskFieldUpdatePayload;+export type ActionPayloadType = ActionTaskFieldUpdatePayload;export type Activity = {id: ActivityId;@@ -252,6 +247,7 @@ export type Activity = {// e.g if actionType is "bytebase.task.xxx", then this field refers to the corresponding task's id.containerId: TaskId;creator: Principal;+ comment: string;payload?: ActionPayloadType;};export type ActivityNew = Omit<Activity, "id">;diff --git a/frontend/src/views/TaskActivityPanel.vue b/frontend/src/views/TaskActivityPanel.vueindex 69432d283d..57c62257e5 100644--- a/frontend/src/views/TaskActivityPanel.vue+++ b/frontend/src/views/TaskActivityPanel.vue@@ -93,16 +93,13 @@</a></div><div- v-if="- currentUser.id == activity.creator.id &&- activity.actionType == 'bytebase.task.comment.create'- "+ v-if="currentUser.id == activity.creator.id"class="space-x-2 flex items-center text-control-light"><templatev-if="state.editCommentMode &&- state.activeComment.id == activity.id+ state.activeActivity.id == activity.id"><button@@ -115,10 +112,7 @@<buttontype="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="- editComment.length == 0 ||- editComment == activity.payload.comment- "+ :disabled="!allowUpdateComment"@click.prevent="doUpdateComment">Save@@ -128,10 +122,14 @@<div v-else class="mr-2 flex items-center space-x-2"><!-- Delete Comment Button--><button+ v-if="+ activity.actionType ==+ 'bytebase.task.comment.create'+ "class="btn-icon"@click.prevent="{- state.activeComment = activity;+ state.activeActivity = activity;state.showDeleteCommentModal = true;}"@@ -175,42 +173,38 @@</div></div><template- v-if="activity.actionType == 'bytebase.task.comment.create'"+ v-if="+ state.editCommentMode &&+ state.activeActivity.id == activity.id+ ">- <template- v-if="- state.editCommentMode &&- state.activeComment.id == activity.id+ <label for="comment" class="sr-only">Edit Comment</label>+ <textarea+ ref="editCommentTextArea"+ class="textarea block w-full resize-none mt-1 text-sm text-control whitespace-pre-wrap"+ placeholder="Leave a comment..."+ v-model="editComment"+ @input="+ (e) => {+ sizeToFit(e.target);+ }"- >- <label for="comment" class="sr-only">Edit Comment</label>- <textarea- ref="editCommentTextArea"- class="textarea block w-full resize-none mt-1 text-sm text-control whitespace-pre-wrap"- placeholder="Leave a comment..."- v-model="editComment"- @input="- (e) => {- sizeToFit(e.target);- }- "- @focus="- (e) => {- sizeToFit(e.target);- }- "- ></textarea>- </template>- <!-- The margin value is intentionally set to avoid flickering when switching between edit mode. -->- <div- v-else- class="text-sm ml-1.5 mt-2 mb-0.5 whitespace-pre-wrap"- >- <div v-highlight>- {{ activity.payload.comment }}- </div>- </div>+ @focus="+ (e) => {+ sizeToFit(e.target);+ }+ "+ ></textarea></template>+ <!-- The margin value is intentionally set to avoid flickering when switching between edit mode. -->+ <div+ v-else-if="activity.comment"+ class="text-sm ml-1.5 mt-2 mb-0.5 whitespace-pre-wrap"+ >+ <div v-highlight>+ {{ activity.comment }}+ </div>+ </div></div></div></div>@@ -280,9 +274,9 @@:description="'You cannot undo this action.'"@ok="() => {- doDeleteComment(state.activeComment);+ doDeleteComment(state.activeActivity);state.showDeleteCommentModal = false;- state.activeComment = null;+ state.activeActivity = null;}"@cancel="state.showDeleteCommentModal = false"@@ -305,7 +299,6 @@ import { useStore } from "vuex";import {Task,Activity,- ActionTaskCommentCreatePayload,ActionTaskFieldUpdatePayload,Environment,} from "../types";@@ -315,7 +308,7 @@ import { fieldFromId, TaskTemplate, TaskBuiltinFieldId } from "../plugins";interface LocalState {showDeleteCommentModal: boolean;editCommentMode: boolean;- activeComment?: Activity;+ activeActivity?: Activity;}export default {@@ -351,7 +344,9 @@ export default {if (e.code == "Escape") {cancelEditComment();} else if (e.code == "Enter" && e.metaKey) {- doUpdateComment();+ if (allowUpdateComment.value) {+ doUpdateComment();+ }}} else if (newCommentTextArea.value === document.activeElement) {if (e.code == "Enter" && e.metaKey) {@@ -386,7 +381,7 @@ export default {const cancelEditComment = () => {editComment.value = "";- state.activeComment = undefined;+ state.activeActivity = undefined;state.editCommentMode = false;};@@ -413,8 +408,8 @@ export default {};const onUpdateComment = (activity: Activity) => {- editComment.value = (activity.payload! as ActionTaskCommentCreatePayload).comment;- state.activeComment = activity;+ editComment.value = activity.comment;+ state.activeActivity = activity;state.editCommentMode = true;nextTick(() => {editCommentTextArea.value.focus();@@ -424,7 +419,7 @@ export default {const doUpdateComment = () => {const activityPatch = store.dispatch("activity/updateComment", {- activityId: state.activeComment!.id,+ activityId: state.activeActivity!.id,updatedComment: editComment.value,}).then(() => {@@ -435,6 +430,10 @@ export default {});};+ const allowUpdateComment = computed(() => {+ return editComment.value != state.activeActivity!.comment;+ });+const doDeleteComment = (activity: Activity) => {store.dispatch("activity/deleteActivity", activity).catch((error) => {console.log(error);@@ -553,6 +552,7 @@ export default {cancelEditComment,onUpdateComment,doUpdateComment,+ allowUpdateComment,doDeleteComment,};},