-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Implement the Task Manager drawer (#1955)
Resolves: #1938 Add a queued tasks count badge and a task list drawer. - Add a `TaskManagerContext` to control the count indicator and visibility of the drawer. This is a top level context so the task manager is available on all pages. The context itself monitors the task queue report endpoint[^1] that drives the notification badge count. - Use the standard `NotificationDrawer` attached to the `Page` layout to render the task manager item drawer. - The `TaskNotificationBadge` is integrated to the application's `HeaderApp`. - The `TaskManagerDrawer` shows the list of currently "queued" tasks[^2] in task id descending sort order (most recently created tasks on the top). - Each task item is rendered in a "collapsed" state and after a click will render "expanded". The expanded state include the started timestamp. - **_Note 1:_** Until fetch more / infinite scroll is implemented in the task manager drawer list, only the first 20 queued tasks will be displayed. - **_Note 2:_** Task actions need to be added to the task items. These should reuse the same set of actions as the task table in #1957. Related changes: - Update the `HeaderApp` to handle visibility of masthead toolbar items at the `ToolbarGroup` level. - Rename `SSOMenu` to `SsoToolbarItem`. - Updated the typing on a few task related API functions. [^1]: konveyor/tackle2-hub#641 [^2]: konveyor/tackle2-hub#640 --------- Signed-off-by: Scott J Dickerson <[email protected]>
- Loading branch information
Showing
14 changed files
with
653 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
client/src/app/components/task-manager/TaskManagerContext.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useFetchTaskQueue } from "@app/queries/tasks"; | ||
import React, { useContext, useMemo, useState } from "react"; | ||
|
||
interface TaskManagerContextProps { | ||
/** Count of the currently "queued" Tasks */ | ||
queuedCount: number; | ||
|
||
/** Is the task manager drawer currently visible? */ | ||
isExpanded: boolean; | ||
|
||
/** Control if the task manager drawer is visible */ | ||
setIsExpanded: (value: boolean) => void; | ||
} | ||
|
||
const TaskManagerContext = React.createContext<TaskManagerContextProps>({ | ||
queuedCount: 0, | ||
|
||
isExpanded: false, | ||
setIsExpanded: () => undefined, | ||
}); | ||
|
||
export const useTaskManagerContext = () => { | ||
const values = useContext(TaskManagerContext); | ||
|
||
return values; | ||
}; | ||
|
||
export const TaskManagerProvider: React.FC<{ children: React.ReactNode }> = ({ | ||
children, | ||
}) => { | ||
const { taskQueue } = useFetchTaskQueue(); | ||
const [isExpanded, setIsExpanded] = useState(false); | ||
|
||
const contextValue = useMemo( | ||
() => ({ | ||
queuedCount: taskQueue.total, | ||
isExpanded, | ||
setIsExpanded, | ||
}), | ||
[taskQueue.total, isExpanded, setIsExpanded] | ||
); | ||
|
||
return ( | ||
<TaskManagerContext.Provider value={contextValue}> | ||
{children} | ||
</TaskManagerContext.Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.task-manager-item-collapsed .pf-v5-c-notification-drawer__list-item-header { | ||
margin-bottom: 0; | ||
} |
Oops, something went wrong.