11// SPDX-License-Identifier: MIT
22// Copyright (c) 2022 The Pybricks Authors
33
4- import { AnchorButton , Intent } from '@blueprintjs/core' ;
4+ import { AnchorButton , Button , Intent } from '@blueprintjs/core' ;
55import React from 'react' ;
66import { pybricksUsbDfuTroubleshootingUrl } from '../../app/constants' ;
77import ExternalLinkIcon from '../../components/ExternalLinkIcon' ;
88import type { CreateToast } from '../../toasterTypes' ;
99import { isLinux , isWindows } from '../../utils/os' ;
1010import { useI18n } from './i18n' ;
1111
12- const NoDfuHub : React . VoidFunctionComponent = ( ) => {
12+ type NoDfuHubProps = {
13+ onInstallWindowsDriver : ( ) => void ;
14+ } ;
15+
16+ const NoDfuHub : React . VoidFunctionComponent < NoDfuHubProps > = ( {
17+ onInstallWindowsDriver,
18+ } ) => {
1319 const i18n = useI18n ( ) ;
1420
1521 return (
@@ -18,23 +24,31 @@ const NoDfuHub: React.VoidFunctionComponent = () => {
1824
1925 { isWindows ( ) && < p > { i18n . translate ( 'noDfuHub.suggestion1.windows' ) } </ p > }
2026 { isLinux ( ) && < p > { i18n . translate ( 'noDfuHub.suggestion1.linux' ) } </ p > }
21-
22- < p > { i18n . translate ( 'noDfuHub.suggestion2' ) } </ p >
23-
24- < AnchorButton
25- icon = "help"
26- href = { pybricksUsbDfuTroubleshootingUrl }
27- target = "_blank"
28- >
29- { i18n . translate ( 'noDfuHub.troubleshootButton' ) }
30- < ExternalLinkIcon />
31- </ AnchorButton >
27+ < div className = "pb-ble-alerts-buttons" >
28+ { isWindows ( ) && (
29+ < Button icon = "download" onClick = { onInstallWindowsDriver } >
30+ { i18n . translate ( 'noDfuHub.installUsbDriverButton' ) }
31+ </ Button >
32+ ) }
33+ < AnchorButton
34+ icon = "help"
35+ href = { pybricksUsbDfuTroubleshootingUrl }
36+ target = "_blank"
37+ >
38+ { i18n . translate ( 'noDfuHub.troubleshootButton' ) }
39+ < ExternalLinkIcon />
40+ </ AnchorButton >
41+ </ div >
3242 </ >
3343 ) ;
3444} ;
3545
36- export const noDfuHub : CreateToast = ( onAction ) => ( {
37- message : < NoDfuHub /> ,
46+ export const noDfuHub : CreateToast < never , 'dismiss' | 'installWindowsDriver' > = (
47+ onAction ,
48+ ) => ( {
49+ message : (
50+ < NoDfuHub onInstallWindowsDriver = { ( ) => onAction ( 'installWindowsDriver' ) } />
51+ ) ,
3852 icon : 'info-sign' ,
3953 intent : Intent . PRIMARY ,
4054 onDismiss : ( ) => onAction ( 'dismiss' ) ,
0 commit comments