[ARVADOS-WORKBENCH2] updated: 1.3.0-45-g4e1ff9a
Git user
git at public.curoverse.com
Thu Dec 6 11:35:56 EST 2018
Summary of changes:
.../api-client-authorizations-actions.ts | 10 ++++
.../attributes-dialog.tsx | 23 ++++++++
.../help-dialog.tsx | 66 ++++++++++++++++++++++
.../main-content-bar/main-content-bar.tsx | 3 +-
.../api-client-authorization-panel-root.tsx | 27 +++++++--
.../api-client-authorization-panel.tsx | 4 ++
src/views/workbench/workbench.tsx | 2 +
7 files changed, 128 insertions(+), 7 deletions(-)
create mode 100644 src/views-components/api-client-authorizations-dialog/help-dialog.tsx
via 4e1ff9a1613f897f24bc59a981e94d8bf227fd10 (commit)
from d19d853e83383a6b75f638be99472aa626a05524 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 4e1ff9a1613f897f24bc59a981e94d8bf227fd10
Author: Janicki Artur <artur.janicki at contractors.roche.com>
Date: Thu Dec 6 17:35:48 2018 +0100
add help dialog, change attrs dialog and store
Feature #14500_admin_api_tokens
Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>
diff --git a/src/store/api-client-authorizations/api-client-authorizations-actions.ts b/src/store/api-client-authorizations/api-client-authorizations-actions.ts
index 5f52aa2..8ed8a38 100644
--- a/src/store/api-client-authorizations/api-client-authorizations-actions.ts
+++ b/src/store/api-client-authorizations/api-client-authorizations-actions.ts
@@ -21,6 +21,7 @@ export type ApiClientAuthorizationsActions = UnionOf<typeof apiClientAuthorizati
export const API_CLIENT_AUTHORIZATION_REMOVE_DIALOG = 'apiClientAuthorizationRemoveDialog';
export const API_CLIENT_AUTHORIZATION_ATTRIBUTES_DIALOG = 'apiClientAuthorizationAttributesDialog';
+export const API_CLIENT_AUTHORIZATION_HELP_DIALOG = 'apiClientAuthorizationHelpDialog';
export const loadApiClientAuthorizationsPanel = () =>
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
@@ -69,4 +70,13 @@ export const removeApiClientAuthorization = (uuid: string) =>
} catch (e) {
return;
}
+ };
+
+export const openApiClientAuthorizationsHelpDialog = () =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+ const apiHost = getState().properties.apiHost;
+ const user = getState().auth.user;
+ const email = user ? user.email : '';
+ const apiToken = getState().auth.apiToken;
+ dispatch(dialogActions.OPEN_DIALOG({ id: API_CLIENT_AUTHORIZATION_HELP_DIALOG, data: { apiHost, apiToken, email } }));
};
\ No newline at end of file
diff --git a/src/views-components/api-client-authorizations-dialog/attributes-dialog.tsx b/src/views-components/api-client-authorizations-dialog/attributes-dialog.tsx
index 662c880..e7defd6 100644
--- a/src/views-components/api-client-authorizations-dialog/attributes-dialog.tsx
+++ b/src/views-components/api-client-authorizations-dialog/attributes-dialog.tsx
@@ -12,6 +12,7 @@ import { WithDialogProps, withDialog } from "~/store/dialog/with-dialog";
import { API_CLIENT_AUTHORIZATION_ATTRIBUTES_DIALOG } from '~/store/api-client-authorizations/api-client-authorizations-actions';
import { ArvadosTheme } from '~/common/custom-theme';
import { ApiClientAuthorization } from '~/models/api-client-authorization';
+import { formatDate } from '~/common/formatters';
type CssRules = 'root';
@@ -41,6 +42,28 @@ export const AttributesApiClientAuthorizationDialog = compose(
<Grid item xs={7}>{data.apiClientAuthorization.uuid}</Grid>
<Grid item xs={5}>Owner uuid</Grid>
<Grid item xs={7}>{data.apiClientAuthorization.ownerUuid}</Grid>
+ <Grid item xs={5}>API Client ID</Grid>
+ <Grid item xs={7}>{data.apiClientAuthorization.apiClientId}</Grid>
+ <Grid item xs={5}>API Token</Grid>
+ <Grid item xs={7}>{data.apiClientAuthorization.apiToken}</Grid>
+ <Grid item xs={5}>Created by IP address</Grid>
+ <Grid item xs={7}>{data.apiClientAuthorization.createdByIpAddress || '(none)'}</Grid>
+ <Grid item xs={5}>Default owner</Grid>
+ <Grid item xs={7}>{data.apiClientAuthorization.defaultOwnerUuid || '(none)'}</Grid>
+ <Grid item xs={5}>Expires at</Grid>
+ <Grid item xs={7}>{formatDate(data.apiClientAuthorization.expiresAt) || '(none)'}</Grid>
+ <Grid item xs={5}>Last used at</Grid>
+ <Grid item xs={7}>{formatDate(data.apiClientAuthorization.lastUsedAt) || '(none)'}</Grid>
+ <Grid item xs={5}>Last used by IP address</Grid>
+ <Grid item xs={7}>{data.apiClientAuthorization.lastUsedByIpAddress || '(none)'}</Grid>
+ <Grid item xs={5}>Scopes</Grid>
+ <Grid item xs={7}>{JSON.stringify(data.apiClientAuthorization.scopes || '(none)')}</Grid>
+ <Grid item xs={5}>User ID</Grid>
+ <Grid item xs={7}>{data.apiClientAuthorization.userId || '(none)'}</Grid>
+ <Grid item xs={5}>Created at</Grid>
+ <Grid item xs={7}>{formatDate(data.apiClientAuthorization.createdAt) || '(none)'}</Grid>
+ <Grid item xs={5}>Updated at</Grid>
+ <Grid item xs={7}>{formatDate(data.apiClientAuthorization.updatedAt) || '(none)'}</Grid>
</Grid>}
</DialogContent>
<DialogActions>
diff --git a/src/views-components/api-client-authorizations-dialog/help-dialog.tsx b/src/views-components/api-client-authorizations-dialog/help-dialog.tsx
new file mode 100644
index 0000000..d2802fa
--- /dev/null
+++ b/src/views-components/api-client-authorizations-dialog/help-dialog.tsx
@@ -0,0 +1,66 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Typography } from "@material-ui/core";
+import { WithDialogProps } from "~/store/dialog/with-dialog";
+import { withDialog } from '~/store/dialog/with-dialog';
+import { DefaultCodeSnippet } from '~/components/default-code-snippet/default-code-snippet';
+import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { compose } from "redux";
+import { API_CLIENT_AUTHORIZATION_HELP_DIALOG } from '~/store/api-client-authorizations/api-client-authorizations-actions';
+
+type CssRules = 'codeSnippet';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ codeSnippet: {
+ borderRadius: theme.spacing.unit * 0.5,
+ border: `1px solid ${theme.palette.grey["400"]}`,
+ '& pre': {
+ fontSize: '0.815rem'
+ }
+ }
+});
+
+interface HelpApiClientAuthorizationDataProps {
+ apiHost: string;
+ apiToken: string;
+ email: string;
+}
+
+export const HelpApiClientAuthorizationDialog = compose(
+ withDialog(API_CLIENT_AUTHORIZATION_HELP_DIALOG),
+ withStyles(styles))(
+ (props: WithDialogProps<HelpApiClientAuthorizationDataProps> & WithStyles<CssRules>) =>
+ <Dialog open={props.open}
+ onClose={props.closeDialog}
+ fullWidth
+ maxWidth='md'>
+ <DialogTitle>HELP:</DialogTitle>
+ <DialogContent>
+ <DefaultCodeSnippet
+ className={props.classes.codeSnippet}
+ lines={[snippetText(props.data)]} />
+ {/* // lines={snippetText2(props.data)} /> */}
+ </DialogContent>
+ <DialogActions>
+ <Button
+ variant='flat'
+ color='primary'
+ onClick={props.closeDialog}>
+ Close
+ </Button>
+ </DialogActions>
+ </Dialog>
+ );
+
+const snippetText = (data: HelpApiClientAuthorizationDataProps) => `### Pasting the following lines at a shell prompt will allow Arvados SDKs
+### to authenticate to your account, ${data.email}
+
+read ARVADOS_API_TOKEN <<EOF
+${data.apiToken}
+EOF
+export ARVADOS_API_TOKEN ARVADOS_API_HOST=${data.apiHost}
+unset ARVADOS_API_HOST_INSECURE`;
diff --git a/src/views-components/main-content-bar/main-content-bar.tsx b/src/views-components/main-content-bar/main-content-bar.tsx
index 78b79a8..a3279e3 100644
--- a/src/views-components/main-content-bar/main-content-bar.tsx
+++ b/src/views-components/main-content-bar/main-content-bar.tsx
@@ -20,7 +20,8 @@ const isButtonVisible = ({ router }: RootState) => {
const pathname = router.location ? router.location.pathname : '';
return !Routes.matchWorkflowRoute(pathname) && !Routes.matchVirtualMachineRoute(pathname) &&
!Routes.matchRepositoriesRoute(pathname) && !Routes.matchSshKeysRoute(pathname) &&
- !Routes.matchKeepServicesRoute(pathname) && !Routes.matchComputeNodesRoute(pathname);
+ !Routes.matchKeepServicesRoute(pathname) && !Routes.matchComputeNodesRoute(pathname) &&
+ !Routes.matchApiClientAuthorizationsRoute(pathname);
};
export const MainContentBar = connect((state: RootState) => ({
diff --git a/src/views/api-client-authorization-panel/api-client-authorization-panel-root.tsx b/src/views/api-client-authorization-panel/api-client-authorization-panel-root.tsx
index bd50a59..52921b3 100644
--- a/src/views/api-client-authorization-panel/api-client-authorization-panel-root.tsx
+++ b/src/views/api-client-authorization-panel/api-client-authorization-panel-root.tsx
@@ -8,16 +8,23 @@ import {
Table, TableHead, TableRow, TableCell, TableBody, Tooltip, IconButton
} from '@material-ui/core';
import { ArvadosTheme } from '~/common/custom-theme';
-import { MoreOptionsIcon } from '~/components/icon/icon';
+import { MoreOptionsIcon, HelpIcon } from '~/components/icon/icon';
import { ApiClientAuthorization } from '~/models/api-client-authorization';
+import { formatDate } from '~/common/formatters';
-type CssRules = 'root' | 'tableRow';
+type CssRules = 'root' | 'tableRow' | 'helpIconGrid' | 'tableGrid';
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
root: {
width: '100%',
overflow: 'auto'
},
+ helpIconGrid: {
+ textAlign: 'right'
+ },
+ tableGrid: {
+ marginTop: theme.spacing.unit
+ },
tableRow: {
'& td, th': {
whiteSpace: 'nowrap'
@@ -27,6 +34,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
export interface ApiClientAuthorizationPanelRootActionProps {
openRowOptions: (event: React.MouseEvent<HTMLElement>, keepService: ApiClientAuthorization) => void;
+ openHelpDialog: () => void;
}
export interface ApiClientAuthorizationPanelRootDataProps {
@@ -38,10 +46,17 @@ type ApiClientAuthorizationPanelRootProps = ApiClientAuthorizationPanelRootActio
& ApiClientAuthorizationPanelRootDataProps & WithStyles<CssRules>;
export const ApiClientAuthorizationPanelRoot = withStyles(styles)(
- ({ classes, hasApiClientAuthorizations, apiClientAuthorizations, openRowOptions }: ApiClientAuthorizationPanelRootProps) =>
+ ({ classes, hasApiClientAuthorizations, apiClientAuthorizations, openRowOptions, openHelpDialog }: ApiClientAuthorizationPanelRootProps) =>
<Card className={classes.root}>
<CardContent>
- {hasApiClientAuthorizations && <Grid container direction="row">
+ {hasApiClientAuthorizations && <Grid container direction="row" justify="flex-end">
+ <Grid item xs={12} className={classes.helpIconGrid}>
+ <Tooltip title="Api token - help">
+ <IconButton onClick={openHelpDialog}>
+ <HelpIcon />
+ </IconButton>
+ </Tooltip>
+ </Grid>
<Grid item xs={12}>
<Table>
<TableHead>
@@ -67,8 +82,8 @@ export const ApiClientAuthorizationPanelRoot = withStyles(styles)(
<TableCell>{apiClientAuthorizatio.apiToken}</TableCell>
<TableCell>{apiClientAuthorizatio.createdByIpAddress || '(none)'}</TableCell>
<TableCell>{apiClientAuthorizatio.defaultOwnerUuid || '(none)'}</TableCell>
- <TableCell>{apiClientAuthorizatio.expiresAt || '(none)'}</TableCell>
- <TableCell>{apiClientAuthorizatio.lastUsedAt || '(none)'}</TableCell>
+ <TableCell>{formatDate(apiClientAuthorizatio.expiresAt) || '(none)'}</TableCell>
+ <TableCell>{formatDate(apiClientAuthorizatio.lastUsedAt) || '(none)'}</TableCell>
<TableCell>{apiClientAuthorizatio.lastUsedByIpAddress || '(none)'}</TableCell>
<TableCell>{JSON.stringify(apiClientAuthorizatio.scopes)}</TableCell>
<TableCell>{apiClientAuthorizatio.userId}</TableCell>
diff --git a/src/views/api-client-authorization-panel/api-client-authorization-panel.tsx b/src/views/api-client-authorization-panel/api-client-authorization-panel.tsx
index 06d32bf..75b79ab 100644
--- a/src/views/api-client-authorization-panel/api-client-authorization-panel.tsx
+++ b/src/views/api-client-authorization-panel/api-client-authorization-panel.tsx
@@ -11,6 +11,7 @@ import {
ApiClientAuthorizationPanelRootActionProps
} from '~/views/api-client-authorization-panel/api-client-authorization-panel-root';
import { openApiClientAuthorizationContextMenu } from '~/store/context-menu/context-menu-actions';
+import { openApiClientAuthorizationsHelpDialog } from '~/store/api-client-authorizations/api-client-authorizations-actions';
const mapStateToProps = (state: RootState): ApiClientAuthorizationPanelRootDataProps => {
return {
@@ -22,6 +23,9 @@ const mapStateToProps = (state: RootState): ApiClientAuthorizationPanelRootDataP
const mapDispatchToProps = (dispatch: Dispatch): ApiClientAuthorizationPanelRootActionProps => ({
openRowOptions: (event, apiClientAuthorization) => {
dispatch<any>(openApiClientAuthorizationContextMenu(event, apiClientAuthorization));
+ },
+ openHelpDialog: () => {
+ dispatch<any>(openApiClientAuthorizationsHelpDialog());
}
});
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index 1f2c602..1f5a503 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -70,6 +70,7 @@ import { AttributesComputeNodeDialog } from '~/views-components/compute-nodes-di
import { AttributesKeepServiceDialog } from '~/views-components/keep-services-dialog/attributes-dialog';
import { AttributesSshKeyDialog } from '~/views-components/ssh-keys-dialog/attributes-dialog';
import { VirtualMachineAttributesDialog } from '~/views-components/virtual-machines-dialog/attributes-dialog';
+import { HelpApiClientAuthorizationDialog } from '~/views-components/api-client-authorizations-dialog/help-dialog';
type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
@@ -169,6 +170,7 @@ export const WorkbenchPanel =
<CurrentTokenDialog />
<FileRemoveDialog />
<FilesUploadCollectionDialog />
+ <HelpApiClientAuthorizationDialog />
<MoveCollectionDialog />
<MoveProcessDialog />
<MoveProjectDialog />
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list