Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Delete comment support
Tianzhou Chen684ea2e9e0eb
diff --git a/frontend/src/miragejs/routes/index.js b/frontend/src/miragejs/routes/index.jsindex 4b672a8267..153d68482d 100644--- a/frontend/src/miragejs/routes/index.js+++ b/frontend/src/miragejs/routes/index.js@@ -339,6 +339,10 @@ export default function routes() {return createdActivity;});+ this.delete("/activity/:activityId", function (schema, request) {+ return schema.activities.find(request.params.activityId).destroy();+ });+// Groupthis.get("/group", function (schema, request) {const {diff --git a/frontend/src/store/modules/activity.ts b/frontend/src/store/modules/activity.tsindex 9459641753..aeafeb1c55 100644--- a/frontend/src/store/modules/activity.ts+++ b/frontend/src/store/modules/activity.ts@@ -50,6 +50,14 @@ const actions = {return createdActivity;},++ async deleteActivity({ dispatch }: any, activity: Activity) {+ await axios.delete(`/api/activity/${activity.id}`);++ if (activity.attributes.actionType.startsWith("bytebase.task.")) {+ dispatch("fetchActivityListForTask", activity.attributes.containerId);+ }+ },};const mutations = {diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.tsindex f28d0cf010..ce8cf61392 100644--- a/frontend/src/types/bytebase.ts+++ b/frontend/src/types/bytebase.ts@@ -9,6 +9,8 @@ export type StageId = string;export type TaskId = string;+export type ActivityId = string;+export type GroupId = string;export type ProjectId = string;diff --git a/frontend/src/views/TaskActivityPanel.vue b/frontend/src/views/TaskActivityPanel.vueindex 75c11e9a93..356c5a75dc 100644--- a/frontend/src/views/TaskActivityPanel.vue+++ b/frontend/src/views/TaskActivityPanel.vue@@ -24,7 +24,7 @@"><div>- <div class="relative pl-0.5 pt-0.5">+ <div class="relative pl-0.5"><divclass="bg-control-bg rounded-full ring-8 ring-white flex items-center justify-center">@@ -59,7 +59,7 @@</div></template><div class="min-w-0 flex-1">- <div class="min-w-0 flex-1 py-1.5">+ <div class="min-w-0 flex-1 flex justify-between"><div class="text-sm text-control-light"><span class="font-medium text-main">{{activity.attributes.creator.name@@ -71,6 +71,36 @@>{{ humanizeTs(activity.attributes.createdTs) }}</a></div>+ <div+ v-if="currentUser.id == activity.attributes.creator.id"+ class="space-x-2 text-control-light"+ >+ <!-- Delete Comment Button-->+ <button+ class="btn-icon"+ @click.prevent="+ {+ state.activeComment = activity;+ state.showDeleteCommentModal = true;+ }+ "+ >+ <svg+ class="w-4 h-4"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"+ ></path>+ </svg>+ </button>+ </div></div><templatev-if="@@ -152,13 +182,34 @@</div></div></div>+ <BBAlert+ v-if="state.showDeleteCommentModal"+ :style="'INFO'"+ :okText="'Delete'"+ :title="'Are you sure to delete this comment?'"+ :description="'You cannot undo this action.'"+ @ok="+ () => {+ deleteComment(state.activeComment);+ state.showDeleteCommentModal = false;+ state.activeComment = null;+ }+ "+ @cancel="state.showDeleteCommentModal = false"+ >+ </BBAlert></template><script lang="ts">-import { computed, inject, ref, watchEffect, PropType } from "vue";+import { computed, inject, ref, reactive, watchEffect, PropType } from "vue";import { useStore } from "vuex";import { UserStateSymbol } from "../components/ProvideUser.vue";-import { User, Task, TaskActionType } from "../types";+import { User, Task, TaskActionType, Activity } from "../types";++interface LocalState {+ showDeleteCommentModal: boolean;+ activeComment?: Activity;+}export default {name: "TaskActivityPanel",@@ -174,6 +225,10 @@ export default {const comment = ref("");const commentButton = ref();+ const state = reactive<LocalState>({+ showDeleteCommentModal: false,+ });+const currentUser = inject<User>(UserStateSymbol);const prepareActivityList = () => {@@ -212,6 +267,12 @@ export default {});};+ const deleteComment = (activity: Activity) => {+ store.dispatch("activity/deleteActivity", activity).catch((error) => {+ console.log(error);+ });+ };+watchEffect(prepareActivityList);const actionSentence = (actionType: TaskActionType) => {@@ -226,12 +287,14 @@ export default {};return {+ state,comment,commentButton,currentUser,activityList,actionSentence,createComment,+ deleteComment,};},};