Skip to content

Commit

Permalink
feat: Added tooltip when button is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaslf97 committed Oct 23, 2024
1 parent 663d92f commit a4eeb32
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/features/Compute/CaseGroup/CaseButtons/CaseButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,21 @@ export const CaseButtons = ({
setDeleteConfirm(false);
};

const deleteTooltip = () => {
if (!isOwner()) return 'Can not delete because you are not owner or admin.';
return 'Can not delete unsaved case.';
};

const duplicateTooltip = () => {
if (!isOwner())
return 'Can not duplicate because you are not owner or admin.';
return 'Can not duplicate unsaved case.';
};

return (
<Styled.ButtonDiv>
{id.length < 3 || !isOwner() ? (
<Tooltip title={'Can not delete unsaved case.'}>
<Tooltip title={deleteTooltip()}>
<Button disabled variant="ghost_icon" aria-label="remove">
<Icon data={DELETE} size={24}></Icon>
</Button>
Expand All @@ -81,7 +92,7 @@ export const CaseButtons = ({
{caseType === 'Variogram' && (
<>
{id.length < 3 || !isOwner() ? (
<Tooltip title={'Can not duplicate unsaved case.'}>
<Tooltip title={duplicateTooltip()}>
<Button disabled variant="ghost_icon" aria-label="duplicate">
<Icon data={COPY} size={24}></Icon>
</Button>
Expand Down

0 comments on commit a4eeb32

Please sign in to comment.