Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tip warning the developers that they may have bridge disabled in the debug settings #15616

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import { isDesktop } from '@trezor/env-utils';

import { Translation, TroubleshootingTips } from 'src/components/suite';
import {
TROUBLESHOOTING_TIP_SUITE_DESKTOP,
TROUBLESHOOTING_TIP_RESTART_COMPUTER,
TROUBLESHOOTING_TIP_WEBUSB_ENVIRONMENT,
TROUBLESHOOTING_ENABLE_IN_DEBUG,
TipItem,
} from 'src/components/suite/troubleshooting/tips';

export const Transport = () => {
const items = [
TROUBLESHOOTING_TIP_WEBUSB_ENVIRONMENT,
TROUBLESHOOTING_TIP_SUITE_DESKTOP,
TROUBLESHOOTING_TIP_RESTART_COMPUTER,
];
import { useBridgeDesktopApi } from '../../../hooks/suite/useBridgeDesktopApi';
import { useSelector } from '../../../hooks/suite';
import { selectIsDebugModeActive } from '../../../reducers/suite/suiteReducer';

const tipItems: TipItem[] = [
TROUBLESHOOTING_TIP_WEBUSB_ENVIRONMENT,
TROUBLESHOOTING_TIP_SUITE_DESKTOP,
TROUBLESHOOTING_TIP_RESTART_COMPUTER,
] as const;

const Tips = ({ items }: { items: TipItem[] }) => {
return (
// No transport layer (bridge/webUSB) is available
// On web it makes sense to
Expand All @@ -25,3 +33,19 @@ export const Transport = () => {
/>
);
};

const TransportDesktop = ({ items }: { items: TipItem[] }) => {
const isDebugModeActive = useSelector(selectIsDebugModeActive);
const { bridgeProcess } = useBridgeDesktopApi();

const itemsForDesktop = [...items];

if (isDebugModeActive && !bridgeProcess.process) {
itemsForDesktop.push(TROUBLESHOOTING_ENABLE_IN_DEBUG);
}

return <Tips items={itemsForDesktop} />;
};

export const Transport = () =>
isDesktop() ? <TransportDesktop items={tipItems} /> : <Tips items={tipItems} />;
43 changes: 32 additions & 11 deletions packages/suite/src/components/suite/troubleshooting/tips/index.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
import { ReactNode } from 'react';

import { isWeb, isDesktop, isLinux, isAndroid } from '@trezor/env-utils';
import { TREZOR_SUPPORT_DEVICE_URL } from '@trezor/urls';
import { Text } from '@trezor/components';

import { TrezorLink } from 'src/components/suite';
import { Translation } from 'src/components/suite/Translation';

import { BridgeStatus, SuiteDesktopTip, BridgeToggle, Wrapper } from './BridgeTip';
import { UdevDescription } from './UdevDescription';

export const TROUBLESHOOTING_TIP_BRIDGE_STATUS = {
export type TipItem = {
key: string;
heading: ReactNode;
description: ReactNode;
hide?: boolean;
};

export const TROUBLESHOOTING_TIP_BRIDGE_STATUS: TipItem = {
key: 'bridge-status',
heading: <Translation id="TR_TROUBLESHOOTING_TIP_BRIDGE_STATUS_TITLE" />,
description: <BridgeStatus />,
hide: !isWeb(),
};

export const TROUBLESHOOTING_TIP_WEBUSB_ENVIRONMENT = {
export const TROUBLESHOOTING_TIP_WEBUSB_ENVIRONMENT: TipItem = {
key: 'webusb-environment',
heading: <Translation id="TR_TROUBLESHOOTING_TIP_BROWSER_WEBUSB_TITLE" />,
description: <Translation id="TR_TROUBLESHOOTING_TIP_BROWSER_WEBUSB_DESCRIPTION" />,
hide: !isWeb(),
};

export const TROUBLESHOOTING_TIP_UNREADABLE_HID = {
export const TROUBLESHOOTING_TIP_UNREADABLE_HID: TipItem = {
key: 'unreadable-hid',
heading: <Translation id="TR_TROUBLESHOOTING_TIP_UNREADABLE_HID_TITLE" />,
description: (
Expand All @@ -40,53 +50,64 @@ export const TROUBLESHOOTING_TIP_UNREADABLE_HID = {
),
};

export const TROUBLESHOOTING_TIP_SUITE_DESKTOP = {
export const TROUBLESHOOTING_TIP_SUITE_DESKTOP: TipItem = {
key: 'suite-desktop',
heading: <Translation id="TR_TROUBLESHOOTING_TIP_SUITE_DESKTOP_TITLE" />,
description: <SuiteDesktopTip />,
hide: !isWeb(),
};

export const TROUBLESHOOTING_TIP_SUITE_DESKTOP_TOGGLE_BRIDGE = {
export const TROUBLESHOOTING_TIP_SUITE_DESKTOP_TOGGLE_BRIDGE: TipItem = {
key: 'suite-desktop',
heading: <Translation id="TR_TROUBLESHOOTING_TIP_SUITE_DESKTOP_TOGGLE_BRIDGE_TITLE" />,
description: <BridgeToggle />,
hide: isWeb() || isAndroid(),
};

export const TROUBLESHOOTING_TIP_CABLE = {
export const TROUBLESHOOTING_TIP_CABLE: TipItem = {
key: 'cable',
heading: <Translation id="TR_TROUBLESHOOTING_TIP_CABLE_TITLE" />,
description: <Translation id="TR_TROUBLESHOOTING_TIP_CABLE_DESCRIPTION" />,
};

export const TROUBLESHOOTING_TIP_USB = {
export const TROUBLESHOOTING_TIP_USB: TipItem = {
key: 'usbPort',
heading: <Translation id="TR_TROUBLESHOOTING_TIP_USB_PORT_TITLE" />,
description: <Translation id="TR_TROUBLESHOOTING_TIP_USB_PORT_DESCRIPTION" />,
hide: isAndroid(),
};

export const TROUBLESHOOTING_TIP_DIFFERENT_COMPUTER = {
export const TROUBLESHOOTING_TIP_DIFFERENT_COMPUTER: TipItem = {
key: 'differentComputer',
heading: <Translation id="TR_TROUBLESHOOTING_TIP_COMPUTER_TITLE" />,
description: <Translation id="TR_TROUBLESHOOTING_TIP_COMPUTER_DESCRIPTION" />,
};

export const TROUBLESHOOTING_TIP_RESTART_COMPUTER = {
export const TROUBLESHOOTING_TIP_RESTART_COMPUTER: TipItem = {
key: 'restartComputer',
heading: <Translation id="TR_TROUBLESHOOTING_TIP_RESTART_COMPUTER_TITLE" />,
description: <Translation id="TR_TROUBLESHOOTING_TIP_RESTART_COMPUTER_DESCRIPTION" />,
};

export const TROUBLESHOOTING_TIP_UDEV = {
export const TROUBLESHOOTING_ENABLE_IN_DEBUG: TipItem = {
key: 'enableInDebug',
heading: (
<>
You may have <Text variant="destructive">disabled bridge in the debug</Text> settings.
</>
),
description: <>Try to enable it. You know, ... with the switch.</>,
hide: isWeb(),
};

export const TROUBLESHOOTING_TIP_UDEV: TipItem = {
key: 'udev',
heading: <Translation id="TR_UDEV_DOWNLOAD_TITLE" />,
description: <UdevDescription />,
hide: !isLinux(),
};

export const TROUBLESHOOTING_TIP_RECONNECT = {
export const TROUBLESHOOTING_TIP_RECONNECT: TipItem = {
key: 'device-reconnect',
heading: <Translation id="TR_RECONNECT_YOUR_DEVICE" />,
description: (
Expand Down
Loading