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 <nitinkoche03@gmail.com>
This commit is contained in:
Yura Levchenko
2024-10-02 08:58:51 +02:00
committed by GitHub
co-authored by Nitin Koche
parent a8c07bf77f
commit d7dd41e7e4
2 changed files with 8 additions and 8 deletions
@@ -20,7 +20,7 @@ export const ObjectTasks = ({
return (
<StyledContainer>
<ObjectFilterDropdownScope filterScopeId="entity-tasks-filter-scope">
<TaskGroups targetableObjects={[targetableObject]} showAddButton />
<TaskGroups targetableObjects={[targetableObject]} />
</ObjectFilterDropdownScope>
</StyledContainer>
);
@@ -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 (
<StyledContainer>
@@ -103,7 +103,7 @@ export const TaskGroups = ({
title={status}
tasks={tasksByStatus}
button={
showAddButton && (
(status === 'TODO' || !hasTodoStatus) && (
<AddTaskButton activityTargetableObjects={targetableObjects} />
)
}