fixed conflicts + link to ssh-keys panel
authorPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Wed, 21 Nov 2018 11:37:51 +0000 (12:37 +0100)
committerPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Wed, 21 Nov 2018 11:37:51 +0000 (12:37 +0100)
Feature #13865

Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>

20 files changed:
src/models/ssh-key.ts [new file with mode: 0644]
src/routes/route-change-handlers.ts
src/routes/routes.ts
src/services/authorized-keys-service/authorized-keys-service.ts [new file with mode: 0644]
src/services/services.ts
src/store/auth/auth-action.ts
src/store/auth/auth-reducer.ts
src/store/navigation/navigation-action.ts
src/store/run-process-panel/run-process-panel-actions.ts
src/store/workbench/workbench-actions.ts
src/validators/is-rsa-key.tsx [new file with mode: 0644]
src/validators/validators.tsx
src/views-components/dialog-create/dialog-ssh-key-create.tsx [new file with mode: 0644]
src/views-components/dialog-forms/create-ssh-key-dialog.ts [new file with mode: 0644]
src/views-components/form-fields/ssh-key-form-fields.tsx [new file with mode: 0644]
src/views-components/main-app-bar/account-menu.tsx
src/views/repositories-panel/repositories-panel.tsx
src/views/ssh-key-panel/ssh-key-panel-root.tsx [new file with mode: 0644]
src/views/ssh-key-panel/ssh-key-panel.tsx [new file with mode: 0644]
src/views/workbench/workbench.tsx

diff --git a/src/models/ssh-key.ts b/src/models/ssh-key.ts
new file mode 100644 (file)
index 0000000..8ccbd92
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Resource } from '~/models/resource';
+
+export enum KeyType {
+    SSH = 'SSH'
+}
+
+export interface SshKeyResource extends Resource {
+    name: string;
+    keyType: KeyType;
+    authorizedUserUuid: string;
+    publicKey: string;
+    expiresAt: string;
+}
\ No newline at end of file
index a4a53d7022300540721a961339888a7e786c87ee..c7f3555bcf79db6f64448b330cb4132392a913cb 100644 (file)
@@ -4,8 +4,8 @@
 
 import { History, Location } from 'history';
 import { RootStore } from '~/store/store';
-import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute, matchSearchResultsRoute, matchRepositoriesRoute } from './routes';
-import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog, loadRepositories } from '~/store/workbench/workbench-actions';
+import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute, matchSearchResultsRoute, matchSshKeysRoute, matchRepositoriesRoute } from './routes';
+import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog, loadSshKeys, loadRepositories } from '~/store/workbench/workbench-actions';
 import { navigateToRootProject } from '~/store/navigation/navigation-action';
 import { loadSharedWithMe, loadRunProcess, loadWorkflow, loadSearchResults } from '~//store/workbench/workbench-actions';
 
@@ -28,6 +28,7 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
     const sharedWithMeMatch = matchSharedWithMeRoute(pathname);
     const runProcessMatch = matchRunProcessRoute(pathname);
     const workflowMatch = matchWorkflowRoute(pathname);
+    const sshKeysMatch = matchSshKeysRoute(pathname);
 
     if (projectMatch) {
         store.dispatch(loadProject(projectMatch.params.id));
@@ -53,5 +54,7 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
         store.dispatch(loadSearchResults);
     } else if(repositoryMatch) {
         store.dispatch(loadRepositories);
+    } else if (sshKeysMatch) {
+        store.dispatch(loadSshKeys);
     }
 };
