Skip to content

Commit

Permalink
Adding a tooltip when the button is unavailable and displaying a mess…
Browse files Browse the repository at this point in the history
…age explaining the unavailability

Signed-off-by: aviya-gidan <[email protected]>
  • Loading branch information
aviya-gidan committed Oct 13, 2024
1 parent 0d87a57 commit de69af0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 3 additions & 1 deletion client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@
"updateFailed": "Update failed.",
"updateRequestSubmitted": "Update request submitted.",
"cancelationFailed": "Cancelation failed.",
"cancelationRequestSubmitted": "Cancelation request submitted"
"cancelationRequestSubmitted": "Cancelation request submitted",
"cancelNotAvailable": "It is not possible to cancel a task that is in status {{statusName}}",
"togglePreemptionNotAvailable": "It is not possible to toggle preemption for a task that is in status {{statusName}}"
},
"proposedActions": {
"refactor": "Refactor",
Expand Down
8 changes: 5 additions & 3 deletions client/src/app/components/task-manager/TaskManagerDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ const TaskItem: React.FC<{
<MenuToggle
ref={toggleRef}
isExpanded={actionsExpanded}
isDisabled={taskActionItems.every(({ isDisabled }) => isDisabled)}
isDisabled={taskActionItems.every(
({ isAriaDisabled }) => isAriaDisabled
)}
onClick={() => onActionsExpandToggle(!actionsExpanded)}
variant="plain"
aria-label={`Actions for task ${task.name}`}
Expand All @@ -199,11 +201,11 @@ const TaskItem: React.FC<{
)}
>
<DropdownList>
{taskActionItems.map(({ title, onClick, isDisabled }) => (
{taskActionItems.map(({ title, onClick, isAriaDisabled }) => (
<DropdownItem
key={title}
onClick={onClick}
isDisabled={isDisabled}
isDisabled={isAriaDisabled}
>
{title}
</DropdownItem>
Expand Down
16 changes: 14 additions & 2 deletions client/src/app/pages/tasks/useTaskActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,27 @@ export const useTaskActions = (task: Task) => {
return [
{
title: t("actions.cancel"),
isDisabled: !canCancel(task.state),
isAriaDisabled: !canCancel(task.state),
tooltipProps: {
content: !canCancel(task.state)
? `${t("message.cancelNotAvailable", { statusName: task.state })}`
: "",
},
onClick: () => cancelTask(task.id),
},
{
title: task.policy?.preemptEnabled
? t("actions.disablePreemption")
: t("actions.enablePreemption"),
isDisabled: !canTogglePreemption(task.state),
isAriaDisabled: !canTogglePreemption(task.state),
onClick: () => togglePreemption(task),
tooltipProps: {
content: !canTogglePreemption(task.state)
? `${t("message.togglePreemptionNotAvailable", {
statusName: task.state,
})}`
: "",
},
},
{
title: t("actions.taskDetails"),
Expand Down

0 comments on commit de69af0

Please sign in to comment.