From: Stephen Smith Date: Mon, 2 Aug 2021 19:16:03 +0000 (-0400) Subject: 17690: Filter ssh keys shown in user keys to only current user X-Git-Tag: 2.3.0~8^2~2 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/ec862c8c86eab36e998186f3138dd396d4ec13f6 17690: Filter ssh keys shown in user keys to only current user Arvados-DCO-1.1-Signed-off-by: Stephen Smith --- diff --git a/src/views/ssh-key-panel/ssh-key-admin-panel.tsx b/src/views/ssh-key-panel/ssh-key-admin-panel.tsx new file mode 100644 index 00000000..72a8c4cb --- /dev/null +++ b/src/views/ssh-key-panel/ssh-key-admin-panel.tsx @@ -0,0 +1,31 @@ +// 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 { openSshKeyCreateDialog, openPublicKeyDialog } from 'store/auth/auth-action-ssh'; +import { openSshKeyContextMenu } from 'store/context-menu/context-menu-actions'; +import { SshKeyPanelRoot, SshKeyPanelRootDataProps, SshKeyPanelRootActionProps } from 'views/ssh-key-panel/ssh-key-panel-root'; + +const mapStateToProps = (state: RootState): SshKeyPanelRootDataProps => { + return { + sshKeys: state.auth.sshKeys, + hasKeys: state.auth.sshKeys!.length > 0 + }; +}; + +const mapDispatchToProps = (dispatch: Dispatch): SshKeyPanelRootActionProps => ({ + openSshKeyCreateDialog: () => { + dispatch(openSshKeyCreateDialog()); + }, + openRowOptions: (event, sshKey) => { + dispatch(openSshKeyContextMenu(event, sshKey)); + }, + openPublicKeyDialog: (name: string, publicKey: string) => { + dispatch(openPublicKeyDialog(name, publicKey)); + } +}); + +export const SshKeyAdminPanel = connect(mapStateToProps, mapDispatchToProps)(SshKeyPanelRoot); diff --git a/src/views/ssh-key-panel/ssh-key-panel.tsx b/src/views/ssh-key-panel/ssh-key-panel.tsx index 4d896f3d..f2b7dd3c 100644 --- a/src/views/ssh-key-panel/ssh-key-panel.tsx +++ b/src/views/ssh-key-panel/ssh-key-panel.tsx @@ -10,9 +10,13 @@ import { openSshKeyContextMenu } from 'store/context-menu/context-menu-actions'; import { SshKeyPanelRoot, SshKeyPanelRootDataProps, SshKeyPanelRootActionProps } from 'views/ssh-key-panel/ssh-key-panel-root'; const mapStateToProps = (state: RootState): SshKeyPanelRootDataProps => { + const sshKeys = state.auth.sshKeys = state.auth.sshKeys.filter((key) => { + return key.authorizedUserUuid == state.auth.user.uuid; + }); + return { - sshKeys: state.auth.sshKeys, - hasKeys: state.auth.sshKeys!.length > 0 + sshKeys: sshKeys, + hasKeys: sshKeys!.length > 0 }; }; diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index b708355c..9ce93bf2 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -45,6 +45,7 @@ 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 { SshKeyAdminPanel } from 'views/ssh-key-panel/ssh-key-admin-panel'; import { SiteManagerPanel } from "views/site-manager-panel/site-manager-panel"; import { MyAccountPanel } from 'views/my-account-panel/my-account-panel'; import { SharingDialog } from 'views-components/sharing-dialog/sharing-dialog'; @@ -164,7 +165,7 @@ let routes = <> - +