diff --git a/web/navigation-panels/settings-switcher.react.js b/web/navigation-panels/settings-switcher.react.js index f44038431..1075f3f5a 100644 --- a/web/navigation-panels/settings-switcher.react.js +++ b/web/navigation-panels/settings-switcher.react.js @@ -1,93 +1,100 @@ // @flow import * as React from 'react'; import { useDispatch } from 'lib/utils/redux-utils.js'; +import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js'; import NavigationPanel from './navigation-panel.react.js'; import css from './settings-switcher.css'; import { updateNavInfoActionType } from '../redux/action-types.js'; import { navSettingsSectionSelector } from '../selectors/nav-selectors.js'; import { useStaffCanSee } from '../utils/staff-utils.js'; function SettingsSwitcher(): React.Node { const dispatch = useDispatch(); const onClickAccountSettings = React.useCallback( (event: SyntheticEvent) => { event.preventDefault(); dispatch({ type: updateNavInfoActionType, payload: { tab: 'settings', settingsSection: 'account' }, }); }, [dispatch], ); const accountSettingsNavigationItem = React.useMemo( () => (

My Account

), [onClickAccountSettings], ); const staffCanSee = useStaffCanSee(); const onClickKeyservers = React.useCallback( (event: SyntheticEvent) => { event.preventDefault(); dispatch({ type: updateNavInfoActionType, payload: { tab: 'settings', settingsSection: 'keyservers' }, }); }, [dispatch], ); const keyserversNavigationItem = React.useMemo(() => { if (!staffCanSee) { return null; } return (

Keyservers

); }, [onClickKeyservers, staffCanSee]); const onClickDangerZone = React.useCallback( (event: SyntheticEvent) => { event.preventDefault(); dispatch({ type: updateNavInfoActionType, payload: { tab: 'settings', settingsSection: 'danger-zone' }, }); }, [dispatch], ); - const dangerZoneNavigationItem = React.useMemo( - () => ( + const dangerZoneNavigationItem = React.useMemo(() => { + // Once we're using the identity service for auth, a user may only delete + // their Comm account using their primary device. Their primary device + // cannot be a web device at this time, so we hide the Danger Zone from web + // users. + if (usingCommServicesAccessToken) { + return null; + } + return (

Danger Zone

- ), - [onClickDangerZone], - ); + ); + }, [onClickDangerZone]); return ( {accountSettingsNavigationItem} {keyserversNavigationItem} {dangerZoneNavigationItem} ); } export default SettingsSwitcher; diff --git a/web/settings/danger-zone.react.js b/web/settings/danger-zone.react.js index c40f1133d..132160e66 100644 --- a/web/settings/danger-zone.react.js +++ b/web/settings/danger-zone.react.js @@ -1,40 +1,48 @@ // @flow import * as React from 'react'; import { useModalContext } from 'lib/components/modal-provider.react.js'; +import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js'; import AccountDeleteModal from './account-delete-modal.react.js'; import css from './danger-zone.css'; import Button, { buttonThemes } from '../components/button.react.js'; function DangerZone(): React.Node { const { pushModal } = useModalContext(); const onDeleteAccountClick = React.useCallback( () => pushModal(), [pushModal], ); + // Once we're using the identity service for auth, a user may only delete + // their Comm account using their primary device. Their primary device cannot + // be a web device at this time, so we hide the Danger Zone from web users. + if (usingCommServicesAccessToken) { + return null; + } + return (

Danger Zone

Delete Account

Your account will be permanently deleted. There is no way to reverse this.

); } export default DangerZone;