Skip to content

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

chore: remove stale activity deletion as it's not supported (#3108)

Danny Xue5bea9c4af25
diff --git a/frontend/src/components/Issue/IssueActivityPanel.vue b/frontend/src/components/Issue/IssueActivityPanel.vue
index ab89bebfc6..bda7b6735b 100644
--- a/frontend/src/components/Issue/IssueActivityPanel.vue
+++ b/frontend/src/components/Issue/IssueActivityPanel.vue
@@ -315,22 +315,6 @@
</div>
</div>
</div>
- <BBAlert
- v-if="state.showDeleteCommentModal"
- :style="'INFO'"
- :ok-text="'Delete'"
- :title="'Are you sure to delete this comment?'"
- :description="'You cannot undo this action.'"
- @ok="
- () => {
- doDeleteComment(state.activeActivity!);
- state.showDeleteCommentModal = false;
- state.activeActivity = undefined;
- }
- "
- @cancel="state.showDeleteCommentModal = false"
- >
- </BBAlert>
</template>
<script lang="ts" setup>
@@ -372,7 +356,6 @@ import ActivityActionSentence from "./activity/ActionSentence.vue";
import { isSimilarActivity } from "./activity/utils";
interface LocalState {
- showDeleteCommentModal: boolean;
editCommentMode: boolean;
activeActivity?: Activity;
}
@@ -417,7 +400,6 @@ const issue = logic.issue as Ref<Issue>;
const { addSubscriberId } = useExtraIssueLogic();
const state = reactive<LocalState>({
- showDeleteCommentModal: false,
editCommentMode: false,
});
@@ -580,10 +562,6 @@ const allowUpdateComment = computed(() => {
return editComment.value != state.activeActivity!.comment;
});
-const doDeleteComment = (activity: Activity) => {
- activityStore.deleteActivity(activity);
-};
-
const actionIcon = (activity: Activity): ActionIconType => {
if (activity.type == "bb.issue.create") {
return "create";
diff --git a/frontend/src/store/modules/activity.ts b/frontend/src/store/modules/activity.ts
index 0481d69f2c..532bbd13cf 100644
--- a/frontend/src/store/modules/activity.ts
+++ b/frontend/src/store/modules/activity.ts
@@ -265,15 +265,5 @@ export const useActivityStore = defineStore("activity", {
return updatedActivity;
},
- async deleteActivity(activity: Activity) {
- await axios.delete(`/api/activity/${activity.id}`);
-
- if (activity.type.startsWith("bb.issue.")) {
- this.fetchActivityListByIssueId(activity.containerId);
- }
- },
- async deleteActivityById(id: number) {
- await axios.delete(`/api/activity/${id}`);
- },
},
});
diff --git a/server/activity.go b/server/activity.go
index bcaa45daf1..6884e0cd91 100644
--- a/server/activity.go
+++ b/server/activity.go
@@ -20,32 +20,29 @@ func (s *Server) registerActivityRoutes(g *echo.Group) {
if err := jsonapi.UnmarshalPayload(c.Request().Body, activityCreate); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Malformed create activity request").SetInternal(err)
}
+ if activityCreate.Type != api.ActivityIssueCommentCreate {
+ return echo.NewHTTPError(http.StatusBadRequest, "Only allow to create activity for issue comment")
+ }
activityCreate.Level = api.ActivityInfo
activityCreate.CreatorID = c.Get(getPrincipalIDContextKey()).(int)
- var foundIssue *api.Issue
- if activityCreate.Type == api.ActivityIssueCommentCreate {
- issue, err := s.store.GetIssueByID(ctx, activityCreate.ContainerID)
- if err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch issue ID when creating the comment: %d", activityCreate.ContainerID)).SetInternal(err)
- }
- if issue == nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to find issue ID for creating the comment: %d", activityCreate.ContainerID))
- }
-
- bytes, err := json.Marshal(api.ActivityIssueCommentCreatePayload{
- IssueName: issue.Name,
- })
- if err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to construct activity payload").SetInternal(err)
- }
- activityCreate.Payload = string(bytes)
- foundIssue = issue
+ issue, err := s.store.GetIssueByID(ctx, activityCreate.ContainerID)
+ if err != nil {
+ return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch issue ID when creating the comment: %d", activityCreate.ContainerID)).SetInternal(err)
+ }
+ if issue == nil {
+ return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to find issue ID for creating the comment: %d", activityCreate.ContainerID))
}
- activity, err := s.ActivityManager.CreateActivity(ctx, activityCreate, &ActivityMeta{
- issue: foundIssue,
+ bytes, err := json.Marshal(api.ActivityIssueCommentCreatePayload{
+ IssueName: issue.Name,
})
+ if err != nil {
+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to construct activity payload").SetInternal(err)
+ }
+ activityCreate.Payload = string(bytes)
+
+ activity, err := s.ActivityManager.CreateActivity(ctx, activityCreate, &ActivityMeta{issue: issue})
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create activity").SetInternal(err)
}
@@ -121,7 +118,7 @@ func (s *Server) registerActivityRoutes(g *echo.Group) {
if err := jsonapi.UnmarshalPayload(c.Request().Body, activityPatch); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Malformed patch activity request").SetInternal(err)
}
-
+ // We only allow to update comment from frontend.
activity, err := s.store.PatchActivity(ctx, activityPatch)
if err != nil {
if common.ErrorCode(err) == common.NotFound {