diff --git a/web/modals/keyserver-selection/keyserver-selection-modal.css b/web/modals/keyserver-selection/keyserver-selection-modal.css --- a/web/modals/keyserver-selection/keyserver-selection-modal.css +++ b/web/modals/keyserver-selection/keyserver-selection-modal.css @@ -39,3 +39,11 @@ .button { width: 100%; } + +.keyserverRemoveConfirmationContainer { + display: flex; + flex-direction: column; + row-gap: 24px; + padding: 24px 32px; + color: var(--text-background-primary-default); +} diff --git a/web/modals/keyserver-selection/keyserver-selection-modal.react.js b/web/modals/keyserver-selection/keyserver-selection-modal.react.js --- a/web/modals/keyserver-selection/keyserver-selection-modal.react.js +++ b/web/modals/keyserver-selection/keyserver-selection-modal.react.js @@ -2,15 +2,18 @@ import * as React from 'react'; +import { removeKeyserverActionType } from 'lib/actions/keyserver-actions.js'; import { useModalContext } from 'lib/components/modal-provider.react.js'; import type { KeyserverInfo } from 'lib/types/keyserver-types.js'; import type { GlobalAccountUserInfo } from 'lib/types/user-types.js'; +import { useDispatch } from 'lib/utils/redux-utils.js'; import css from './keyserver-selection-modal.css'; import Button, { buttonThemes } from '../../components/button.react.js'; import KeyserverPill from '../../components/keyserver-pill.react.js'; import StatusIndicator from '../../components/status-indicator.react.js'; import Alert from '../alert.react.js'; +import ConfirmationAlert from '../confirmation-alert.react.js'; import Modal from '../modal.react.js'; type Props = { @@ -21,7 +24,7 @@ function KeyserverSelectionModal(props: Props): React.Node { const { keyserverAdminUserInfo, keyserverInfo } = props; - const { popModal, pushModal } = useModalContext(); + const { popModal, pushModal, clearModals } = useModalContext(); const onClickDisconnectKeyserver = React.useCallback( () => @@ -36,6 +39,40 @@ [pushModal], ); + const dispatch = useDispatch(); + + const onDeleteKeyserver = React.useCallback(() => { + dispatch({ + type: removeKeyserverActionType, + payload: { + keyserverAdminUserID: keyserverAdminUserInfo.id, + }, + }); + + clearModals(); + }, [clearModals, dispatch, keyserverAdminUserInfo.id]); + + const onClickRemoveKeyserver = React.useCallback( + () => + pushModal( + +
+
+ Are you sure you want to delete this keyserver from your keyserver + list? +
+
You will still remain in the associated communities.
+
+
, + ), + [onDeleteKeyserver, pushModal], + ); + const { keyerverRemoveInfoText, keyserverRemoveButton } = React.useMemo(() => { if (keyserverInfo.connection.status !== 'connected') { @@ -58,6 +95,7 @@ variant="filled" buttonColor={buttonThemes.danger} className={css.button} + onClick={onClickRemoveKeyserver} > Delete keyserver from list @@ -96,7 +134,11 @@ keyerverRemoveInfoText: removeInfoText, keyserverRemoveButton: removeButton, }; - }, [keyserverInfo.connection.status, onClickDisconnectKeyserver]); + }, [ + keyserverInfo.connection.status, + onClickDisconnectKeyserver, + onClickRemoveKeyserver, + ]); return (