From d477c19ad97b74dd845a1d244939821bffdd092c Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Thu, 23 Mar 2023 02:13:52 +0530 Subject: [PATCH] feat: show empty states toggle button in the views dropdown (#500) * feat: show empty states toggle button in views dropdown * refactor: empty state toggle naming convention, feat: hidden groups in section in the kanban board --- .../components/core/board-view/all-boards.tsx | 38 ++++++++++- .../components/core/issues-view-filter.tsx | 36 ++++++++--- .../components/core/list-view/all-lists.tsx | 4 +- apps/app/contexts/issue-view.context.tsx | 63 ++++++++++++++++--- apps/app/hooks/use-issues-view.tsx | 5 ++ 5 files changed, 125 insertions(+), 21 deletions(-) diff --git a/apps/app/components/core/board-view/all-boards.tsx b/apps/app/components/core/board-view/all-boards.tsx index 27aaace9b..4ee6175d2 100644 --- a/apps/app/components/core/board-view/all-boards.tsx +++ b/apps/app/components/core/board-view/all-boards.tsx @@ -2,8 +2,11 @@ import useProjectIssuesView from "hooks/use-issues-view"; // components import { SingleBoard } from "components/core/board-view/single-board"; +// helpers +import { addSpaceIfCamelCase } from "helpers/string.helper"; // types import { IIssue, IState, UserAuth } from "types"; +import { getStateGroupIcon } from "components/icons"; type Props = { type: "issue" | "cycle" | "module"; @@ -30,7 +33,11 @@ export const AllBoards: React.FC = ({ removeIssue, userAuth, }) => { - const { groupedByIssues, groupByProperty: selectedGroup, orderBy } = useProjectIssuesView(); + const { + groupedByIssues, + groupByProperty: selectedGroup, + showEmptyGroups, + } = useProjectIssuesView(); return ( <> @@ -40,6 +47,8 @@ export const AllBoards: React.FC = ({ const currentState = selectedGroup === "state" ? states?.find((s) => s.id === singleGroup) : null; + if (!showEmptyGroups && groupedByIssues[singleGroup].length === 0) return null; + return ( = ({ /> ); })} + {!showEmptyGroups && ( +
+

Hidden groups

+
+ {Object.keys(groupedByIssues).map((singleGroup, index) => { + const currentState = + selectedGroup === "state" ? states?.find((s) => s.id === singleGroup) : null; + + if (groupedByIssues[singleGroup].length === 0) + return ( +
+
+ {currentState && + getStateGroupIcon(currentState.group, "16", "16", currentState.color)} +

+ {selectedGroup === "state" + ? addSpaceIfCamelCase(currentState?.name ?? "") + : addSpaceIfCamelCase(singleGroup)} +

+
+ 0 +
+ ); + })} +
+
+ )} ) : null} diff --git a/apps/app/components/core/issues-view-filter.tsx b/apps/app/components/core/issues-view-filter.tsx index 4c2f8f7b7..a3e2af412 100644 --- a/apps/app/components/core/issues-view-filter.tsx +++ b/apps/app/components/core/issues-view-filter.tsx @@ -42,8 +42,10 @@ export const IssuesFilterView: React.FC = () => { setIssueViewToKanban, groupByProperty, setGroupByProperty, - setOrderBy, orderBy, + setOrderBy, + showEmptyGroups, + setShowEmptyGroups, filters, setFilters, resetFilterToDefault, @@ -203,9 +205,9 @@ export const IssuesFilterView: React.FC = () => { >
-
+
-

Group by

+

Group by

option.key === groupByProperty)?.name ?? @@ -226,7 +228,7 @@ export const IssuesFilterView: React.FC = () => {
-

Order by

+

Order by

option.key === orderBy)?.name ?? @@ -249,7 +251,7 @@ export const IssuesFilterView: React.FC = () => {
-

Issue type

+

Issue type

option.key === filters.type) @@ -271,17 +273,33 @@ export const IssuesFilterView: React.FC = () => { ))}
-
+
+

Show empty states

+
+
+