-
-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite): add granular controls to debug settings
- Loading branch information
Showing
1 changed file
with
58 additions
and
17 deletions.
There are no files selected for viewing
75 changes: 58 additions & 17 deletions
75
packages/suite/src/views/settings/SettingsDebug/CheckFirmwareAuthenticity.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,78 @@ | ||
import { useState } from 'react'; | ||
|
||
import { Button } from '@trezor/components'; | ||
import { Button, Switch } from '@trezor/components'; | ||
|
||
import { ActionColumn, SectionItem, TextColumn } from 'src/components/suite'; | ||
import { useDispatch } from 'src/hooks/suite'; | ||
import { useDispatch, useSelector } from 'src/hooks/suite'; | ||
import { manualFirmwareHashCheckThunk } from '@suite-common/wallet-core'; | ||
import { SUITE } from 'src/actions/suite/constants'; | ||
|
||
export const CheckFirmwareAuthenticity = () => { | ||
const [inProgress, setInProgress] = useState(false); | ||
|
||
const dispatch = useDispatch(); | ||
const { isFirmwareHashCheckDisabled, isFirmwareRevisionCheckDisabled } = useSelector( | ||
state => state.suite.settings, | ||
); | ||
|
||
const onCheckFirmwareAuthenticity = async () => { | ||
setInProgress(true); | ||
await dispatch(manualFirmwareHashCheckThunk()); | ||
setInProgress(false); | ||
}; | ||
|
||
const onToggleFirmwareRevisionCheck = (newEnabledState?: boolean) => | ||
dispatch({ | ||
type: SUITE.DEVICE_FIRMWARE_REVISION_CHECK, | ||
payload: { isDisabled: !newEnabledState }, | ||
}); | ||
const onToggleFirmwareHashCheck = (newEnabledState?: boolean) => | ||
dispatch({ | ||
type: SUITE.DEVICE_FIRMWARE_HASH_CHECK, | ||
payload: { isDisabled: !newEnabledState }, | ||
}); | ||
|
||
return ( | ||
<SectionItem data-testid="@settings/debug/check-firmware-authenticity"> | ||
<TextColumn | ||
title="Check firmware authenticity" | ||
description="Download firmware binary from data.trezor.io and compare its hash with firmware hash provided by Trezor device. TODO will be removed and done automatically" | ||
/> | ||
<ActionColumn> | ||
<Button | ||
onClick={onCheckFirmwareAuthenticity} | ||
isLoading={inProgress} | ||
isDisabled={inProgress} | ||
> | ||
Check | ||
</Button> | ||
</ActionColumn> | ||
</SectionItem> | ||
<> | ||
<SectionItem data-testid="@settings/debug/check-firmware-authenticity"> | ||
<TextColumn | ||
title="Check firmware authenticity" | ||
description="Download firmware binary from data.trezor.io and compare its hash with firmware hash provided by Trezor device." | ||
/> | ||
<ActionColumn> | ||
<Button | ||
onClick={onCheckFirmwareAuthenticity} | ||
isLoading={inProgress} | ||
isDisabled={inProgress} | ||
> | ||
Check | ||
</Button> | ||
</ActionColumn> | ||
</SectionItem> | ||
<SectionItem> | ||
<TextColumn | ||
title="Check firmware Hash regularly" | ||
description="Carry out firmware Hash check every time you authorize Trezor device. The toggle in Device settings controls both Hash & Revision check simultaneously." | ||
/> | ||
<ActionColumn> | ||
<Switch | ||
onChange={onToggleFirmwareHashCheck} | ||
isChecked={!isFirmwareHashCheckDisabled} | ||
/> | ||
</ActionColumn> | ||
</SectionItem> | ||
<SectionItem> | ||
<TextColumn | ||
title="Check firmware Revision regularly" | ||
description="Carry out firmware Revision check every time you authorize Trezor device. The toggle in Device settings controls both Hash & Revision check simultaneously." | ||
/> | ||
<ActionColumn> | ||
<Switch | ||
onChange={onToggleFirmwareRevisionCheck} | ||
isChecked={!isFirmwareRevisionCheckDisabled} | ||
/> | ||
</ActionColumn> | ||
</SectionItem> | ||
</> | ||
); | ||
}; |