You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-wallet/src/views/Landing/views/Root/index.js

58 lines
2.2 KiB

/* @flow */
import React from 'react';
import { isWebUSB } from 'utils/device';
import LandingWrapper from 'views/Landing/components/LandingWrapper';
import BetaDisclaimer from 'views/Landing/components/BetaDisclaimer';
import BrowserNotSupported from 'views/Landing/components/BrowserNotSupported';
import ConnectDevice from 'views/Landing/components/ConnectDevice';
import InstallBridge from 'views/Landing/views/InstallBridge/Container';
import type { Props } from './Container';
const Root = (props: Props) => {
const { initialized, browserState, transport } = props.connect;
const { disconnectRequest } = props.wallet;
const localStorageError = props.localStorage.error;
const connectError = props.connect.error;
if (props.wallet.showBetaDisclaimer) return <BetaDisclaimer />;
const error = !initialized ? localStorageError || connectError : null;
const shouldShowUnsupportedBrowser = browserState.supported === false;
const shouldShowInstallBridge = initialized && connectError;
const shouldShowConnectDevice = props.wallet.ready && props.devices.length < 1;
const shouldShowDisconnectDevice = !!disconnectRequest;
const isLoading =
!error &&
!shouldShowConnectDevice &&
!shouldShowUnsupportedBrowser;
console.log('props', props)
console.log('isLoading', isLoading);
console.log('error', error);
console.log('shouldShowConnectDevice', shouldShowConnectDevice);
console.log('shouldShowUnsupportedBrowser', shouldShowConnectDevice);
const deviceLabel = disconnectRequest ? disconnectRequest.label : '';
// corner case: display InstallBridge view on "/" route
// it has it's own Container and props
if (shouldShowInstallBridge) return <InstallBridge />;
return (
<LandingWrapper loading={isLoading} error={error}>
{shouldShowUnsupportedBrowser && <BrowserNotSupported />}
{(shouldShowConnectDevice || shouldShowDisconnectDevice) && (
<ConnectDevice
deviceLabel={deviceLabel}
showWebUsb={isWebUSB(transport)}
showDisconnect={shouldShowDisconnectDevice}
/>
)}
</LandingWrapper>
);
};
export default Root;