Skip to content

Commit

Permalink
Add tooltip when not authorized
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-farache committed Jun 19, 2024
1 parent a1731ea commit e3066d7
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@backstage/core-plugin-api';
import { usePermission } from '@backstage/plugin-permission-react';

import { Tooltip } from '@mui/material';
import Button from '@mui/material/Button';
import Grid from '@mui/material/Grid';
import Skeleton from '@mui/material/Skeleton';
Expand Down Expand Up @@ -68,14 +69,19 @@ export const WorkflowDefinitionViewerPage = () => {
<Skeleton variant="text" width="5rem" />
) : (
!loadingPermission && (
<Button
variant="contained"
color="primary"
onClick={handleExecute}
disabled={!canRun}
<Tooltip
title="user not authorized to execute workflow"
disableHoverListener={canRun}
>
Run
</Button>
<Button
variant="contained"
color="primary"
onClick={handleExecute}
disabled={!canRun}
>
Run
</Button>
</Tooltip>
)
)}
</Grid>
Expand Down
62 changes: 39 additions & 23 deletions plugins/orchestrator/src/components/WorkflowInstancePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '@backstage/core-plugin-api';
import { usePermission } from '@backstage/plugin-permission-react';

import { Tooltip } from '@mui/material';
import Button from '@mui/material/Button';
import Grid from '@mui/material/Grid';

Expand Down Expand Up @@ -211,39 +212,54 @@ export const WorkflowInstancePage = ({
{!canRerun && (
<>
<Grid item>
<Button
variant="contained"
color="primary"
disabled={!permittedToAbort.allowed || !canAbort}
onClick={canAbort ? handleRerun : undefined}
<Tooltip
title="user not authorized to execute workflow"
disableHoverListener={permittedToExecute.allowed}
>
Retrigger
</Button>
<Button
variant="contained"
color="primary"
disabled={!permittedToExecute.allowed || !canRerun}
onClick={canRerun ? handleRerun : undefined}
>
Retrigger
</Button>
</Tooltip>
</Grid>
<Grid item>
<Button
variant="contained"
color="secondary"
disabled={!permittedToAbort.allowed || !canAbort}
onClick={
canAbort ? toggleAbortConfirmationDialog : undefined
}
<Tooltip
title="user not authorized to abort workflow"
disableHoverListener={permittedToAbort.allowed}
>
Abort
</Button>
<Button
variant="contained"
color="secondary"
disabled={!permittedToAbort.allowed || !canAbort}
onClick={
canAbort ? toggleAbortConfirmationDialog : undefined
}
>
Abort
</Button>
</Tooltip>
</Grid>
</>
)}
{!canAbort && (
<Grid item>
<Button
variant="contained"
color="primary"
disabled={!permittedToExecute.allowed || !canRerun}
onClick={canRerun ? handleRerun : undefined}
<Tooltip
title="user not authorized to execute workflow"
disableHoverListener={permittedToExecute.allowed}
>
Rerun
</Button>
<Button
variant="contained"
color="primary"
disabled={!permittedToExecute.allowed || !canRerun}
onClick={canRerun ? handleRerun : undefined}
>
Rerun
</Button>
</Tooltip>
</Grid>
)}
</Grid>
Expand Down

0 comments on commit e3066d7

Please sign in to comment.