17690: Filter ssh keys shown in user keys to only current user
authorStephen Smith <stephen@curii.com>
Mon, 2 Aug 2021 19:16:03 +0000 (15:16 -0400)
committerStephen Smith <stephen@curii.com>
Mon, 2 Aug 2021 19:16:03 +0000 (15:16 -0400)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

src/views/ssh-key-panel/ssh-key-admin-panel.tsx [new file with mode: 0644]
src/views/ssh-key-panel/ssh-key-panel.tsx
src/views/workbench/workbench.tsx

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 (file)
index 0000000..72a8c4c
--- /dev/null
@@ -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<any>(openSshKeyCreateDialog());
+    },
+    openRowOptions: (event, sshKey) => {
+        dispatch<any>(openSshKeyContextMenu(event, sshKey));
+    },
+    openPublicKeyDialog: (name: string, publicKey: string) => {
+        dispatch<any>(openPublicKeyDialog(name, publicKey));
+    }
+});
+
+export const SshKeyAdminPanel = connect(mapStateToProps, mapDispatchToProps)(SshKeyPanelRoot);
index 4d896f3d4b4f705a4f87005d1c6ed22560c10fda..f2b7dd3c43793b8b3f73523342e426cff2f6af64 100644 (file)
@@ -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
     };
 };
 
index b708355cd4f1a84fd68ecb19b287728920f0fbd4..9ce93bf2ae6e38214186defb3bc87dc02b6455d8 100644 (file)
@@ -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 = <>
     <Route path={Routes.VIRTUAL_MACHINES_ADMIN} component={VirtualMachineAdminPanel} />
     <Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
     <Route path={Routes.SSH_KEYS_USER} component={SshKeyPanel} />
-    <Route path={Routes.SSH_KEYS_ADMIN} component={SshKeyPanel} />
+    <Route path={Routes.SSH_KEYS_ADMIN} component={SshKeyAdminPanel} />
     <Route path={Routes.SITE_MANAGER} component={SiteManagerPanel} />
     <Route path={Routes.KEEP_SERVICES} component={KeepServicePanel} />
     <Route path={Routes.USERS} component={UserPanel} />