index 5dbecb45245f566d83e1fbb63cb45c43edeca3df..c9c2ae20e1eff73e55ae7d76b6e52aa3c2658f00 100644 (file)
@@ -20,7 +20,8 @@ export const Routes = {
     SHARED_WITH_ME: '/shared-with-me',
     RUN_PROCESS: '/run-process',
     WORKFLOWS: '/workflows',
-    SEARCH_RESULTS: '/search-results'
+    SEARCH_RESULTS: '/search-results',
+    SSH_KEYS: `/ssh-keys`
 };
 
 export const getResourceUrl = (uuid: string) => {
@@ -79,4 +80,7 @@ export const matchSearchResultsRoute = (route: string) =>
     matchPath<ResourceRouteParams>(route, { path: Routes.SEARCH_RESULTS });
 
 export const matchRepositoriesRoute = (route: string) =>
-    matchPath<ResourceRouteParams>(route, { path: Routes.REPOSITORIES });
\ No newline at end of file
+    matchPath<ResourceRouteParams>(route, { path: Routes.REPOSITORIES });
+    
+export const matchSshKeysRoute = (route: string) =>
+    matchPath(route, { path: Routes.SSH_KEYS });
diff --git a/src/services/authorized-keys-service/authorized-keys-service.ts b/src/services/authorized-keys-service/authorized-keys-service.ts
new file mode 100644 (file)
index 0000000..c952f42
--- /dev/null
@@ -0,0 +1,34 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { AxiosInstance } from "axios";
+import { SshKeyResource } from '~/models/ssh-key';
+import { CommonResourceService, CommonResourceServiceError } from '~/services/common-service/common-resource-service';
+import { ApiActions } from "~/services/api/api-actions";
+
+export enum AuthorizedKeysServiceError {
+    UNIQUE_PUBLIC_KEY = 'UniquePublicKey',
+    INVALID_PUBLIC_KEY = 'InvalidPublicKey',
+}
+
+export class AuthorizedKeysService extends CommonResourceService<SshKeyResource> {
+    constructor(serverApi: AxiosInstance, actions: ApiActions) {
+        super(serverApi, "authorized_keys", actions);
+    }
+}
+
+export const getAuthorizedKeysServiceError = (errorResponse: any) => {
+    if ('errors' in errorResponse && 'errorToken' in errorResponse) {
+        const error = errorResponse.errors.join('');
+        switch (true) {
+            case /Public key does not appear to be a valid ssh-rsa or dsa public key/.test(error):
+                return AuthorizedKeysServiceError.INVALID_PUBLIC_KEY;
+            case /Public key already exists in the database, use a different key./.test(error):
+                return AuthorizedKeysServiceError.UNIQUE_PUBLIC_KEY;
+            default:
+                return CommonResourceServiceError.UNKNOWN;
+        }
+    }
+    return CommonResourceServiceError.NONE;
+};
\ No newline at end of file
index 2bc955f24c71ca8599f15127ae3a5b94d97662b7..308505c5abdbf1ef625b1ff49e038096dad829d5 100644 (file)
@@ -25,6 +25,7 @@ import { WorkflowService } from "~/services/workflow-service/workflow-service";
 import { SearchService } from '~/services/search-service/search-service';
 import { PermissionService } from "~/services/permission-service/permission-service";
 import { RepositoriesService } from '~/services/repositories-service/repositories-service';
+import { AuthorizedKeysService } from '~/services/authorized-keys-service/authorized-keys-service';
 
 export type ServiceRepository = ReturnType<typeof createServices>;
 
@@ -35,6 +36,7 @@ export const createServices = (config: Config, actions: ApiActions) => {
     const webdavClient = new WebDAV();
     webdavClient.defaults.baseURL = config.keepWebServiceUrl;
 
+    const authorizedKeysService = new AuthorizedKeysService(apiClient, actions);
     const containerRequestService = new ContainerRequestService(apiClient, actions);
     const containerService = new ContainerService(apiClient, actions);
     const groupsService = new GroupsService(apiClient, actions);
@@ -59,6 +61,7 @@ export const createServices = (config: Config, actions: ApiActions) => {
         ancestorsService,
         apiClient,
         authService,
+        authorizedKeysService,
         collectionFilesService,
         collectionService,
         containerRequestService,
index ac2e0b7e2f68c6e699e294710d582582701b5fc2..3658c589b6a4814f8dddc359494e744c1b0cf77c 100644 (file)
@@ -4,10 +4,16 @@
 
 import { ofType, unionize, UnionOf } from '~/common/unionize';
 import { Dispatch } from "redux";
-import { User } from "~/models/user";
+import { reset, stopSubmit } from 'redux-form';
+import { AxiosInstance } from "axios";
 import { RootState } from "../store";
+import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+import { dialogActions } from '~/store/dialog/dialog-actions';
+import { setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
 import { ServiceRepository } from "~/services/services";
-import { AxiosInstance } from "axios";
+import { getAuthorizedKeysServiceError, AuthorizedKeysServiceError } from '~/services/authorized-keys-service/authorized-keys-service';
+import { KeyType, SshKeyResource } from '~/models/ssh-key';
+import { User } from "~/models/user";
 
 export const authActions = unionize({
     SAVE_API_TOKEN: ofType<string>(),
@@ -15,9 +21,18 @@ export const authActions = unionize({
     LOGOUT: {},
     INIT: ofType<{ user: User, token: string }>(),
     USER_DETAILS_REQUEST: {},
-    USER_DETAILS_SUCCESS: ofType<User>()
+    USER_DETAILS_SUCCESS: ofType<User>(),
+    SET_SSH_KEYS: ofType<SshKeyResource[]>(),
+    ADD_SSH_KEY: ofType<SshKeyResource>()
 });
 
+export const SSH_KEY_CREATE_FORM_NAME = 'sshKeyCreateFormName';
+
+export interface SshKeyCreateFormDialogData {
+    publicKey: string;
+    name: string;
+}
+
 function setAuthorizationHeader(services: ServiceRepository, token: string) {
     services.apiClient.defaults.headers.common = {
         Authorization: `OAuth2 ${token}`
@@ -70,4 +85,46 @@ export const getUserDetails = () => (dispatch: Dispatch, getState: () => RootSta
     });
 };
 
+export const openSshKeyCreateDialog = () => dialogActions.OPEN_DIALOG({ id: SSH_KEY_CREATE_FORM_NAME, data: {} });
+
+export const createSshKey = (data: SshKeyCreateFormDialogData) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        try {
+            const userUuid = getState().auth.user!.uuid;
+            const { name, publicKey } = data;
+            const newSshKey = await services.authorizedKeysService.create({
+                name, 
+                publicKey,
+                keyType: KeyType.SSH,
+                authorizedUserUuid: userUuid
+            });
+            dispatch(dialogActions.CLOSE_DIALOG({ id: SSH_KEY_CREATE_FORM_NAME }));
+            dispatch(reset(SSH_KEY_CREATE_FORM_NAME));
+            dispatch(authActions.ADD_SSH_KEY(newSshKey));
+            dispatch(snackbarActions.OPEN_SNACKBAR({
+                message: "Public key has been successfully created.",
+                hideDuration: 2000
+            }));
+        } catch (e) {
+            const error = getAuthorizedKeysServiceError(e);
+            if (error === AuthorizedKeysServiceError.UNIQUE_PUBLIC_KEY) {
+                dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key already exists.' }));
+            } else if (error === AuthorizedKeysServiceError.INVALID_PUBLIC_KEY) {
+                dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key is invalid' }));
+            }
+        }
+    };
+
+export const loadSshKeysPanel = () =>
+    async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        try {
+            dispatch(setBreadcrumbs([{ label: 'SSH Keys'}]));
+            const response = await services.authorizedKeysService.list();
+            dispatch(authActions.SET_SSH_KEYS(response.items));
+        } catch (e) {
+            return;
+        }
+    };
+
+
 export type AuthAction = UnionOf<typeof authActions>;
index a4195322c867316ce201f8d03ea4c28bffd25825..8f234dad35bf8a9d68f508ab47d4a1166eea454e 100644 (file)
@@ -5,13 +5,21 @@
 import { authActions, AuthAction } from "./auth-action";
 import { User } from "~/models/user";
 import { ServiceRepository } from "~/services/services";
+import { SshKeyResource } from '~/models/ssh-key';
 
 export interface AuthState {
     user?: User;
     apiToken?: string;
+    sshKeys?: SshKeyResource[];
 }
 
-export const authReducer = (services: ServiceRepository) => (state: AuthState = {}, action: AuthAction) => {
+const initialState: AuthState = {
+    user: undefined,
+    apiToken: undefined,
+    sshKeys: []
+};
+
+export const authReducer = (services: ServiceRepository) => (state: AuthState = initialState, action: AuthAction) => {
     return authActions.match(action, {
         SAVE_API_TOKEN: (token: string) => {
             return {...state, apiToken: token};
@@ -28,6 +36,12 @@ export const authReducer = (services: ServiceRepository) => (state: AuthState =
         USER_DETAILS_SUCCESS: (user: User) => {
             return {...state, user};
         },
+        SET_SSH_KEYS: (sshKeys: SshKeyResource[]) => {
+            return {...state, sshKeys};
+        },
+        ADD_SSH_KEY: (sshKey: SshKeyResource) => {
+            return { ...state, sshKeys: state.sshKeys!.concat(sshKey) };
+        },
         default: () => state
     });
 };
index ce5996997d02a0d22036f15466c9d69a69b57c75..fc08f3ac495403949d4aa2fc6f32a82e18db3bba 100644 (file)
@@ -63,3 +63,5 @@ export const navigateToRunProcess = push(Routes.RUN_PROCESS);
 export const navigateToSearchResults = push(Routes.SEARCH_RESULTS);
 
 export const navigateToRepositories = push(Routes.REPOSITORIES);
+
+export const navigateToSshKeys= push(Routes.SSH_KEYS);
index 314b76214c8501141aa9ca9ab592555dc7fe1e6b..a21f7c04bf90b9b55462dc57e7eb2c0e31a48e1a 100644 (file)
@@ -57,7 +57,7 @@ export const openSetWorkflowDialog = (workflow: WorkflowResource) =>
             dispatch(dialogActions.OPEN_DIALOG({
                 id: SET_WORKFLOW_DIALOG,
                 data: {
-                    title: 'Data loss warning',
+                    title: 'Form will be cleared',
                     text: 'Changing a workflow will clean all input fields in next step.',
                     confirmButtonLabel: 'Change Workflow',
                     workflow
index c6440fd9593b66dc8cce94d9128d9e2587044eaf..5e33661cfff12f9c0442de7f09011f3381e7a1a0 100644 (file)
@@ -39,6 +39,7 @@ import { sharedWithMePanelActions } from '~/store/shared-with-me-panel/shared-wi
 import { loadSharedWithMePanel } from '~/store/shared-with-me-panel/shared-with-me-panel-actions';
 import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
 import { loadWorkflowPanel, workflowPanelActions } from '~/store/workflow-panel/workflow-panel-actions';
+import { loadSshKeysPanel } from '~/store/auth/auth-action';
 import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view';
 import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
 import { getProgressIndicator } from '~/store/progress-indicator/progress-indicator-reducer';
@@ -397,6 +398,11 @@ export const loadRepositories = handleFirstTimeLoad(
         dispatch(setBreadcrumbs([{ label: 'Repositories' }]));
     });
 
+export const loadSshKeys = handleFirstTimeLoad(
+    async (dispatch: Dispatch<any>) => {
+        await dispatch(loadSshKeysPanel());
+    });
+
 const finishLoadingProject = (project: GroupContentsResource | string) =>
     async (dispatch: Dispatch<any>) => {
         const uuid = typeof project === 'string' ? project : project.uuid;
diff --git a/src/validators/is-rsa-key.tsx b/src/validators/is-rsa-key.tsx
new file mode 100644 (file)
index 0000000..7620a80
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+
+const ERROR_MESSAGE = 'Public key is invalid';
+
+export const isRsaKey = (value: any) => {
+    return value.match(/ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3} ([^@]+@[^@]+)/i) ? undefined : ERROR_MESSAGE;
+};
index 37c1bd37458dc50cd293d4f9c9bf85ad2cb7311f..c601df17416d8711be048d51144684703fa4fe8c 100644 (file)
@@ -4,6 +4,7 @@
 
 import { require } from './require';
 import { maxLength } from './max-length';
+import { isRsaKey } from './is-rsa-key';
 
 export const TAG_KEY_VALIDATION = [require, maxLength(255)];
 export const TAG_VALUE_VALIDATION = [require, maxLength(255)];
@@ -21,4 +22,7 @@ export const MOVE_TO_VALIDATION = [require];
 
 export const PROCESS_NAME_VALIDATION = [require, maxLength(255)];
 
-export const REPOSITORY_NAME_VALIDATION = [require, maxLength(255)];
\ No newline at end of file
+export const REPOSITORY_NAME_VALIDATION = [require, maxLength(255)];
+
+export const SSH_KEY_PUBLIC_VALIDATION = [require, isRsaKey, maxLength(1024)];
+export const SSH_KEY_NAME_VALIDATION = [require, maxLength(255)];
diff --git a/src/views-components/dialog-create/dialog-ssh-key-create.tsx b/src/views-components/dialog-create/dialog-ssh-key-create.tsx
new file mode 100644 (file)
index 0000000..b7c9b1f
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { InjectedFormProps } from 'redux-form';
+import { WithDialogProps } from '~/store/dialog/with-dialog';
+import { FormDialog } from '~/components/form-dialog/form-dialog';
+import { SshKeyPublicField, SshKeyNameField } from '~/views-components/form-fields/ssh-key-form-fields';
+import { SshKeyCreateFormDialogData } from '~/store/auth/auth-action';
+
+type DialogSshKeyProps = WithDialogProps<{}> & InjectedFormProps<SshKeyCreateFormDialogData>;
+
+export const DialogSshKeyCreate = (props: DialogSshKeyProps) =>
+    <FormDialog
+        dialogTitle='Add new SSH key'
+        formFields={SshKeyAddFields}
+        submitLabel='Add new ssh key'
+        {...props}
+    />;
+
+const SshKeyAddFields = () => <span>
+    <SshKeyPublicField />
+    <SshKeyNameField />
+</span>;
diff --git a/src/views-components/dialog-forms/create-ssh-key-dialog.ts b/src/views-components/dialog-forms/create-ssh-key-dialog.ts
new file mode 100644 (file)
index 0000000..e965243
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { compose } from "redux";
+import { reduxForm } from 'redux-form';
+import { withDialog } from "~/store/dialog/with-dialog";
+import { SSH_KEY_CREATE_FORM_NAME, createSshKey, SshKeyCreateFormDialogData } from '~/store/auth/auth-action';
+import { DialogSshKeyCreate } from '~/views-components/dialog-create/dialog-ssh-key-create';
+
+export const CreateSshKeyDialog = compose(
+    withDialog(SSH_KEY_CREATE_FORM_NAME),
+    reduxForm<SshKeyCreateFormDialogData>({
+        form: SSH_KEY_CREATE_FORM_NAME,
+        onSubmit: (data, dispatch) => {
+            dispatch(createSshKey(data));
+        }
+    })
+)(DialogSshKeyCreate);
\ No newline at end of file
diff --git a/src/views-components/form-fields/ssh-key-form-fields.tsx b/src/views-components/form-fields/ssh-key-form-fields.tsx
new file mode 100644 (file)
index 0000000..8724e08
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { Field } from "redux-form";
+import { TextField } from "~/components/text-field/text-field";
+import { SSH_KEY_PUBLIC_VALIDATION, SSH_KEY_NAME_VALIDATION } from "~/validators/validators";
+
+export const SshKeyPublicField = () =>
+    <Field
+        name='publicKey'
+        component={TextField}
+        validate={SSH_KEY_PUBLIC_VALIDATION}
+        autoFocus={true}
+        label="Public Key" />;
+
+export const SshKeyNameField = () =>
+    <Field
+        name='name'
+        component={TextField}
+        validate={SSH_KEY_NAME_VALIDATION}
+        label="Name" />;
+
+
index c643fef2583db913c8b2584ce58a9dacb923a8ff..f00c678e15c573abe0572c6e729bafd887edff3d 100644 (file)
@@ -8,10 +8,11 @@ import { User, getUserFullname } from "~/models/user";
 import { DropdownMenu } from "~/components/dropdown-menu/dropdown-menu";
 import { UserPanelIcon } from "~/components/icon/icon";
 import { DispatchProp, connect } from 'react-redux';
-import { logout } from "~/store/auth/auth-action";
+import { logout } from '~/store/auth/auth-action';
 import { RootState } from "~/store/store";
 import { openCurrentTokenDialog } from '~/store/current-token-dialog/current-token-dialog-actions';
 import { openRepositoriesPanel } from "~/store/repositories/repositories-actions";
+import { navigateToSshKeys } from '~/store/navigation/navigation-action';
 
 interface AccountMenuProps {
     user?: User;
@@ -33,6 +34,7 @@ export const AccountMenu = connect(mapStateToProps)(
                 </MenuItem>
                 <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>
                 <MenuItem onClick={() => dispatch(openCurrentTokenDialog)}>Current token</MenuItem>
+                <MenuItem onClick={() => dispatch(navigateToSshKeys)}>Ssh Keys</MenuItem>
                 <MenuItem>My account</MenuItem>
                 <MenuItem onClick={() => dispatch(logout())}>Logout</MenuItem>
             </DropdownMenu>
index 262f3cc346934922d977198847f45f30f26805e2..cfe59f0d26d772c0ddf9f227e2b5a6cc60d8ea2d 100644 (file)
@@ -14,6 +14,7 @@ import { HelpIcon, AddIcon, MoreOptionsIcon } from '~/components/icon/icon';
 import { loadRepositoriesData, openRepositoriesSampleGitDialog, openRepositoryCreateDialog } from '~/store/repositories/repositories-actions';
 import { RepositoryResource } from '~/models/repositories';
 import { openRepositoryContextMenu } from '~/store/context-menu/context-menu-actions';
+import { Routes } from '~/routes/routes';
 
 
 type CssRules = 'link' | 'button' | 'icon' | 'iconRow' | 'moreOptionsButton' | 'moreOptions' | 'cloneUrls';
@@ -102,7 +103,7 @@ export const RepositoriesPanel = compose(
                                 <Grid item xs={8}>
                                     <Typography variant="body2">
                                         When you are using an Arvados virtual machine, you should clone the https:// URLs. This will authenticate automatically using your API token. <br />
-                                        In order to clone git repositories using SSH, <Link to='' className={classes.link}>add an SSH key to your account</Link> and clone the git@ URLs.
+                                        In order to clone git repositories using SSH, <Link to={Routes.SSH_KEYS} className={classes.link}>add an SSH key to your account</Link> and clone the git@ URLs.
                                     </Typography>
                                 </Grid>
                                 <Grid item xs={4} className={classes.button}>
diff --git a/src/views/ssh-key-panel/ssh-key-panel-root.tsx b/src/views/ssh-key-panel/ssh-key-panel-root.tsx
new file mode 100644 (file)
index 0000000..f752228
--- /dev/null
@@ -0,0 +1,55 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { StyleRulesCallback, WithStyles, withStyles, Card, CardContent, Button, Typography } from '@material-ui/core';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { SshKeyResource } from '~/models/ssh-key';
+
+
+type CssRules = 'root' | 'link';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+    root: {
+       width: '100%'
+    },
+    link: {
+        color: theme.palette.primary.main,
+        textDecoration: 'none',
+        margin: '0px 4px'
+    }
+});
+
+export interface SshKeyPanelRootActionProps {
+    onClick: () => void;
+}
+
+export interface SshKeyPanelRootDataProps {
+    sshKeys?: SshKeyResource[];
+}
+
+type SshKeyPanelRootProps = SshKeyPanelRootDataProps & SshKeyPanelRootActionProps & WithStyles<CssRules>;
+
+export const SshKeyPanelRoot = withStyles(styles)(
+    ({ classes, sshKeys, onClick }: SshKeyPanelRootProps) =>
+        <Card className={classes.root}>
+            <CardContent>
+                <Typography variant='body1' paragraph={true}>
+                    You have not yet set up an SSH public key for use with Arvados.
+                    <a href='https://doc.arvados.org/user/getting_started/ssh-access-unix.html' target='blank' className={classes.link}>
+                        Learn more.
+                    </a>
+                </Typography>
+                <Typography variant='body1' paragraph={true}>
+                    When you have an SSH key you would like to use, add it using button below.
+                </Typography>
+                <Button
+                    onClick={onClick}
+                    color="primary"
+                    variant="contained">
+                    Add New Ssh Key
+                </Button>
+            </CardContent>
+        </Card>
+    );
\ No newline at end of file
diff --git a/src/views/ssh-key-panel/ssh-key-panel.tsx b/src/views/ssh-key-panel/ssh-key-panel.tsx
new file mode 100644 (file)
index 0000000..f600677
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { RootState } from '~/store/store';
+import { Dispatch } from 'redux';
+import { connect } from 'react-redux';
+import { SshKeyPanelRoot, SshKeyPanelRootDataProps, SshKeyPanelRootActionProps } from '~/views/ssh-key-panel/ssh-key-panel-root';
+import { openSshKeyCreateDialog } from '~/store/auth/auth-action';
+
+const mapStateToProps = (state: RootState): SshKeyPanelRootDataProps => {
+    return {
+        sshKeys: state.auth.sshKeys
+    };
+};
+
+const mapDispatchToProps = (dispatch: Dispatch): SshKeyPanelRootActionProps => ({
+    onClick: () => {
+        dispatch(openSshKeyCreateDialog());
+    }
+});
+
+export const SshKeyPanel = connect(mapStateToProps, mapDispatchToProps)(SshKeyPanelRoot);
\ No newline at end of file
index eee9911c163006d78a0ad200a4095ec252c328a9..ebdf57c3a7a9ac9f2adbb9a944fd3a472db7fc08 100644 (file)
@@ -44,6 +44,7 @@ import { RunProcessPanel } from '~/views/run-process-panel/run-process-panel';
 import SplitterLayout from 'react-splitter-layout';
 import { WorkflowPanel } from '~/views/workflow-panel/workflow-panel';
 import { SearchResultsPanel } from '~/views/search-results-panel/search-results-panel';
+import { SshKeyPanel } from '~/views/ssh-key-panel/ssh-key-panel';
 import { SharingDialog } from '~/views-components/sharing-dialog/sharing-dialog';
 import { AdvancedTabDialog } from '~/views-components/advanced-tab-dialog/advanced-tab-dialog';
 import { ProcessInputDialog } from '~/views-components/process-input-dialog/process-input-dialog';
@@ -53,6 +54,7 @@ import { RepositoriesSampleGitDialog } from '~/views-components/repositories-sam
 import { RepositoryAttributesDialog } from '~/views-components/repository-attributes-dialog/repository-attributes-dialog';
 import { CreateRepositoryDialog } from '~/views-components/dialog-forms/create-repository-dialog';
 import { RemoveRepositoryDialog } from '~/views-components/repository-remove-dialog/repository-remove-dialog';
+import { CreateSshKeyDialog } from '~/views-components/dialog-forms/create-ssh-key-dialog';
 
 type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
 
@@ -123,6 +125,7 @@ export const WorkbenchPanel =
                                 <Route path={Routes.WORKFLOWS} component={WorkflowPanel} />
                                 <Route path={Routes.SEARCH_RESULTS} component={SearchResultsPanel} />
                                 <Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
+                                <Route path={Routes.SSH_KEYS} component={SshKeyPanel} />
                             </Switch>
                         </Grid>
                     </Grid>
@@ -139,6 +142,7 @@ export const WorkbenchPanel =
             <CreateCollectionDialog />
             <CreateProjectDialog />
             <CreateRepositoryDialog />
+            <CreateSshKeyDialog />
             <CurrentTokenDialog />
             <FileRemoveDialog />
             <FilesUploadCollectionDialog />