From feb0e40559f056f3fd74ddf0ef150f4775f0a3f7 Mon Sep 17 00:00:00 2001 From: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Date: Thu, 23 Mar 2023 18:10:28 +0530 Subject: [PATCH] refactor: state with group 'completed' or 'cancelled' are collapsed by default (#506) --- .../components/core/board-view/all-boards.tsx | 5 +- .../core/board-view/single-board.tsx | 196 +++++++++--------- 2 files changed, 106 insertions(+), 95 deletions(-) diff --git a/apps/app/components/core/board-view/all-boards.tsx b/apps/app/components/core/board-view/all-boards.tsx index 4ee6175d2..ea2bb7147 100644 --- a/apps/app/components/core/board-view/all-boards.tsx +++ b/apps/app/components/core/board-view/all-boards.tsx @@ -76,7 +76,10 @@ export const AllBoards: React.FC = ({ if (groupedByIssues[singleGroup].length === 0) return ( -
+
{currentState && getStateGroupIcon(currentState.group, "16", "16", currentState.color)} diff --git a/apps/app/components/core/board-view/single-board.tsx b/apps/app/components/core/board-view/single-board.tsx index e987c700d..52c3d7021 100644 --- a/apps/app/components/core/board-view/single-board.tsx +++ b/apps/app/components/core/board-view/single-board.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import { useRouter } from "next/router"; @@ -58,6 +58,11 @@ export const SingleBoard: React.FC = ({ const isNotAllowed = userAuth.isGuest || userAuth.isViewer; + useEffect(() => { + if (currentState?.group === "completed" || currentState?.group === "cancelled") + setIsCollapsed(false); + }, [currentState]); + return (
@@ -68,102 +73,105 @@ export const SingleBoard: React.FC = ({ isCollapsed={isCollapsed} setIsCollapsed={setIsCollapsed} /> - - {(provided, snapshot) => ( -
- {orderBy !== "sort_order" && ( - <> -
-
- This board is ordered by {replaceUnderscoreIfSnakeCase(orderBy ?? "created_at")} -
- - )} - {groupedByIssues?.[groupTitle].map((issue, index) => ( - - {(provided, snapshot) => ( - handleEditIssue(issue)} - makeIssueCopy={() => makeIssueCopy(issue)} - handleDeleteIssue={handleDeleteIssue} - handleTrashBox={handleTrashBox} - removeIssue={() => { - if (removeIssue && issue.bridge_id) removeIssue(issue.bridge_id); - }} - userAuth={userAuth} - /> - )} - - ))} - + {(provided, snapshot) => ( +
- {provided.placeholder} - - {type === "issue" ? ( - - ) : ( - +
+
- - Add Issue - - } - optionsPosition="left" - noBorder + This board is ordered by{" "} + {replaceUnderscoreIfSnakeCase(orderBy ?? "created_at")} +
+ + )} + {groupedByIssues?.[groupTitle].map((issue, index) => ( + + {(provided, snapshot) => ( + handleEditIssue(issue)} + makeIssueCopy={() => makeIssueCopy(issue)} + handleDeleteIssue={handleDeleteIssue} + handleTrashBox={handleTrashBox} + removeIssue={() => { + if (removeIssue && issue.bridge_id) removeIssue(issue.bridge_id); + }} + userAuth={userAuth} + /> + )} + + ))} + - Create new - {openIssuesListModal && ( - - Add an existing issue - - )} - - )} -
- )} - + {provided.placeholder} + + {type === "issue" ? ( + + ) : ( + + + Add Issue + + } + optionsPosition="left" + noBorder + > + Create new + {openIssuesListModal && ( + + Add an existing issue + + )} + + )} +
+ )} + + )}
);