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 20, 2024
1 parent a1731ea commit c9ae279
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 26 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 @@ -64,10 +65,13 @@ export const WorkflowDefinitionViewerPage = () => {
)}
<Grid container item justifyContent="flex-end" spacing={1}>
<Grid item>
{loading ? (
{loading || loadingPermission ? (
<Skeleton variant="text" width="5rem" />
) : (
!loadingPermission && (
<Tooltip
title="user not authorized to execute workflow"
disableHoverListener={canRun}
>
<Button
variant="contained"
color="primary"
Expand All @@ -76,7 +80,7 @@ export const WorkflowDefinitionViewerPage = () => {
>
Run
</Button>
)
</Tooltip>
)}
</Grid>
</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 c9ae279

Please sign in to comment.