Skip to content

Commit

Permalink
fix: remove pin-followup on backup device (doesn make sense), also pr…
Browse files Browse the repository at this point in the history
…event modal closure without confirming seed action
  • Loading branch information
peter-sanderson committed Jan 7, 2025
1 parent f47c6d2 commit cbcd78f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 55 deletions.
4 changes: 2 additions & 2 deletions packages/suite-web/e2e/tests/backup/t2t1-success.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ describe('Backup success', () => {
cy.task('pressYes');

cy.log('click all after checkboxes and close backup modal');
cy.getTestElement('@backup/continue-to-pin-button').should('be.disabled');
cy.getTestElement('@backup/close-button').should('be.disabled');
cy.getTestElement('@backup/check-item/wrote-seed-properly').click();
cy.getTestElement('@backup/check-item/made-no-digital-copy').click();
cy.getTestElement('@backup/check-item/will-hide-seed').click();
cy.getTestElement('@backup/continue-to-pin-button').should('not.be.disabled');
cy.getTestElement('@backup/close-button').should('not.be.disabled');

cy.findAnalyticsEventByType<ExtractByEventType<EventType.CreateBackup>>(
requests,
Expand Down
9 changes: 2 additions & 7 deletions packages/suite/src/views/backup/Backup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { selectSelectedDevice } from '@suite-common/wallet-core';
import { useSelector } from 'src/hooks/suite';
import { Translation, TrezorLink } from 'src/components/suite';
import type { ForegroundAppProps } from 'src/types/suite';
import { BackupState } from 'src/reducers/backup/backupReducer';

import { BackupStep1Initial } from './BackupStep1Initial';
import { BackupStep2InProgress } from './BackupStep2InProgress';
import { BackupStep3Finished } from './BackupStep3Finished';
import { BackupStepError } from './BackupStepError';
import { selectBackup } from '../../reducers/backup/backupReducer';

const getEdgeCaseModalHeading = (unfinishedBackup: boolean) => {
if (unfinishedBackup) {
Expand All @@ -28,12 +28,7 @@ export const Backup = ({
onCancel,
}: ForegroundAppProps): NonNullable<ReactNode> /* NonNullable return type is required here to prevent default return from switch-case */ => {
const device = useSelector(selectSelectedDevice);
// const backup = useSelector(selectBackup);

const backup: BackupState = {
status: 'finished',
userConfirmed: [],
};
const backup = useSelector(selectBackup);

const isDeviceUnavailable = !isDeviceAcquired(device) || !device.connected;

Expand Down
14 changes: 4 additions & 10 deletions packages/suite/src/views/backup/BackupStep1Initial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,10 @@ export const BackupStep1Initial = ({
</>
}
>
<>
<Paragraph
variant="tertiary"
typographyStyle="hint"
margin={{ bottom: spacings.xl }}
>
<Translation id="TR_BACKUP_SUBHEADING_1" />
</Paragraph>
<PreBackupCheckboxes />
</>
<Paragraph variant="tertiary" typographyStyle="hint" margin={{ bottom: spacings.xl }}>
<Translation id="TR_BACKUP_SUBHEADING_1" />
</Paragraph>
<PreBackupCheckboxes />
</NewModal>
);
};
45 changes: 9 additions & 36 deletions packages/suite/src/views/backup/BackupStep3Finished.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Paragraph, NewModal } from '@trezor/components';
import { spacings } from '@trezor/theme';
import { selectSelectedDevice } from '@suite-common/wallet-core';

import { useDispatch, useSelector } from 'src/hooks/suite';
import { changePin } from 'src/actions/settings/deviceSettingsActions';
import { Translation } from 'src/components/suite';
import { canContinue } from 'src/utils/backup';

Expand All @@ -18,47 +15,23 @@ export const BackupStep3Finished = ({
onCancel: () => void;
backup: BackupState;
}) => {
const device = useSelector(selectSelectedDevice);
const dispatch = useDispatch();
const continueEnabled = canContinue(backup.userConfirmed);

return (
<NewModal
onCancel={onCancel}
onCancel={continueEnabled ? onCancel : undefined}
variant="primary"
data-testid="@backup"
heading={<Translation id="TR_BACKUP_CREATED" />}
description={<BackupStepDescription backupStatus={backup.status} />}
bottomContent={
<>
{device?.features?.pin_protection ? (
<NewModal.Button
isDisabled={!canContinue(backup.userConfirmed)}
onClick={() => onCancel()}
>
<Translation id="TR_CLOSE" />
</NewModal.Button>
) : (
<>
<NewModal.Button
data-testid="@backup/continue-to-pin-button"
isDisabled={!canContinue(backup.userConfirmed)}
onClick={() => {
onCancel();
dispatch(changePin({}));
}}
>
<Translation id="TR_CONTINUE_TO_PIN" />
</NewModal.Button>
<NewModal.Button
onClick={() => onCancel()}
data-testid="@backup/close-button"
variant="tertiary"
>
<Translation id="TR_SKIP_PIN" />
</NewModal.Button>
</>
)}
</>
<NewModal.Button
isDisabled={!continueEnabled}
onClick={onCancel}
data-testid="@backup/close-button"
>
<Translation id="TR_CLOSE" />
</NewModal.Button>
}
>
<Paragraph
Expand Down

0 comments on commit cbcd78f

Please sign in to comment.