diff --git a/web/settings/account-settings.react.js b/web/settings/account-settings.react.js --- a/web/settings/account-settings.react.js +++ b/web/settings/account-settings.react.js @@ -31,7 +31,6 @@ import css from './account-settings.css'; import AppearanceChangeModal from './appearance-change-modal.react.js'; -import BackupTestRestoreModal from './backup-test-restore-modal.react.js'; import DebugLogsModal from './debug-logs-modal.react.js'; import BlockListModal from './relationship/block-list-modal.react.js'; import FriendListModal from './relationship/friend-list-modal.react.js'; @@ -146,11 +145,6 @@ } }, [identityContext, sendMessageToDevice]); - const openBackupTestRestoreModal = React.useCallback( - () => pushModal(<BackupTestRestoreModal onClose={popModal} />), - [popModal, pushModal], - ); - const processAndSendDMOperation = useProcessAndSendDMOperation(); const onCreateDMThread = React.useCallback(async () => { invariant(userID, 'userID should be set'); @@ -240,24 +234,6 @@ </div> ); } - let backup; - if (staffCanSee) { - backup = ( - <div className={css.preferencesContainer}> - <h4 className={css.preferencesHeader}>Backup menu</h4> - <div className={css.content}> - <ul> - <li> - <span>Test backup restore</span> - <Button variant="text" onClick={openBackupTestRestoreModal}> - <p className={css.buttonText}>Insert data</p> - </Button> - </li> - </ul> - </div> - </div> - ); - } let deviceData; if (staffCanSee) { deviceData = ( @@ -351,7 +327,6 @@ </div> {preferences} {tunnelbroker} - {backup} {deviceData} {dms} {debugLogs} diff --git a/web/settings/backup-test-restore-modal.css b/web/settings/backup-test-restore-modal.css deleted file mode 100644 --- a/web/settings/backup-test-restore-modal.css +++ /dev/null @@ -1,25 +0,0 @@ -.modalBody { - padding: 24px 40px 32px; - color: var(--fg); -} - -.content { - display: flex; - flex-direction: column; - gap: 10px; -} - -.footer { - display: flex; - flex-direction: row-reverse; - justify-content: space-between; - padding-top: 8px; -} - -.modalError { - font-size: var(--xs-font-12); - color: var(--error); - font-style: italic; - padding-left: 6px; - align-self: center; -} diff --git a/web/settings/backup-test-restore-modal.react.js b/web/settings/backup-test-restore-modal.react.js deleted file mode 100644 --- a/web/settings/backup-test-restore-modal.react.js +++ /dev/null @@ -1,118 +0,0 @@ -// @flow - -import invariant from 'invariant'; -import * as React from 'react'; - -import { IdentityClientContext } from 'lib/shared/identity-client-context.js'; - -import css from './backup-test-restore-modal.css'; -import Button from '../components/button.react.js'; -import Input from '../modals/input.react.js'; -import Modal from '../modals/modal.react.js'; -import { getCommSharedWorker } from '../shared-worker/shared-worker-provider.js'; -import { workerRequestMessageTypes } from '../types/worker-types.js'; - -type Props = { - +onClose: () => void, -}; - -function BackupTestRestoreModal(props: Props): React.Node { - const { onClose } = props; - const [backupID, setBackupID] = React.useState(''); - const [backupDataKey, setBackupDataKey] = React.useState(''); - const [backupLogDataKey, setBackupLogDataKey] = React.useState(''); - const [inProgress, setInProgress] = React.useState(false); - const [errorMessage, setErrorMessage] = React.useState(''); - - const client = React.useContext(IdentityClientContext); - - const onSubmit = React.useCallback( - async (event: SyntheticEvent<HTMLButtonElement>) => { - event.preventDefault(); - - setInProgress(true); - void (async () => { - try { - if (!client) { - throw new Error('No identity client'); - } - - const authMetadata = await client.getAuthMetadata(); - - const sharedWorker = await getCommSharedWorker(); - await sharedWorker.schedule({ - type: workerRequestMessageTypes.BACKUP_RESTORE, - authMetadata, - backupID, - backupDataKey, - backupLogDataKey, - }); - } catch (e) { - setErrorMessage(e.message); - } - setInProgress(false); - })(); - }, - [backupDataKey, backupID, backupLogDataKey, client], - ); - - let errorMsg; - if (errorMessage) { - errorMsg = <div className={css.modalError}>{errorMessage}</div>; - } - - return ( - <Modal name="Test backup restore" onClose={onClose} size="large"> - <div className={css.modalBody}> - <div className={css.content}> - <Input - type="text" - value={backupID} - onChange={(event: SyntheticEvent<HTMLInputElement>) => { - const target = event.target; - invariant(target instanceof HTMLInputElement, 'target not input'); - setBackupID(target.value); - }} - disabled={inProgress} - label="Backup ID" - /> - <Input - type="text" - value={backupDataKey} - onChange={(event: SyntheticEvent<HTMLInputElement>) => { - const target = event.target; - invariant(target instanceof HTMLInputElement, 'target not input'); - setBackupDataKey(target.value); - }} - disabled={inProgress} - label="Backup Data Encryption Key" - /> - <Input - type="text" - value={backupLogDataKey} - onChange={(event: SyntheticEvent<HTMLInputElement>) => { - const target = event.target; - invariant(target instanceof HTMLInputElement, 'target not input'); - setBackupLogDataKey(target.value); - }} - disabled={inProgress} - label="Backup Logs Encryption Key" - /> - </div> - <div className={css.footer}> - <Button - type="submit" - variant="filled" - onClick={onSubmit} - disabled={!backupID || !backupDataKey || inProgress} - > - Restore - </Button> - {errorMsg} - </div> - </div> - </Modal> - ); -} - -export default BackupTestRestoreModal;