1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
7 StyleRulesCallback, WithStyles, withStyles, Card, CardContent, Grid,
8 Table, TableHead, TableRow, TableCell, TableBody, Tooltip, IconButton
9 } from '@material-ui/core';
10 import { ArvadosTheme } from '~/common/custom-theme';
11 import { MoreOptionsIcon } from '~/components/icon/icon';
12 import { ApiClientAuthorization } from '~/models/api-client-authorization';
14 type CssRules = 'root' | 'tableRow';
16 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
28 export interface ApiClientAuthorizationPanelRootActionProps {
29 openRowOptions: (event: React.MouseEvent<HTMLElement>, keepService: ApiClientAuthorization) => void;
32 export interface ApiClientAuthorizationPanelRootDataProps {
33 apiClientAuthorizations: ApiClientAuthorization[];
34 hasApiClientAuthorizations: boolean;
37 type ApiClientAuthorizationPanelRootProps = ApiClientAuthorizationPanelRootActionProps
38 & ApiClientAuthorizationPanelRootDataProps & WithStyles<CssRules>;
40 export const ApiClientAuthorizationPanelRoot = withStyles(styles)(
41 ({ classes, hasApiClientAuthorizations, apiClientAuthorizations, openRowOptions }: ApiClientAuthorizationPanelRootProps) =>
42 <Card className={classes.root}>
44 {hasApiClientAuthorizations && <Grid container direction="row">
48 <TableRow className={classes.tableRow}>
49 <TableCell>UUID</TableCell>
50 <TableCell>API Client ID</TableCell>
51 <TableCell>API Token</TableCell>
52 <TableCell>Created by IP address</TableCell>
53 <TableCell>Default owner</TableCell>
54 <TableCell>Expires at</TableCell>
55 <TableCell>Last used at</TableCell>
56 <TableCell>Last used by IP address</TableCell>
57 <TableCell>Scopes</TableCell>
58 <TableCell>User ID</TableCell>
63 {apiClientAuthorizations.map((apiClientAuthorizatio, index) =>
64 <TableRow key={index} className={classes.tableRow}>
65 <TableCell>{apiClientAuthorizatio.uuid}</TableCell>
66 <TableCell>{apiClientAuthorizatio.apiClientId}</TableCell>
67 <TableCell>{apiClientAuthorizatio.apiToken}</TableCell>
68 <TableCell>{apiClientAuthorizatio.createdByIpAddress || '(none)'}</TableCell>
69 <TableCell>{apiClientAuthorizatio.defaultOwnerUuid || '(none)'}</TableCell>
70 <TableCell>{apiClientAuthorizatio.expiresAt || '(none)'}</TableCell>
71 <TableCell>{apiClientAuthorizatio.lastUsedAt || '(none)'}</TableCell>
72 <TableCell>{apiClientAuthorizatio.lastUsedByIpAddress || '(none)'}</TableCell>
73 <TableCell>{JSON.stringify(apiClientAuthorizatio.scopes)}</TableCell>
74 <TableCell>{apiClientAuthorizatio.userId}</TableCell>
76 <Tooltip title="More options" disableFocusListener>
77 <IconButton onClick={event => openRowOptions(event, apiClientAuthorizatio)}>