From 38934e8b99c021e4fb54c9defabbd7433206266f Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Thu, 24 Aug 2023 19:46:12 +0530 Subject: [PATCH] chore: group by assignees option for project issues (#1957) * dev: group by assignees option for project issues * fix: no assignee title --------- Co-authored-by: Aaryan Khandelwal --- .../core/views/board-view/board-header.tsx | 13 ++++++++----- apps/app/components/core/views/issues-view.tsx | 3 ++- .../components/core/views/list-view/single-list.tsx | 6 ++++-- .../issues/my-issues/my-issues-view-options.tsx | 6 +++++- .../profile/profile-issues-view-options.tsx | 6 +++++- apps/app/constants/issue.ts | 1 + apps/app/types/issues.d.ts | 1 + 7 files changed, 26 insertions(+), 10 deletions(-) diff --git a/apps/app/components/core/views/board-view/board-header.tsx b/apps/app/components/core/views/board-view/board-header.tsx index 919bc36a34f..d5b11f5f01d 100644 --- a/apps/app/components/core/views/board-view/board-header.tsx +++ b/apps/app/components/core/views/board-view/board-header.tsx @@ -12,7 +12,7 @@ import useProjects from "hooks/use-projects"; // component import { Avatar, Icon } from "components/ui"; // icons -import { ArrowsPointingInIcon, ArrowsPointingOutIcon, PlusIcon } from "@heroicons/react/24/outline"; +import { PlusIcon } from "@heroicons/react/24/outline"; import { getPriorityIcon, getStateGroupIcon } from "components/icons"; // helpers import { addSpaceIfCamelCase } from "helpers/string.helper"; @@ -56,10 +56,10 @@ export const BoardHeader: React.FC = ({ ); const { data: members } = useSWR( - workspaceSlug && projectId && selectedGroup === "created_by" + workspaceSlug && projectId && (selectedGroup === "created_by" || selectedGroup === "assignees") ? PROJECT_MEMBERS(projectId.toString()) : null, - workspaceSlug && projectId && selectedGroup === "created_by" + workspaceSlug && projectId && (selectedGroup === "created_by" || selectedGroup === "assignees") ? () => projectService.projectMembers(workspaceSlug.toString(), projectId.toString()) : null ); @@ -79,9 +79,11 @@ export const BoardHeader: React.FC = ({ case "project": title = projects?.find((p) => p.id === groupTitle)?.name ?? "None"; break; + case "assignees": case "created_by": const member = members?.find((member) => member.member.id === groupTitle)?.member; - title = member?.display_name ?? ""; + title = member ? member.display_name : "None"; + break; } @@ -122,9 +124,10 @@ export const BoardHeader: React.FC = ({ /> ); break; + case "assignees": case "created_by": const member = members?.find((member) => member.member.id === groupTitle)?.member; - icon = ; + icon = member ? : <>; break; } diff --git a/apps/app/components/core/views/issues-view.tsx b/apps/app/components/core/views/issues-view.tsx index 5f33a6cb011..ffa3f8165cf 100644 --- a/apps/app/components/core/views/issues-view.tsx +++ b/apps/app/components/core/views/issues-view.tsx @@ -514,7 +514,8 @@ export const IssuesView: React.FC = ({ dragDisabled={ selectedGroup === "created_by" || selectedGroup === "labels" || - selectedGroup === "state_detail.group" + selectedGroup === "state_detail.group" || + selectedGroup === "assignees" } emptyState={{ title: cycleId diff --git a/apps/app/components/core/views/list-view/single-list.tsx b/apps/app/components/core/views/list-view/single-list.tsx index 5efc93f3ce7..03ef7772714 100644 --- a/apps/app/components/core/views/list-view/single-list.tsx +++ b/apps/app/components/core/views/list-view/single-list.tsx @@ -94,9 +94,10 @@ export const SingleList: React.FC = ({ case "project": title = projects?.find((p) => p.id === groupTitle)?.name ?? "None"; break; + case "assignees": case "created_by": const member = members?.find((member) => member.member.id === groupTitle)?.member; - title = member?.display_name ?? ""; + title = member ? member.display_name : "None"; break; } @@ -137,9 +138,10 @@ export const SingleList: React.FC = ({ /> ); break; + case "assignees": case "created_by": const member = members?.find((member) => member.member.id === groupTitle)?.member; - icon = ; + icon = member ? : <>; break; } diff --git a/apps/app/components/issues/my-issues/my-issues-view-options.tsx b/apps/app/components/issues/my-issues/my-issues-view-options.tsx index 4c2a4bed1e8..7c6a6fe449c 100644 --- a/apps/app/components/issues/my-issues/my-issues-view-options.tsx +++ b/apps/app/components/issues/my-issues/my-issues-view-options.tsx @@ -156,7 +156,11 @@ export const MyIssuesViewOptions: React.FC = () => { > {GROUP_BY_OPTIONS.map((option) => { if (issueView === "kanban" && option.key === null) return null; - if (option.key === "state" || option.key === "created_by") + if ( + option.key === "state" || + option.key === "created_by" || + option.key === "assignees" + ) return null; return ( diff --git a/apps/app/components/profile/profile-issues-view-options.tsx b/apps/app/components/profile/profile-issues-view-options.tsx index 382f8f2202d..38faf500be4 100644 --- a/apps/app/components/profile/profile-issues-view-options.tsx +++ b/apps/app/components/profile/profile-issues-view-options.tsx @@ -183,7 +183,11 @@ export const ProfileIssuesViewOptions: React.FC = () => { > {GROUP_BY_OPTIONS.map((option) => { if (issueView === "kanban" && option.key === null) return null; - if (option.key === "state" || option.key === "created_by") + if ( + option.key === "state" || + option.key === "created_by" || + option.key === "assignees" + ) return null; return ( diff --git a/apps/app/constants/issue.ts b/apps/app/constants/issue.ts index 3665f180cc4..4e8bb0944a3 100644 --- a/apps/app/constants/issue.ts +++ b/apps/app/constants/issue.ts @@ -7,6 +7,7 @@ export const GROUP_BY_OPTIONS: Array<{ { name: "Priority", key: "priority" }, { name: "Project", key: "project" }, { name: "Labels", key: "labels" }, + { name: "Assignees", key: "assignees" }, { name: "Created by", key: "created_by" }, { name: "None", key: null }, ]; diff --git a/apps/app/types/issues.d.ts b/apps/app/types/issues.d.ts index edbe512a6a7..79ebb04f4f6 100644 --- a/apps/app/types/issues.d.ts +++ b/apps/app/types/issues.d.ts @@ -234,6 +234,7 @@ export type TIssueGroupByOptions = | "created_by" | "state_detail.group" | "project" + | "assignees" | null; export type TIssueOrderByOptions =