forked from konveyor/tackle2-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ [WIP] Implement the Task Manager drawer
Resolves: konveyor#1938 Add a queued tasks count badge plus and item drawer. - Use the standard `NotificationDrawer` attached to the `Page` layout to render the task manager item 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. - Add `TaskQueue` and query for the notification badge __Still Needs__: - Task rows in the notification drawer - Infinite scroll on the task list (or at least a load more link/icon, maybe a visual indicator that more can be fetched on scroll or click) - Individual task actions Related changes: - Update the `HeaderApp` to handle visibility of masthead toolbar items at the `ToolbarGroup` level. - Rename `SSOMenu` to `SsoToolbarItem`. Signed-off-by: Scott J Dickerson <[email protected]>
- Loading branch information
Showing
12 changed files
with
422 additions
and
136 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
45 changes: 45 additions & 0 deletions
45
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,45 @@ | ||
import { useFetchTaskQueue } from "@app/queries/tasks"; | ||
import React, { useContext, 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); | ||
|
||
return ( | ||
<TaskManagerContext.Provider | ||
value={{ | ||
queuedCount: taskQueue.total, | ||
isExpanded, | ||
setIsExpanded, | ||
}} | ||
> | ||
{children} | ||
</TaskManagerContext.Provider> | ||
); | ||
}; |
40 changes: 40 additions & 0 deletions
40
client/src/app/components/task-manager/TaskManagerDrawer.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,40 @@ | ||
import React, { forwardRef } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { | ||
NotificationDrawer, | ||
NotificationDrawerBody, | ||
NotificationDrawerHeader, | ||
NotificationDrawerList, | ||
} from "@patternfly/react-core"; | ||
import { useTaskManagerContext } from "./TaskManagerContext"; | ||
|
||
interface TaskManagerDrawerProps { | ||
ref?: React.ForwardedRef<HTMLElement>; | ||
} | ||
|
||
export const TaskManagerDrawer: React.FC<TaskManagerDrawerProps> = forwardRef( | ||
(_props, ref) => { | ||
const { isExpanded, setIsExpanded, queuedCount } = useTaskManagerContext(); | ||
|
||
const closeDrawer = () => { | ||
setIsExpanded(!isExpanded); | ||
}; | ||
|
||
return ( | ||
<NotificationDrawer ref={ref}> | ||
<NotificationDrawerHeader | ||
title="Task Manager" | ||
customText={`${queuedCount} queued`} | ||
onClose={closeDrawer} | ||
> | ||
<Link to="/tasks">View All Tasks</Link> | ||
</NotificationDrawerHeader> | ||
<NotificationDrawerBody> | ||
<NotificationDrawerList></NotificationDrawerList> | ||
</NotificationDrawerBody> | ||
</NotificationDrawer> | ||
); | ||
} | ||
); | ||
|
||
TaskManagerDrawer.displayName = "TaskManagerDrawer"; |
22 changes: 22 additions & 0 deletions
22
client/src/app/components/task-manager/TaskNotificaitonBadge.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,22 @@ | ||
import React from "react"; | ||
import { NotificationBadge } from "@patternfly/react-core"; | ||
import { useTaskManagerContext } from "./TaskManagerContext"; | ||
|
||
export const TaskNotificationBadge: React.FC = () => { | ||
const { isExpanded, setIsExpanded, queuedCount } = useTaskManagerContext(); | ||
|
||
const badgeClick = () => { | ||
setIsExpanded(!isExpanded); | ||
}; | ||
|
||
return ( | ||
<NotificationBadge | ||
id="task-notification-badge" | ||
aria-label="Count of queued tasks" | ||
variant={queuedCount > 0 ? "unread" : "read"} | ||
count={queuedCount} | ||
onClick={badgeClick} | ||
isExpanded={isExpanded} | ||
/> | ||
); | ||
}; |
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
Oops, something went wrong.