diff --git a/apiserver/plane/app/serializers/issue.py b/apiserver/plane/app/serializers/issue.py index 4f1767ccb..7bea75fa0 100644 --- a/apiserver/plane/app/serializers/issue.py +++ b/apiserver/plane/app/serializers/issue.py @@ -469,19 +469,6 @@ class IssueReactionSerializer(BaseSerializer): ] -class CommentReactionLiteSerializer(BaseSerializer): - actor_detail = UserLiteSerializer(read_only=True, source="actor") - - class Meta: - model = CommentReaction - fields = [ - "id", - "reaction", - "comment", - "actor_detail", - ] - - class CommentReactionSerializer(BaseSerializer): class Meta: model = CommentReaction @@ -512,7 +499,7 @@ class IssueCommentSerializer(BaseSerializer): workspace_detail = WorkspaceLiteSerializer( read_only=True, source="workspace" ) - comment_reactions = CommentReactionLiteSerializer( + comment_reactions = CommentReactionSerializer( read_only=True, many=True ) is_member = serializers.BooleanField(read_only=True) diff --git a/apiserver/plane/app/views/issue.py b/apiserver/plane/app/views/issue.py index 0d27b806d..2a0df13e5 100644 --- a/apiserver/plane/app/views/issue.py +++ b/apiserver/plane/app/views/issue.py @@ -48,10 +48,8 @@ from plane.app.serializers import ( ProjectMemberLiteSerializer, IssueReactionSerializer, CommentReactionSerializer, - IssueVoteSerializer, IssueRelationSerializer, RelatedIssueSerializer, - IssuePublicSerializer, ) from plane.app.permissions import ( ProjectEntityPermission, @@ -493,17 +491,27 @@ class IssueActivityEndpoint(BaseAPIView): @method_decorator(gzip_page) def get(self, request, slug, project_id, issue_id): + filters = {} + if request.GET.get("created_at__gt", None) is not None: + filters = {"created_at__gt": request.GET.get("created_at__gt")} + issue_activities = ( IssueActivity.objects.filter(issue_id=issue_id) .filter( ~Q(field__in=["comment", "vote", "reaction", "draft"]), project__project_projectmember__member=self.request.user, + workspace__slug=slug, ) + .filter(**filters) .select_related("actor", "workspace", "issue", "project") ).order_by("created_at") issue_comments = ( IssueComment.objects.filter(issue_id=issue_id) - .filter(project__project_projectmember__member=self.request.user) + .filter( + project__project_projectmember__member=self.request.user, + workspace__slug=slug, + ) + .filter(**filters) .order_by("created_at") .select_related("actor", "issue", "project", "workspace") .prefetch_related( @@ -518,6 +526,12 @@ class IssueActivityEndpoint(BaseAPIView): ).data issue_comments = IssueCommentSerializer(issue_comments, many=True).data + if request.GET.get("activity_type", None) == "issue-property": + return Response(issue_activities, status=status.HTTP_200_OK) + + if request.GET.get("activity_type", None) == "issue-comment": + return Response(issue_comments, status=status.HTTP_200_OK) + result_list = sorted( chain(issue_activities, issue_comments), key=lambda instance: instance["created_at"], diff --git a/apiserver/plane/bgtasks/issue_activites_task.py b/apiserver/plane/bgtasks/issue_activites_task.py index 686f06a20..06d3295dc 100644 --- a/apiserver/plane/bgtasks/issue_activites_task.py +++ b/apiserver/plane/bgtasks/issue_activites_task.py @@ -111,15 +111,15 @@ def track_parent( issue_activities, epoch, ): - if current_instance.get("parent") != requested_data.get("parent"): + if current_instance.get("parent_id") != requested_data.get("parent_id"): old_parent = ( - Issue.objects.filter(pk=current_instance.get("parent")).first() - if current_instance.get("parent") is not None + Issue.objects.filter(pk=current_instance.get("parent_id")).first() + if current_instance.get("parent_id") is not None else None ) new_parent = ( - Issue.objects.filter(pk=requested_data.get("parent")).first() - if requested_data.get("parent") is not None + Issue.objects.filter(pk=requested_data.get("parent_id")).first() + if requested_data.get("parent_id") is not None else None ) @@ -188,9 +188,9 @@ def track_state( issue_activities, epoch, ): - if current_instance.get("state") != requested_data.get("state"): - new_state = State.objects.get(pk=requested_data.get("state", None)) - old_state = State.objects.get(pk=current_instance.get("state", None)) + if current_instance.get("state_id") != requested_data.get("state_id"): + new_state = State.objects.get(pk=requested_data.get("state_id", None)) + old_state = State.objects.get(pk=current_instance.get("state_id", None)) issue_activities.append( IssueActivity( @@ -288,10 +288,10 @@ def track_labels( epoch, ): requested_labels = set( - [str(lab) for lab in requested_data.get("labels", [])] + [str(lab) for lab in requested_data.get("label_ids", [])] ) current_labels = set( - [str(lab) for lab in current_instance.get("labels", [])] + [str(lab) for lab in current_instance.get("label_ids", [])] ) added_labels = requested_labels - current_labels @@ -350,10 +350,10 @@ def track_assignees( epoch, ): requested_assignees = set( - [str(asg) for asg in requested_data.get("assignees", [])] + [str(asg) for asg in requested_data.get("assignee_ids", [])] ) current_assignees = set( - [str(asg) for asg in current_instance.get("assignees", [])] + [str(asg) for asg in current_instance.get("assignee_ids", [])] ) added_assignees = requested_assignees - current_assignees @@ -541,14 +541,14 @@ def update_issue_activity( ): ISSUE_ACTIVITY_MAPPER = { "name": track_name, - "parent": track_parent, + "parent_id": track_parent, "priority": track_priority, - "state": track_state, + "state_id": track_state, "description_html": track_description, "target_date": track_target_date, "start_date": track_start_date, - "labels": track_labels, - "assignees": track_assignees, + "label_ids": track_labels, + "assignee_ids": track_assignees, "estimate_point": track_estimate_points, "archived_at": track_archive_at, "closed_to": track_closed_to, @@ -1646,4 +1646,4 @@ def issue_activity( if settings.DEBUG: print(e) capture_exception(e) - return + return \ No newline at end of file diff --git a/packages/types/src/issues/activity/base.d.ts b/packages/types/src/issues/activity/base.d.ts new file mode 100644 index 000000000..9f17d78c7 --- /dev/null +++ b/packages/types/src/issues/activity/base.d.ts @@ -0,0 +1,58 @@ +export * from "./issue_activity"; +export * from "./issue_comment"; +export * from "./issue_comment_reaction"; + +import { TIssuePriorities } from "../issues"; + +// root types +export type TIssueActivityWorkspaceDetail = { + name: string; + slug: string; + id: string; +}; + +export type TIssueActivityProjectDetail = { + id: string; + identifier: string; + name: string; + cover_image: string; + description: string | null; + emoji: string | null; + icon_prop: { + name: string; + color: string; + } | null; +}; + +export type TIssueActivityIssueDetail = { + id: string; + sequence_id: boolean; + sort_order: boolean; + name: string; + description_html: string; + priority: TIssuePriorities; + start_date: string; + target_date: string; + is_draft: boolean; +}; + +export type TIssueActivityUserDetail = { + id: string; + first_name: string; + last_name: string; + avatar: string; + is_bot: boolean; + display_name: string; +}; + +export type TIssueActivityComment = + | { + id: string; + activity_type: "COMMENT"; + created_at?: string; + } + | { + id: string; + activity_type: "ACTIVITY"; + created_at?: string; + }; diff --git a/packages/types/src/issues/activity/issue_activity.d.ts b/packages/types/src/issues/activity/issue_activity.d.ts new file mode 100644 index 000000000..391d06c12 --- /dev/null +++ b/packages/types/src/issues/activity/issue_activity.d.ts @@ -0,0 +1,41 @@ +import { + TIssueActivityWorkspaceDetail, + TIssueActivityProjectDetail, + TIssueActivityIssueDetail, + TIssueActivityUserDetail, +} from "./base"; + +export type TIssueActivity = { + id: string; + workspace: string; + workspace_detail: TIssueActivityWorkspaceDetail; + project: string; + project_detail: TIssueActivityProjectDetail; + issue: string; + issue_detail: TIssueActivityIssueDetail; + actor: string; + actor_detail: TIssueActivityUserDetail; + created_at: string; + updated_at: string; + created_by: string | undefined; + updated_by: string | undefined; + attachments: any[]; + + verb: string; + field: string | undefined; + old_value: string | undefined; + new_value: string | undefined; + comment: string | undefined; + old_identifier: string | undefined; + new_identifier: string | undefined; + epoch: number; + issue_comment: string | null; +}; + +export type TIssueActivityMap = { + [issue_id: string]: TIssueActivity; +}; + +export type TIssueActivityIdMap = { + [issue_id: string]: string[]; +}; diff --git a/packages/types/src/issues/activity/issue_comment.d.ts b/packages/types/src/issues/activity/issue_comment.d.ts new file mode 100644 index 000000000..45d34be08 --- /dev/null +++ b/packages/types/src/issues/activity/issue_comment.d.ts @@ -0,0 +1,39 @@ +import { + TIssueActivityWorkspaceDetail, + TIssueActivityProjectDetail, + TIssueActivityIssueDetail, + TIssueActivityUserDetail, +} from "./base"; + +export type TIssueComment = { + id: string; + workspace: string; + workspace_detail: TIssueActivityWorkspaceDetail; + project: string; + project_detail: TIssueActivityProjectDetail; + issue: string; + issue_detail: TIssueActivityIssueDetail; + actor: string; + actor_detail: TIssueActivityUserDetail; + created_at: string; + updated_at: string; + created_by: string | undefined; + updated_by: string | undefined; + attachments: any[]; + + comment_reactions: any[]; + comment_stripped: string; + comment_html: string; + comment_json: object; + external_id: string | undefined; + external_source: string | undefined; + access: "EXTERNAL" | "INTERNAL"; +}; + +export type TIssueCommentMap = { + [issue_id: string]: TIssueComment; +}; + +export type TIssueCommentIdMap = { + [issue_id: string]: string[]; +}; diff --git a/packages/types/src/issues/issue_comment_reaction.d.ts b/packages/types/src/issues/activity/issue_comment_reaction.d.ts similarity index 75% rename from packages/types/src/issues/issue_comment_reaction.d.ts rename to packages/types/src/issues/activity/issue_comment_reaction.d.ts index 8a3695e85..892a3e906 100644 --- a/packages/types/src/issues/issue_comment_reaction.d.ts +++ b/packages/types/src/issues/activity/issue_comment_reaction.d.ts @@ -1,20 +1,20 @@ export type TIssueCommentReaction = { id: string; + comment: string; + actor: string; + reaction: string; + workspace: string; + project: string; created_at: Date; updated_at: Date; - reaction: string; created_by: string; updated_by: string; - project: string; - workspace: string; - actor: string; - comment: string; }; export type TIssueCommentReactionMap = { - [issue_id: string]: TIssueCommentReaction; + [reaction_id: string]: TIssueCommentReaction; }; export type TIssueCommentReactionIdMap = { - [issue_id: string]: string[]; + [comment_id: string]: { [reaction: string]: string[] }; }; diff --git a/packages/types/src/issues/base.d.ts b/packages/types/src/issues/base.d.ts index 08daceb16..ae210d3b1 100644 --- a/packages/types/src/issues/base.d.ts +++ b/packages/types/src/issues/base.d.ts @@ -4,9 +4,8 @@ export * from "./issue_reaction"; export * from "./issue_link"; export * from "./issue_attachment"; export * from "./issue_relation"; -export * from "./issue_activity"; -export * from "./issue_comment_reaction"; export * from "./issue_sub_issues"; +export * from "./activity/base"; export type TLoader = "init-loader" | "mutation" | undefined; diff --git a/packages/types/src/issues/issue_activity.d.ts b/packages/types/src/issues/issue_activity.d.ts deleted file mode 100644 index 2ce22b361..000000000 --- a/packages/types/src/issues/issue_activity.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -export type TIssueActivity = { - access?: "EXTERNAL" | "INTERNAL"; - actor: string; - actor_detail: IUserLite; - attachments: any[]; - comment?: string; - comment_html?: string; - comment_stripped?: string; - created_at: Date; - created_by: string; - field: string | null; - id: string; - issue: string | null; - issue_comment?: string | null; - issue_detail: { - description_html: string; - id: string; - name: string; - priority: string | null; - sequence_id: string; - } | null; - new_identifier: string | null; - new_value: string | null; - old_identifier: string | null; - old_value: string | null; - project: string; - project_detail: IProjectLite; - updated_at: Date; - updated_by: string; - verb: string; - workspace: string; - workspace_detail?: IWorkspaceLite; -}; - -export type TIssueActivityMap = { - [issue_id: string]: TIssueActivity; -}; - -export type TIssueActivityIdMap = { - [issue_id: string]: string[]; -}; diff --git a/packages/types/src/issues/issue_reaction.d.ts b/packages/types/src/issues/issue_reaction.d.ts index 6fc071a9f..88ef27426 100644 --- a/packages/types/src/issues/issue_reaction.d.ts +++ b/packages/types/src/issues/issue_reaction.d.ts @@ -13,7 +13,7 @@ export type TIssueReaction = { }; export type TIssueReactionMap = { - [issue_id: string]: TIssueReaction; + [reaction_id: string]: TIssueReaction; }; export type TIssueReactionIdMap = { diff --git a/web/components/core/activity.tsx b/web/components/core/activity.tsx index e49205459..792102be0 100644 --- a/web/components/core/activity.tsx +++ b/web/components/core/activity.tsx @@ -187,109 +187,6 @@ const activityDetails: { }, icon: