Skip to content

Commit

Permalink
fix: copy fix for wipe-device vs. factory-reset in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-sanderson committed Jan 7, 2025
1 parent fc56ea0 commit 1d29171
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState } from 'react';

import { NewModal, Card, Column, H3, Paragraph } from '@trezor/components';
import { spacings } from '@trezor/theme';
import { isDeviceInBootloaderMode } from '@trezor/device-utils';

import { Translation, CheckItem } from 'src/components/suite';
import { wipeDevice } from 'src/actions/settings/deviceSettingsActions';
Expand All @@ -15,12 +16,17 @@ export const WipeDeviceModal = ({ onCancel }: WipeDeviceModalProps) => {
const [checkbox1, setCheckbox1] = useState(false);
const [checkbox2, setCheckbox2] = useState(false);

const { device, isLocked } = useDevice();
const dispatch = useDispatch();

const { isLocked } = useDevice();
const isBootloaderMode = isDeviceInBootloaderMode(device);

const handleWipeDevice = () => dispatch(wipeDevice());

const headingTranslation = isBootloaderMode
? 'TR_DEVICE_SETTINGS_FACTORY_RESET'
: 'TR_DEVICE_SETTINGS_WIPE_DEVICE';

return (
<NewModal
onCancel={onCancel}
Expand All @@ -35,7 +41,7 @@ export const WipeDeviceModal = ({ onCancel }: WipeDeviceModalProps) => {
isDisabled={isLocked() || !checkbox1 || !checkbox2}
data-testid="@wipe/wipe-button"
>
<Translation id="TR_DEVICE_SETTINGS_BUTTON_WIPE_DEVICE" />
<Translation id={headingTranslation} />
</NewModal.Button>
<NewModal.Button variant="tertiary" onClick={onCancel}>
<Translation id="TR_CANCEL" />
Expand All @@ -44,7 +50,7 @@ export const WipeDeviceModal = ({ onCancel }: WipeDeviceModalProps) => {
}
>
<H3>
<Translation id="TR_DEVICE_SETTINGS_BUTTON_WIPE_DEVICE" />
<Translation id={headingTranslation} />
</H3>
<Paragraph variant="tertiary" margin={{ top: spacings.xs }}>
<Translation id="TR_WIPE_DEVICE_TEXT" />
Expand Down
19 changes: 14 additions & 5 deletions packages/suite/src/support/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2093,9 +2093,13 @@ export default defineMessages({
defaultMessage: 'Security',
id: 'TR_DEVICE_SECURITY',
},
TR_DEVICE_SETTINGS_BUTTON_WIPE_DEVICE: {
TR_DEVICE_SETTINGS_FACTORY_RESET: {
defaultMessage: 'Factory reset',
id: 'TR_DEVICE_SETTINGS_BUTTON_WIPE_DEVICE',
id: 'TR_DEVICE_SETTINGS_FACTORY_RESET',
},
TR_DEVICE_SETTINGS_WIPE_DEVICE: {
defaultMessage: 'Wipe device',
id: 'TR_DEVICE_SETTINGS_WIPE_DEVICE',
},
TR_DEVICE_SETTINGS_CUSTOM_FIRMWARE_BUTTON: {
defaultMessage: 'Install firmware',
Expand Down Expand Up @@ -3335,10 +3339,15 @@ export default defineMessages({
defaultMessage: 'Learn more about the difference',
id: 'TR_WHAT_IS_PASSPHRASE',
},
TR_WIPING_YOUR_DEVICE: {
TR_FACTORY_RESET_DESCRIPTION: {
defaultMessage:
'Performing a factory reset in bootloader mode will erase all device data, including the wallet backup, PIN, and firmware. Without your wallet backup, any funds stored on the device will be lost forever. Ensure you have your backup on hand, as it’s required to restore access to your funds after the reset. Only proceed if you’re fully prepared.',
id: 'TR_FACTORY_RESET_DESCRIPTION',
},
TR_WIPE_DEVICE_DESCRIPTION: {
defaultMessage:
'Factory reset wipes the device memory, erasing all information including the wallet backup and PIN. Only perform a factory reset if you have your wallet backup, which is needed to restore access to your funds.',
id: 'TR_WIPING_YOUR_DEVICE',
'Wiping the device will permanently erase all stored data, including the wallet backup and PIN. If you do not have your wallet backup, any funds on the device will be lost forever. Ensure you have your backup available before wiping the device, as it is essential for restoring access to your funds. Proceed with caution.',
id: 'TR_WIPE_DEVICE_DESCRIPTION',
},
TR_WORDS: {
defaultMessage: '{count} words',
Expand Down
25 changes: 21 additions & 4 deletions packages/suite/src/views/settings/SettingsDevice/WipeDevice.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { isDeviceInBootloaderMode } from '@trezor/device-utils';

import { SettingsSectionItem } from 'src/components/settings';
import { ActionButton, ActionColumn, TextColumn, Translation } from 'src/components/suite';
import { useDispatch } from 'src/hooks/suite';
import { useDevice, useDispatch } from 'src/hooks/suite';
import { openModal } from 'src/actions/suite/modalActions';
import { SettingsAnchor } from 'src/constants/suite/anchors';

Expand All @@ -9,15 +11,30 @@ interface WipeDeviceProps {
}

export const WipeDevice = ({ isDeviceLocked }: WipeDeviceProps) => {
const { device } = useDevice();
const dispatch = useDispatch();

const isBootloaderMode = isDeviceInBootloaderMode(device);

const handleClick = () => dispatch(openModal({ type: 'wipe-device' }));

const headingTranslation = isBootloaderMode
? 'TR_DEVICE_SETTINGS_FACTORY_RESET'
: 'TR_DEVICE_SETTINGS_WIPE_DEVICE';

return (
<SettingsSectionItem anchorId={SettingsAnchor.WipeDevice}>
<TextColumn
title={<Translation id="TR_DEVICE_SETTINGS_BUTTON_WIPE_DEVICE" />}
description={<Translation id="TR_WIPING_YOUR_DEVICE" />}
title={<Translation id={headingTranslation} />}
description={
<Translation
id={
isBootloaderMode
? 'TR_FACTORY_RESET_DESCRIPTION'
: 'TR_WIPE_DEVICE_DESCRIPTION'
}
/>
}
/>
<ActionColumn>
<ActionButton
Expand All @@ -26,7 +43,7 @@ export const WipeDevice = ({ isDeviceLocked }: WipeDeviceProps) => {
isDisabled={isDeviceLocked}
data-testid="@settings/device/open-wipe-modal-button"
>
<Translation id="TR_DEVICE_SETTINGS_BUTTON_WIPE_DEVICE" />
<Translation id={headingTranslation} />
</ActionButton>
</ActionColumn>
</SettingsSectionItem>
Expand Down

0 comments on commit 1d29171

Please sign in to comment.