1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
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';
12 const mapStateToProps = (state: RootState): SshKeyPanelRootDataProps => {
13 const sshKeys = state.auth.sshKeys.filter((key) => {
14 return key.authorizedUserUuid === (state.auth.user ? state.auth.user.uuid : null);
19 hasKeys: sshKeys!.length > 0
23 const mapDispatchToProps = (dispatch: Dispatch): SshKeyPanelRootActionProps => ({
24 openSshKeyCreateDialog: () => {
25 dispatch<any>(openSshKeyCreateDialog());
27 openRowOptions: (event, sshKey) => {
28 dispatch<any>(openSshKeyContextMenu(event, sshKey));
30 openPublicKeyDialog: (name: string, publicKey: string) => {
31 dispatch<any>(openPublicKeyDialog(name, publicKey));
35 export const SshKeyPanel = connect(mapStateToProps, mapDispatchToProps)(SshKeyPanelRoot);