Skip to content

Commit

Permalink
fix(suite): Fix view only in settings when no device (#13693)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvaclavik authored Aug 7, 2024
1 parent 9adeb0b commit 70de4d6
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import {
TextColumn,
Translation,
} from 'src/components/suite';
import { useDispatch } from 'src/hooks/suite';
import { useDevice, useDispatch } from 'src/hooks/suite';

export const EnableViewOnly = () => {
const dispatch = useDispatch();
const { device } = useDevice();

const handleSwitchDeviceClick = () =>
dispatch(
goto('suite-switch-device', {
Expand All @@ -19,14 +21,20 @@ export const EnableViewOnly = () => {
}),
);

const isDeviceConnected = device?.connected && device?.available;

return (
<SectionItem data-test="@settings/device/enable-view-only">
<TextColumn
title={<Translation id="TR_DEVICE_SETTINGS_ENABLE_VIEW_ONLY_TITLE" />}
description={<Translation id="TR_DEVICE_SETTINGS_ENABLE_VIEW_ONLY_DESC" />}
/>
<ActionColumn>
<ActionButton onClick={handleSwitchDeviceClick} variant="secondary">
<ActionButton
onClick={handleSwitchDeviceClick}
variant="secondary"
isDisabled={!isDeviceConnected}
>
<Translation id="TR_DEVICE_SETTINGS_ENABLE_VIEW_ONLY_CHANGE_BUTTON" />
</ActionButton>
</ActionColumn>
Expand Down

0 comments on commit 70de4d6

Please sign in to comment.