From 62ff5a943865229c1630c66366f824511048ce63 Mon Sep 17 00:00:00 2001 From: Janicki Artur Date: Wed, 21 Nov 2018 10:10:52 +0100 Subject: [PATCH] Add ssh keys panel Feature #14479_ssh_keys Arvados-DCO-1.1-Signed-off-by: Janicki Artur --- src/models/ssh-key.ts | 30 ++++++++++ src/routes/route-change-handlers.ts | 7 ++- src/routes/routes.ts | 6 +- .../authorized-keys-service.ts | 14 +++++ .../common-service/common-resource-service.ts | 6 ++ src/services/services.ts | 3 + src/store/auth/auth-action.ts | 54 +++++++++++++++++- src/store/auth/auth-reducer.ts | 16 +++++- src/store/navigation/navigation-action.ts | 2 + src/store/workbench/workbench-actions.ts | 6 ++ src/validators/is-rsa-key.tsx | 10 ++++ src/validators/validators.tsx | 6 +- .../dialog-create/dialog-ssh-key-create.tsx | 25 +++++++++ .../dialog-forms/create-ssh-key-dialog.ts | 20 +++++++ .../form-fields/ssh-key-form-fields.tsx | 25 +++++++++ .../main-app-bar/account-menu.tsx | 4 +- .../ssh-key-panel/ssh-key-panel-root.tsx | 55 +++++++++++++++++++ src/views/ssh-key-panel/ssh-key-panel.tsx | 23 ++++++++ src/views/workbench/workbench.tsx | 4 ++ 19 files changed, 309 insertions(+), 7 deletions(-) create mode 100644 src/models/ssh-key.ts create mode 100644 src/services/authorized-keys-service/authorized-keys-service.ts create mode 100644 src/validators/is-rsa-key.tsx create mode 100644 src/views-components/dialog-create/dialog-ssh-key-create.tsx create mode 100644 src/views-components/dialog-forms/create-ssh-key-dialog.ts create mode 100644 src/views-components/form-fields/ssh-key-form-fields.tsx create mode 100644 src/views/ssh-key-panel/ssh-key-panel-root.tsx create mode 100644 src/views/ssh-key-panel/ssh-key-panel.tsx diff --git a/src/models/ssh-key.ts b/src/models/ssh-key.ts new file mode 100644 index 00000000..76d6ffd9 --- /dev/null +++ b/src/models/ssh-key.ts @@ -0,0 +1,30 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { Resource } from '~/models/resource'; + +export interface SshKey { + name: string; + keyType: KeyType; + authorizedUserUuid: string; + publicKey: string; + expiresAt: string; +} + +export interface SshKeyCreateFormDialogData { + publicKey: string; + name: string; +} + +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 diff --git a/src/routes/route-change-handlers.ts b/src/routes/route-change-handlers.ts index ef9e9ebc..fb6f5e20 100644 --- a/src/routes/route-change-handlers.ts +++ b/src/routes/route-change-handlers.ts @@ -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 } from './routes'; -import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog } from '~/store/workbench/workbench-actions'; +import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute, matchSearchResultsRoute, matchSshKeysRoute } from './routes'; +import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog, loadSshKeys } from '~/store/workbench/workbench-actions'; import { navigateToRootProject } from '~/store/navigation/navigation-action'; import { loadSharedWithMe, loadRunProcess, loadWorkflow, loadSearchResults } from '~//store/workbench/workbench-actions'; @@ -27,6 +27,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)); @@ -50,5 +51,7 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => { store.dispatch(loadWorkflow); } else if (searchResultsMatch) { store.dispatch(loadSearchResults); + } else if (sshKeysMatch) { + store.dispatch(loadSshKeys); } }; diff --git a/src/routes/routes.ts b/src/routes/routes.ts index e5f34935..b00b9fe2 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -19,7 +19,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) => { @@ -76,3 +77,6 @@ export const matchWorkflowRoute = (route: string) => export const matchSearchResultsRoute = (route: string) => matchPath(route, { path: Routes.SEARCH_RESULTS }); + +export const matchSshKeysRoute = (route: string) => + matchPath(route, { path: Routes.SSH_KEYS }); \ No newline at end of file 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 index 00000000..b51704a0 --- /dev/null +++ b/src/services/authorized-keys-service/authorized-keys-service.ts @@ -0,0 +1,14 @@ +// 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 } from "~/services/common-service/common-resource-service"; +import { ApiActions } from "~/services/api/api-actions"; + +export class AuthorizedKeysService extends CommonResourceService { + constructor(serverApi: AxiosInstance, actions: ApiActions) { + super(serverApi, "authorized_keys", actions); + } +} \ No newline at end of file diff --git a/src/services/common-service/common-resource-service.ts b/src/services/common-service/common-resource-service.ts index 70c1df0e..02a3379d 100644 --- a/src/services/common-service/common-resource-service.ts +++ b/src/services/common-service/common-resource-service.ts @@ -35,6 +35,8 @@ export enum CommonResourceServiceError { UNIQUE_VIOLATION = 'UniqueViolation', OWNERSHIP_CYCLE = 'OwnershipCycle', MODIFYING_CONTAINER_REQUEST_FINAL_STATE = 'ModifyingContainerRequestFinalState', + UNIQUE_PUBLIC_KEY = 'UniquePublicKey', + INVALID_PUBLIC_KEY = 'InvalidPublicKey', UNKNOWN = 'Unknown', NONE = 'None' } @@ -150,6 +152,10 @@ export const getCommonResourceServiceError = (errorResponse: any) => { return CommonResourceServiceError.OWNERSHIP_CYCLE; case /Mounts cannot be modified in state 'Final'/.test(error): return CommonResourceServiceError.MODIFYING_CONTAINER_REQUEST_FINAL_STATE; + case /Public key does not appear to be a valid ssh-rsa or dsa public key/.test(error): + return CommonResourceServiceError.INVALID_PUBLIC_KEY; + case /Public key already exists in the database, use a different key./.test(error): + return CommonResourceServiceError.UNIQUE_PUBLIC_KEY; default: return CommonResourceServiceError.UNKNOWN; } diff --git a/src/services/services.ts b/src/services/services.ts index 5adf10b3..aeeb9556 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -24,6 +24,7 @@ import { ApiActions } from "~/services/api/api-actions"; 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 { AuthorizedKeysService } from '~/services/authorized-keys-service/authorized-keys-service'; export type ServiceRepository = ReturnType; @@ -34,6 +35,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); @@ -57,6 +59,7 @@ export const createServices = (config: Config, actions: ApiActions) => { ancestorsService, apiClient, authService, + authorizedKeysService, collectionFilesService, collectionService, containerRequestService, diff --git a/src/store/auth/auth-action.ts b/src/store/auth/auth-action.ts index ac2e0b7e..64ee7196 100644 --- a/src/store/auth/auth-action.ts +++ b/src/store/auth/auth-action.ts @@ -4,10 +4,16 @@ import { ofType, unionize, UnionOf } from '~/common/unionize'; import { Dispatch } from "redux"; +import { reset, stopSubmit } from 'redux-form'; import { User } from "~/models/user"; import { RootState } from "../store"; import { ServiceRepository } from "~/services/services"; +import { getCommonResourceServiceError, CommonResourceServiceError } from '~/services/common-service/common-resource-service'; import { AxiosInstance } from "axios"; +import { snackbarActions } from '~/store/snackbar/snackbar-actions'; +import { dialogActions } from '~/store/dialog/dialog-actions'; +import { SshKeyCreateFormDialogData, SshKey, KeyType } from '~/models/ssh-key'; +import { setBreadcrumbs } from '../breadcrumbs/breadcrumbs-actions'; export const authActions = unionize({ SAVE_API_TOKEN: ofType(), @@ -15,9 +21,13 @@ export const authActions = unionize({ LOGOUT: {}, INIT: ofType<{ user: User, token: string }>(), USER_DETAILS_REQUEST: {}, - USER_DETAILS_SUCCESS: ofType() + USER_DETAILS_SUCCESS: ofType(), + SET_SSH_KEYS: ofType(), + ADD_SSH_KEY: ofType() }); +export const SSH_KEY_CREATE_FORM_NAME = 'sshKeyCreateFormName'; + function setAuthorizationHeader(services: ServiceRepository, token: string) { services.apiClient.defaults.headers.common = { Authorization: `OAuth2 ${token}` @@ -70,4 +80,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 = getCommonResourceServiceError(e); + if (error === CommonResourceServiceError.UNIQUE_PUBLIC_KEY) { + dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key already exists.' })); + } else if (error === CommonResourceServiceError.INVALID_PUBLIC_KEY) { + dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key is invalid' })); + } + } + }; + +export const loadSshKeysPanel = () => + async (dispatch: Dispatch, 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; diff --git a/src/store/auth/auth-reducer.ts b/src/store/auth/auth-reducer.ts index a4195322..8a30a2a6 100644 --- a/src/store/auth/auth-reducer.ts +++ b/src/store/auth/auth-reducer.ts @@ -5,13 +5,21 @@ import { authActions, AuthAction } from "./auth-action"; import { User } from "~/models/user"; import { ServiceRepository } from "~/services/services"; +import { SshKey } from '~/models/ssh-key'; export interface AuthState { user?: User; apiToken?: string; + sshKeys?: SshKey[]; } -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: SshKey[]) => { + return {...state, sshKeys}; + }, + ADD_SSH_KEY: (sshKey: SshKey) => { + return { ...state, sshKeys: state.sshKeys!.concat(sshKey) }; + }, default: () => state }); }; diff --git a/src/store/navigation/navigation-action.ts b/src/store/navigation/navigation-action.ts index b63fc2cb..57967c7d 100644 --- a/src/store/navigation/navigation-action.ts +++ b/src/store/navigation/navigation-action.ts @@ -61,3 +61,5 @@ export const navigateToSharedWithMe = push(Routes.SHARED_WITH_ME); export const navigateToRunProcess = push(Routes.RUN_PROCESS); export const navigateToSearchResults = push(Routes.SEARCH_RESULTS); + +export const navigateToSshKeys= push(Routes.SSH_KEYS); \ No newline at end of file diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts index aaf8f266..5cc9ea34 100644 --- a/src/store/workbench/workbench-actions.ts +++ b/src/store/workbench/workbench-actions.ts @@ -39,6 +39,7 @@ import { sharedWithMePanelActions } from '~/store/shared-with-me-panel/shared-wi import { loadSharedWithMePanel } from '../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 '../progress-indicator/progress-indicator-reducer'; @@ -390,6 +391,11 @@ export const loadSearchResults = handleFirstTimeLoad( await dispatch(loadSearchResultsPanel()); }); +export const loadSshKeys = handleFirstTimeLoad( + async (dispatch: Dispatch) => { + await dispatch(loadSshKeysPanel()); + }); + const finishLoadingProject = (project: GroupContentsResource | string) => async (dispatch: Dispatch) => { 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 index 00000000..7620a801 --- /dev/null +++ b/src/validators/is-rsa-key.tsx @@ -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; +}; diff --git a/src/validators/validators.tsx b/src/validators/validators.tsx index edc47265..1980ed80 100644 --- a/src/validators/validators.tsx +++ b/src/validators/validators.tsx @@ -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)]; @@ -19,4 +20,7 @@ export const COPY_FILE_VALIDATION = [require]; export const MOVE_TO_VALIDATION = [require]; -export const PROCESS_NAME_VALIDATION = [require, maxLength(255)]; \ No newline at end of file +export const PROCESS_NAME_VALIDATION = [require, maxLength(255)]; + +export const SSH_KEY_PUBLIC_VALIDATION = [require, isRsaKey, maxLength(1024)]; +export const SSH_KEY_NAME_VALIDATION = [require, maxLength(255)]; \ No newline at end of file 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 index 00000000..28c3a362 --- /dev/null +++ b/src/views-components/dialog-create/dialog-ssh-key-create.tsx @@ -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 '~/models/ssh-key'; + +type DialogSshKeyProps = WithDialogProps<{}> & InjectedFormProps; + +export const DialogSshKeyCreate = (props: DialogSshKeyProps) => + ; + +const SshKeyAddFields = () => + + +; 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 index 00000000..bc436d91 --- /dev/null +++ b/src/views-components/dialog-forms/create-ssh-key-dialog.ts @@ -0,0 +1,20 @@ +// 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 } from '~/store/auth/auth-action'; +import { DialogSshKeyCreate } from '~/views-components/dialog-create/dialog-ssh-key-create'; +import { SshKeyCreateFormDialogData } from '~/models/ssh-key'; + +export const CreateSshKeyDialog = compose( + withDialog(SSH_KEY_CREATE_FORM_NAME), + reduxForm({ + 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 index 00000000..8724e08f --- /dev/null +++ b/src/views-components/form-fields/ssh-key-form-fields.tsx @@ -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 = () => + ; + +export const SshKeyNameField = () => + ; + + diff --git a/src/views-components/main-app-bar/account-menu.tsx b/src/views-components/main-app-bar/account-menu.tsx index fdd8123f..ee863a29 100644 --- a/src/views-components/main-app-bar/account-menu.tsx +++ b/src/views-components/main-app-bar/account-menu.tsx @@ -8,9 +8,10 @@ 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 { navigateToSshKeys } from '~/store/navigation/navigation-action'; interface AccountMenuProps { user?: User; @@ -31,6 +32,7 @@ export const AccountMenu = connect(mapStateToProps)( {getUserFullname(user)} dispatch(openCurrentTokenDialog)}>Current token + dispatch(navigateToSshKeys)}>Ssh Keys My account dispatch(logout())}>Logout 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 index 00000000..90602de0 --- /dev/null +++ b/src/views/ssh-key-panel/ssh-key-panel-root.tsx @@ -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 { SshKey } from '~/models/ssh-key'; + + +type CssRules = 'root' | 'link'; + +const styles: StyleRulesCallback = (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?: SshKey[]; +} + +type SshKeyPanelRootProps = SshKeyPanelRootDataProps & SshKeyPanelRootActionProps & WithStyles; + +export const SshKeyPanelRoot = withStyles(styles)( + ({ classes, sshKeys, onClick }: SshKeyPanelRootProps) => + + + + You have not yet set up an SSH public key for use with Arvados. + + Learn more. + + + + When you have an SSH key you would like to use, add it using button below. + + + + + ); \ 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 index 00000000..f600677d --- /dev/null +++ b/src/views/ssh-key-panel/ssh-key-panel.tsx @@ -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 diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 8d1fb670..3a63ea37 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -44,10 +44,12 @@ 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'; import { ProjectPropertiesDialog } from '~/views-components/project-properties-dialog/project-properties-dialog'; +import { CreateSshKeyDialog } from '~/views-components/dialog-forms/create-ssh-key-dialog'; type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content'; @@ -117,6 +119,7 @@ export const WorkbenchPanel = + @@ -132,6 +135,7 @@ export const WorkbenchPanel = + -- 2.30.2