17690: Fix stray accidental copy+paste
[arvados-workbench2.git] / src / views / ssh-key-panel / ssh-key-panel.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { RootState } from 'store/store';
6 import { Dispatch } from 'redux';
7 import { connect } from 'react-redux';
8 import { openSshKeyCreateDialog, openPublicKeyDialog } from 'store/auth/auth-action-ssh';
9 import { openSshKeyContextMenu } from 'store/context-menu/context-menu-actions';
10 import { SshKeyPanelRoot, SshKeyPanelRootDataProps, SshKeyPanelRootActionProps } from 'views/ssh-key-panel/ssh-key-panel-root';
11
12 const mapStateToProps = (state: RootState): SshKeyPanelRootDataProps => {
13     const sshKeys = state.auth.sshKeys.filter((key) => {
14       return key.authorizedUserUuid == state.auth.user.uuid;
15     });
16
17     return {
18         sshKeys: sshKeys,
19         hasKeys: sshKeys!.length > 0
20     };
21 };
22
23 const mapDispatchToProps = (dispatch: Dispatch): SshKeyPanelRootActionProps => ({
24     openSshKeyCreateDialog: () => {
25         dispatch<any>(openSshKeyCreateDialog());
26     },
27     openRowOptions: (event, sshKey) => {
28         dispatch<any>(openSshKeyContextMenu(event, sshKey));
29     },
30     openPublicKeyDialog: (name: string, publicKey: string) => {
31         dispatch<any>(openPublicKeyDialog(name, publicKey));
32     }
33 });
34
35 export const SshKeyPanel = connect(mapStateToProps, mapDispatchToProps)(SshKeyPanelRoot);