Skip to content

Commit

Permalink
Changed condition on which 'Add task' button is displayed (#7333) (#7362
Browse files Browse the repository at this point in the history
)

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 <[email protected]>
  • Loading branch information
lparz1val and ehconitin authored Oct 2, 2024
1 parent a8c07bf commit d7dd41e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ObjectTasks = ({
return (
<StyledContainer>
<ObjectFilterDropdownScope filterScopeId="entity-tasks-filter-scope">
<TaskGroups targetableObjects={[targetableObject]} showAddButton />
<TaskGroups targetableObjects={[targetableObject]} />
</ObjectFilterDropdownScope>
</StyledContainer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? [],
});
Expand Down Expand Up @@ -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 (
<StyledContainer>
Expand All @@ -103,7 +103,7 @@ export const TaskGroups = ({
title={status}
tasks={tasksByStatus}
button={
showAddButton && (
(status === 'TODO' || !hasTodoStatus) && (
<AddTaskButton activityTargetableObjects={targetableObjects} />
)
}
Expand Down

0 comments on commit d7dd41e

Please sign in to comment.