From d7dd41e7e454cc4e50bb436871e30ca3ccefaebc Mon Sep 17 00:00:00 2001 From: Yura Levchenko Date: Wed, 2 Oct 2024 08:58:51 +0200 Subject: [PATCH] Changed condition on which 'Add task' button is displayed (#7333) (#7362) This PR addresses issue #7333. It updates the condition for displaying the 'Add task' button. The button is now only visible for the 'TODO' section or when no 'TODO' block is present (i.e., there are no tasks in this category). Additionally, I removed the unused showAddButton, which is no longer necessary due to the updated logic. ![image](https://github.com/user-attachments/assets/571542d7-1b0f-4b91-afcf-4592490f1f72) ![image](https://github.com/user-attachments/assets/46974459-d3cd-497a-a6b6-9302cbff7716) --------- Co-authored-by: Nitin Koche --- .../activities/tasks/components/ObjectTasks.tsx | 2 +- .../activities/tasks/components/TaskGroups.tsx | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/twenty-front/src/modules/activities/tasks/components/ObjectTasks.tsx b/packages/twenty-front/src/modules/activities/tasks/components/ObjectTasks.tsx index a798a818d865..9e2dd7a4bc54 100644 --- a/packages/twenty-front/src/modules/activities/tasks/components/ObjectTasks.tsx +++ b/packages/twenty-front/src/modules/activities/tasks/components/ObjectTasks.tsx @@ -20,7 +20,7 @@ export const ObjectTasks = ({ return ( - + ); diff --git a/packages/twenty-front/src/modules/activities/tasks/components/TaskGroups.tsx b/packages/twenty-front/src/modules/activities/tasks/components/TaskGroups.tsx index a6e4999773bc..ae484382ffcc 100644 --- a/packages/twenty-front/src/modules/activities/tasks/components/TaskGroups.tsx +++ b/packages/twenty-front/src/modules/activities/tasks/components/TaskGroups.tsx @@ -32,13 +32,9 @@ const StyledContainer = styled.div` type TaskGroupsProps = { filterDropdownId?: string; targetableObjects?: ActivityTargetableObject[]; - showAddButton?: boolean; }; -export const TaskGroups = ({ - targetableObjects, - showAddButton, -}: TaskGroupsProps) => { +export const TaskGroups = ({ targetableObjects }: TaskGroupsProps) => { const { tasks, tasksLoading } = useTasks({ targetableObjects: targetableObjects ?? [], }); @@ -93,7 +89,11 @@ export const TaskGroups = ({ const sortedTasksByStatus = Object.entries( groupBy(tasks, ({ status }) => status), - ).toSorted(([statusA], [statusB]) => statusB.localeCompare(statusA)); + ).sort(([statusA], [statusB]) => statusB.localeCompare(statusA)); + + const hasTodoStatus = sortedTasksByStatus.some( + ([status]) => status === 'TODO', + ); return ( @@ -103,7 +103,7 @@ export const TaskGroups = ({ title={status} tasks={tasksByStatus} button={ - showAddButton && ( + (status === 'TODO' || !hasTodoStatus) && ( ) }