16718: Adds option to search for collection's past versions.
[arvados.git] / 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 * as 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 Client ID</Grid>
46                         <Grid item xs={7}>{data.apiClientAuthorization.apiClientId}</Grid>
47                         <Grid item xs={5}>API Token</Grid>
48                         <Grid item xs={7}>{data.apiClientAuthorization.apiToken}</Grid>
49                         <Grid item xs={5}>Created by IP address</Grid>
50                         <Grid item xs={7}>{data.apiClientAuthorization.createdByIpAddress || '(none)'}</Grid>
51                         <Grid item xs={5}>Default owner</Grid>
52                         <Grid item xs={7}>{data.apiClientAuthorization.defaultOwnerUuid || '(none)'}</Grid>
53                         <Grid item xs={5}>Expires at</Grid>
54                         <Grid item xs={7}>{formatDate(data.apiClientAuthorization.expiresAt) || '(none)'}</Grid>
55                         <Grid item xs={5}>Last used at</Grid>
56                         <Grid item xs={7}>{formatDate(data.apiClientAuthorization.lastUsedAt) || '(none)'}</Grid>
57                         <Grid item xs={5}>Last used by IP address</Grid>
58                         <Grid item xs={7}>{data.apiClientAuthorization.lastUsedByIpAddress || '(none)'}</Grid>
59                         <Grid item xs={5}>Scopes</Grid>
60                         <Grid item xs={7}>{JSON.stringify(data.apiClientAuthorization.scopes || '(none)')}</Grid>
61                         <Grid item xs={5}>User ID</Grid>
62                         <Grid item xs={7}>{data.apiClientAuthorization.userId || '(none)'}</Grid>
63                         <Grid item xs={5}>Created at</Grid>
64                         <Grid item xs={7}>{formatDate(data.apiClientAuthorization.createdAt) || '(none)'}</Grid>
65                         <Grid item xs={5}>Updated at</Grid>
66                         <Grid item xs={7}>{formatDate(data.apiClientAuthorization.updatedAt) || '(none)'}</Grid>
67                     </Grid>}
68                 </DialogContent>
69                 <DialogActions>
70                     <Button
71                         variant='text'
72                         color='primary'
73                         onClick={closeDialog}>
74                         Close
75                     </Button>
76                 </DialogActions>
77             </Dialog>
78     );