diff --git a/frontend/src/components/accountPage/SSHKeysTable/SSHKeysTable.tsx b/frontend/src/components/accountPage/SSHKeysTable/SSHKeysTable.tsx index 74bc718b5..6a708f7cd 100644 --- a/frontend/src/components/accountPage/SSHKeysTable/SSHKeysTable.tsx +++ b/frontend/src/components/accountPage/SSHKeysTable/SSHKeysTable.tsx @@ -1,15 +1,18 @@ import { DeleteOutlined } from '@ant-design/icons'; -import { Popconfirm, Table } from 'antd'; +import { Table } from 'antd'; +import Button from 'antd-button-color'; import Column from 'antd/lib/table/Column'; -import { FC } from 'react'; +import { FC, useState } from 'react'; +import { ModalAlert } from '../../common/ModalAlert'; export interface ISSHKeysTableProps { sshKeys?: { name: string; key: string }[]; - onDeleteKey?: (key: { name: string; key: string }) => void; + onDeleteKey: (key: { name: string; key: string }) => Promise; } const SSHKeysTable: FC = props => { - const { sshKeys } = props; + const { sshKeys, onDeleteKey } = props; + const [showDeleteModalConfirm, setShowDeleteModalConfirm] = useState(false); return ( = props => { width={60} render={(_: any, record: { name: string; key: string }) => sshKeys?.length && ( - props.onDeleteKey?.(record)} - > - - + <> + setShowDeleteModalConfirm(false)} + > + Close + , + , + ]} + show={showDeleteModalConfirm} + setShow={setShowDeleteModalConfirm} + /> + + setShowDeleteModalConfirm(true)} + style={{ color: 'red' }} + /> + ) } /> diff --git a/frontend/src/components/accountPage/UserPanel/UserPanel.tsx b/frontend/src/components/accountPage/UserPanel/UserPanel.tsx index dacc9880c..e60592991 100644 --- a/frontend/src/components/accountPage/UserPanel/UserPanel.tsx +++ b/frontend/src/components/accountPage/UserPanel/UserPanel.tsx @@ -14,22 +14,16 @@ export interface IUserPanelProps { username: string; email: string; sshKeys?: { name: string; key: string }[]; - onDeleteKey?: (key: { - name: string; - key: string; - }) => boolean | Promise; - onAddKey?: (key: { name: string; key: string }) => boolean | Promise; + onDeleteKey: (key: { name: string; key: string }) => Promise; + onAddKey: (key: { name: string; key: string }) => boolean | Promise; } const UserPanel: FC = props => { - const { sshKeys, ...otherInfo } = props; + const { sshKeys, onDeleteKey, ...otherInfo } = props; const [showSSHModal, setShowSSHModal] = useState(false); const closeModal = () => setShowSSHModal(false); - const deleteKey = async (targetKey: { name: string; key: string }) => { - await props.onDeleteKey?.(targetKey); - }; const addKey = async (newKey: { name: string; key: string }) => { if (await props.onAddKey?.(newKey)) { closeModal(); @@ -56,7 +50,7 @@ const UserPanel: FC = props => { - +