diff --git a/src/components/DeleteConfirm/index.js b/src/components/DeleteConfirm/index.js index 7b4d97df..8902b7f1 100644 --- a/src/components/DeleteConfirm/index.js +++ b/src/components/DeleteConfirm/index.js @@ -11,6 +11,7 @@ import { color } from 'lib/variables'; export const DeleteConfirm = ({ deleteType, deleteName, + deleteMessage, icon, onDelete, inputValue, @@ -28,11 +29,15 @@ export const DeleteConfirm = ({ -

- This will delete all resources associated with the {deleteType}{' '} - {deleteName} and cannot be undone. Make sure this is something you - really want to do! -

+ {deleteMessage ? ( +

{deleteMessage}

+ ) : ( +

+ This will delete all resources associated with the {deleteType}{' '} + {deleteName} and cannot be undone. Make sure this is something you + really want to do! +

+ )}

Type the name of the {deleteType} to confirm.

diff --git a/src/components/SshKeys/index.js b/src/components/SshKeys/index.js index 81bf8ec7..676ad575 100644 --- a/src/components/SshKeys/index.js +++ b/src/components/SshKeys/index.js @@ -4,9 +4,11 @@ import Skeleton from 'react-loading-skeleton'; import { Col, Modal, Row, Space, notification } from 'antd'; import Button from 'components/Button'; +import DeleteConfirm from 'components/DeleteConfirm'; import DeleteUserSSHPublicKey from 'lib/mutation/DeleteUserSSHPublicKey'; import UpdateUserSSHPublicKey from 'lib/mutation/UpdateUserSSHPublicKey'; import Me from 'lib/query/Me'; +import { color } from 'lib/variables'; import moment from 'moment'; import { StyledKeys } from './StyledKeys'; @@ -19,21 +21,24 @@ const SshKeys = ({ me: { id, email, sshKeys: keys }, loading, handleRefetch }) = const [editState, setEditState] = useState({ id: '', name: '', - keyValue: '', + publicKey: '', }); const closeModal = () => { - setEditState({ name: '', keyValue: '' }); + setEditState({ name: '', publicKey: '' }); setModalOpen(false); }; const openModal = keyObject => { - setEditState(keyObject); + setEditState({ ...keyObject, publicKey: getPK(keyObject) }); setModalOpen(true); }; const [api, contextHolder] = notification.useNotification({ maxCount: 1 }); + const getPK = key => { + return key.keyType + ' ' + key.keyValue; + }; const openNotificationWithIcon = errorMessage => { api['error']({ message: 'There was a problem updating the SSH key.', @@ -108,7 +113,7 @@ const SshKeys = ({ me: { id, email, sshKeys: keys }, loading, handleRefetch }) = id: key.id, patch: { name: editState.name, - publicKey: editState.keyValue, + publicKey: editState.publicKey, }, }, }, @@ -151,9 +156,9 @@ const SshKeys = ({ me: { id, email, sshKeys: keys }, loading, handleRefetch }) = { - setEditState({ ...editState, keyValue: e.target.value }); + setEditState({ ...editState, publicKey: e.target.value }); }} /> @@ -172,12 +177,23 @@ const SshKeys = ({ me: { id, email, sshKeys: keys }, loading, handleRefetch }) = return
{error.message}
; } + const deleteMessage = ( + <> + This action will delete the SSH key{' '} + {key.name} and cannot be + undone. + + ); + return ( - + /> ); }}