Skip to content

Commit

Permalink
feat: [IAC-2429]: IACM plugin unauthourized message
Browse files Browse the repository at this point in the history
  • Loading branch information
simonharness committed Sep 10, 2024
1 parent 41c0601 commit b6dbf42
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions plugins/harness-iacm/src/components/WorkspaceList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import useGetResources from '../../hooks/useGetResources';
import useProjectUrlSlugEntity from '../../hooks/useProjectUrlEntity';
import { useResourceSlugFromEntity } from './useResourceSlugFromEntity';
import ResourceTable from '../ResourceTable';
import { EmptyState } from '@backstage/core-components';

const useStyles = makeStyles(theme => ({
container: {
Expand Down Expand Up @@ -48,6 +49,16 @@ const useStyles = makeStyles(theme => ({
alignItems: 'center',
gap: '5px',
},
noAccess: {
padding: theme.spacing(2),
display: 'flex',

textAlign: 'center',
},
workspaceList: {
marginTop: '-40px',
},
workspaceItem: { padding: '0.75rem', fontSize: '1rem' },
}));

export interface Workspace {
Expand Down Expand Up @@ -153,6 +164,33 @@ function WorkspaceList() {
</Grid>
);

if (state === AsyncStatus.Unauthorized) {
const urls = Object.values(harnessWorkspaceUrlObject).map(url =>
url.replace('|', ''),
);
return (
<>
<EmptyState
title="You don't have the permission to View the following IaCM workspace(s)"
missing="info"
action={
<ul className={classes.workspaceList}>
{urls.map(workspace => (
<li
value={workspace}
key={workspace}
className={classes.workspaceItem}
>
<span>{workspace}</span>
</li>
))}
</ul>
}
/>
</>
);
}

if (state === AsyncStatus.Init || state === AsyncStatus.Loading) {
return (
<div className={classes.empty}>
Expand Down

0 comments on commit b6dbf42

Please sign in to comment.