Skip to content

Commit

Permalink
Admin/Roles: adjust roles grid display (#2275)
Browse files Browse the repository at this point in the history
  • Loading branch information
nl0 authored Jul 16, 2021
1 parent 8d67545 commit d5b37ba
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions catalog/app/containers/Admin/Roles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ import ROLE_UPDATE_UNMANAGED_MUTATION from './RolesUpdateUnmanaged.generated'
import ROLE_DELETE_MUTATION from './RolesDelete.generated'
import { RoleSelectionFragment as Role } from './RoleSelection.generated'

const useMonoStyles = M.makeStyles((t) => ({
root: {
fontFamily: (t.typography as $TSFixMe).monospace.fontFamily,
},
}))

function Mono({ children }: React.PropsWithChildren<{}>) {
const classes = useMonoStyles()
return <span className={classes.root}>{children}</span>
}

const IAM_HOME = 'https://console.aws.amazon.com/iam/home'
const ARN_ROLE_RE = /^arn:aws:iam:[^:]*:\d+:role\/(.+)$/
const ARN_POLICY_RE = /^arn:aws:iam:[^:]*:\d+:policy\/(.+)$/
Expand All @@ -59,17 +48,19 @@ const columns = [
props: { component: 'th', scope: 'row' },
},
{
id: 'type',
label: 'Type',
getValue: (r: Role) => r.__typename,
getDisplay: (_value: any, r: Role) =>
r.__typename === 'ManagedRole' ? (
<>Managed: access to {r.permissions.filter((p) => !!p.level).length} buckets</>
) : (
<>
Unmanaged: <Mono>{r.arn}</Mono>
</>
),
id: 'managed',
label: 'Managed',
getValue: (r: Role) => r.__typename === 'ManagedRole',
getDisplay: (value: boolean) => (value ? 'Yes' : 'No'),
},
{
id: 'buckets',
label: 'Buckets',
getValue: (r: Role) =>
r.__typename === 'ManagedRole'
? r.permissions.filter((p) => !!p.level).length
: null,
getDisplay: (buckets: number | null) => (buckets == null ? 'N/A' : buckets),
},
]

Expand Down Expand Up @@ -630,7 +621,8 @@ export default function Roles() {
{columns.map((col) => (
// @ts-expect-error
<M.TableCell key={col.id} {...col.props}>
{(col.getDisplay || R.identity)(col.getValue(i), i)}
{/* @ts-expect-error */}
{(col.getDisplay || R.identity)(col.getValue(i))}
</M.TableCell>
))}
<M.TableCell align="right" padding="none">
Expand Down

0 comments on commit d5b37ba

Please sign in to comment.