Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Adding a tooltip when the button is unavailable #2126

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 })}`
aviya-gidan marked this conversation as resolved.
Show resolved Hide resolved
: "",
},
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
Loading