// SPDX-License-Identifier: MIT // Copyright (c) 2022 The Pybricks Authors import { Callout, Intent } from '@blueprintjs/core'; import React, { useMemo } from 'react'; import { pybricksUsbDfuWindowsDriverInstallUrl, pybricksUsbLinuxUdevRulesUrl, } from '../../app/constants'; import { Hub, hubHasBluetoothButton, hubHasUSB } from '../../components/hubPicker'; import ExternalLinkIcon from '../../utils/ExternalLinkIcon'; import { isLinux, isWindows } from '../../utils/os'; import { useI18n } from './i18n'; type BootloaderInstructionsProps = { hubType: Hub; }; /** * Provides customized instructions on how to enter bootloader mode based * on the hub type. */ const BootloaderInstructions: React.VoidFunctionComponent< BootloaderInstructionsProps > = ({ hubType }) => { const i18n = useI18n(); const { button, light, lightPattern } = useMemo(() => { return { button: i18n.translate( hubHasBluetoothButton(hubType) ? 'button.bluetooth' : 'button.power', ), light: i18n.translate( hubHasBluetoothButton(hubType) ? 'light.bluetooth' : 'light.status', ), lightPattern: i18n.translate( hubHasBluetoothButton(hubType) ? 'lightPattern.bluetooth' : 'lightPattern.status', ), }; }, [i18n, hubType]); return ( <> {hubHasUSB(hubType) && isLinux() && ( {i18n.translate('warning.linux')}{' '} {i18n.translate('warning.learnMore')} )} {hubHasUSB(hubType) && isWindows() && ( {i18n.translate('warning.windows')}{' '} {i18n.translate('warning.learnMore')} )}

{i18n.translate('instruction')}

    {hubHasUSB(hubType) &&
  1. {i18n.translate('step.disconnectUsb')}
  2. }
  3. {i18n.translate('step.powerOff')}
  4. {/* City hub has power issues and requires disconnecting motors/sensors */} {hubType === Hub.City &&
  5. {i18n.translate('step.disconnectIo')}
  6. }
  7. {i18n.translate('step.holdButton', { button })}
  8. {hubHasUSB(hubType) &&
  9. {i18n.translate('step.connectUsb')}
  10. }
  11. {i18n.translate('step.waitForLight', { button, light, lightPattern, })}
  12. {i18n.translate( /* hubs with USB will keep the power on, but other hubs won't */ hubHasUSB(hubType) ? 'step.releaseButton' : 'step.keepHolding', { button, }, )}
); }; export default BootloaderInstructions;