feat(EE): resolve comments (#1420)

* feat: resolve comment (EE)

* Add resolve to comment mark in editor (EE)

* comment ui permissions

* sticky comment state tabs (EE)

* cleanup

* feat: add space_id to comments and allow space admins to delete any comment

- Add space_id column to comments table with data migration from pages
- Add last_edited_by_id, resolved_by_id, and updated_at columns to comments
- Update comment deletion permissions to allow space admins to delete any comment
- Backfill space_id on old comments

* fix foreign keys
This commit is contained in:
Philip Okugbe
2025-07-29 21:36:48 +01:00
committed by GitHub
parent ec12e80423
commit ca9558b246
23 changed files with 927 additions and 341 deletions

View File

@ -63,6 +63,20 @@ export type RefetchRootTreeNodeEvent = {
spaceId: string;
};
export type ResolveCommentEvent = {
operation: "resolveComment";
pageId: string;
commentId: string;
resolved: boolean;
resolvedAt?: Date;
resolvedById?: string;
resolvedBy?: {
id: string;
name: string;
avatarUrl?: string | null;
};
};
export type WebSocketEvent =
| InvalidateEvent
| InvalidateCommentsEvent
@ -71,4 +85,5 @@ export type WebSocketEvent =
| AddTreeNodeEvent
| MoveTreeNodeEvent
| DeleteTreeNodeEvent
| RefetchRootTreeNodeEvent;
| RefetchRootTreeNodeEvent
| ResolveCommentEvent;

View File

@ -13,6 +13,7 @@ import {
} from "../page/queries/page-query";
import { RQ_KEY } from "../comment/queries/comment-query";
import { queryClient } from "@/main.tsx";
import { IComment } from "@/features/comment/types/comment.types";
export const useQuerySubscription = () => {
const queryClient = useQueryClient();
@ -96,6 +97,30 @@ export const useQuerySubscription = () => {
});
break;
}
case "resolveComment": {
const currentComments = queryClient.getQueryData(
RQ_KEY(data.pageId),
) as IPagination<IComment>;
if (currentComments && currentComments.items) {
const updatedComments = currentComments.items.map((comment) =>
comment.id === data.commentId
? {
...comment,
resolvedAt: data.resolvedAt,
resolvedById: data.resolvedById,
resolvedBy: data.resolvedBy
}
: comment,
);
queryClient.setQueryData(RQ_KEY(data.pageId), {
...currentComments,
items: updatedComments,
});
}
break;
}
}
});
}, [queryClient, socket]);