21910: Merge branch 'main' into 21910-remove-api_client_id
[arvados.git] / services / workbench2 / src / views-components / api-client-authorizations-dialog / attributes-dialog.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from "react";
6 import { compose } from 'redux';
7 import {
8     withStyles, Dialog, DialogTitle, DialogContent, DialogActions,
9     Button, StyleRulesCallback, WithStyles, Grid
10 } from '@material-ui/core';
11 import { WithDialogProps, withDialog } from "store/dialog/with-dialog";
12 import { API_CLIENT_AUTHORIZATION_ATTRIBUTES_DIALOG } from 'store/api-client-authorizations/api-client-authorizations-actions';
13 import { ArvadosTheme } from 'common/custom-theme';
14 import { ApiClientAuthorization } from 'models/api-client-authorization';
15 import { formatDate } from 'common/formatters';
16
17 type CssRules = 'root';
18
19 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
20     root: {
21         fontSize: '0.875rem',
22         '& div:nth-child(odd)': {
23             textAlign: 'right',
24             color: theme.palette.grey["500"]
25         }
26     }
27 });
28
29 interface AttributesKeepServiceDialogDataProps {
30     apiClientAuthorization: ApiClientAuthorization;
31 }
32
33 export const AttributesApiClientAuthorizationDialog = compose(
34     withDialog(API_CLIENT_AUTHORIZATION_ATTRIBUTES_DIALOG),
35     withStyles(styles))(
36         ({ open, closeDialog, data, classes }: WithDialogProps<AttributesKeepServiceDialogDataProps> & WithStyles<CssRules>) =>
37             <Dialog open={open} onClose={closeDialog} fullWidth maxWidth='sm'>
38                 <DialogTitle>Attributes</DialogTitle>
39                 <DialogContent>
40                     {data.apiClientAuthorization && <Grid container direction="row" spacing={16} className={classes.root}>
41                         <Grid item xs={5}>UUID</Grid>
42                         <Grid item xs={7}>{data.apiClientAuthorization.uuid}</Grid>
43                         <Grid item xs={5}>Owner uuid</Grid>
44                         <Grid item xs={7}>{data.apiClientAuthorization.ownerUuid}</Grid>
45                         <Grid item xs={5}>API Token</Grid>
46                         <Grid item xs={7}>{data.apiClientAuthorization.apiToken}</Grid>
47                         <Grid item xs={5}>Created by IP address</Grid>
48                         <Grid item xs={7}>{data.apiClientAuthorization.createdByIpAddress || '(none)'}</Grid>
49                         <Grid item xs={5}>Expires at</Grid>
50                         <Grid item xs={7}>{formatDate(data.apiClientAuthorization.expiresAt) || '(none)'}</Grid>
51                         <Grid item xs={5}>Last used at</Grid>
52                         <Grid item xs={7}>{formatDate(data.apiClientAuthorization.lastUsedAt) || '(none)'}</Grid>
53                         <Grid item xs={5}>Last used by IP address</Grid>
54                         <Grid item xs={7}>{data.apiClientAuthorization.lastUsedByIpAddress || '(none)'}</Grid>
55                         <Grid item xs={5}>Scopes</Grid>
56                         <Grid item xs={7}>{JSON.stringify(data.apiClientAuthorization.scopes || '(none)')}</Grid>
57                         <Grid item xs={5}>User ID</Grid>
58                         <Grid item xs={7}>{data.apiClientAuthorization.userId || '(none)'}</Grid>
59                         <Grid item xs={5}>Created at</Grid>
60                         <Grid item xs={7}>{formatDate(data.apiClientAuthorization.createdAt) || '(none)'}</Grid>
61                         <Grid item xs={5}>Updated at</Grid>
62                         <Grid item xs={7}>{formatDate(data.apiClientAuthorization.updatedAt) || '(none)'}</Grid>
63                     </Grid>}
64                 </DialogContent>
65                 <DialogActions>
66                     <Button
67                         variant='text'
68                         color='primary'
69                         onClick={closeDialog}>
70                         Close
71                     </Button>
72                 </DialogActions>
73             </Dialog>
74     );