@@ -3,7 +3,7 @@ import { Typography } from '@/components/commons/Typography';
33import { QueryClient , QueryClientProvider } from '@tanstack/react-query' ;
44import {
55 FirmwareToolContextC ,
6- useFirmwareToolContext ,
6+ provideFirmwareTool ,
77} from '@/hooks/firmware-tool' ;
88import { AddImusStep } from './AddImusStep' ;
99import { SelectBoardStep } from './SelectBoardStep' ;
@@ -15,63 +15,87 @@ import { SelectFirmwareStep } from './SelectFirmwareStep';
1515import { BuildStep } from './BuildStep' ;
1616import { FlashingMethodStep } from './FlashingMethodStep' ;
1717import { FlashingStep } from './FlashingStep' ;
18- import { FlashBtnStep } from './FlashBtnStep' ;
19- import { FirmwareUpdateMethod } from 'solarxr-protocol' ;
2018import { useMemo } from 'react' ;
19+ import {
20+ useGetHealth ,
21+ useGetIsCompatibleVersion ,
22+ } from '@/firmware-tool-api/firmwareToolComponents' ;
23+ import { SelectSourceSetep } from './steps/SelectSourceStep' ;
24+ import { BoardDefaultsStep } from './steps/BoardDefaultsStep' ;
2125
2226function FirmwareToolContent ( ) {
2327 const { l10n } = useLocalization ( ) ;
24- const context = useFirmwareToolContext ( ) ;
25- const { isError, isGlobalLoading : isLoading , retry, isCompatible } = context ;
28+ const context = provideFirmwareTool ( ) ;
29+ const { isError, isLoading : isInitialLoading , refetch } = useGetHealth ( { } ) ;
30+ const compatibilityCheckEnabled = ! ! __VERSION_TAG__ ;
31+ const { isLoading : isCompatibilityLoading , data : compatibilityData } =
32+ useGetIsCompatibleVersion (
33+ { pathParams : { version : __VERSION_TAG__ } } ,
34+ { enabled : compatibilityCheckEnabled }
35+ ) ;
36+
37+ const isLoading = isInitialLoading || isCompatibilityLoading ;
38+ const isCompatible =
39+ ! compatibilityCheckEnabled || ( compatibilityData ?. success ?? false ) ;
2640
2741 const steps = useMemo ( ( ) => {
2842 const steps = [
2943 {
30- id : 'SelectBoard' ,
31- component : SelectBoardStep ,
32- title : l10n . getString ( 'firmware_tool-board_step' ) ,
33- } ,
34- {
35- component : BoardPinsStep ,
36- title : l10n . getString ( 'firmware_tool-board_pins_step' ) ,
44+ id : 'SelectSource' ,
45+ component : SelectSourceSetep ,
46+ title : l10n . getString ( 'firmware_tool-step-select_source' ) ,
3747 } ,
3848 {
39- component : AddImusStep ,
40- title : l10n . getString ( 'firmware_tool-add_imus_step' ) ,
41- } ,
42- {
43- id : 'SelectFirmware' ,
44- component : SelectFirmwareStep ,
45- title : l10n . getString ( 'firmware_tool-select_firmware_step' ) ,
46- } ,
47- {
48- component : FlashingMethodStep ,
49- id : 'FlashingMethod' ,
50- title : l10n . getString ( 'firmware_tool-flash_method_step' ) ,
51- } ,
52- {
53- component : BuildStep ,
54- title : l10n . getString ( 'firmware_tool-build_step' ) ,
55- } ,
56- {
57- component : FlashingStep ,
58- title : l10n . getString ( 'firmware_tool-flashing_step' ) ,
49+ component : BoardDefaultsStep ,
50+ title : l10n . getString ( 'firmware_tool-step-board_defaults' ) ,
5951 } ,
52+ // {
53+ // component: BoardPinsStep,
54+ // title: l10n.getString('firmware_tool-board_pins_step'),
55+ // },
56+ // {
57+ // component: AddImusStep,
58+ // title: l10n.getString('firmware_tool-add_imus_step'),
59+ // },
60+ // {
61+ // id: 'SelectFirmware',
62+ // component: SelectFirmwareStep,
63+ // title: l10n.getString('firmware_tool-select_firmware_step'),
64+ // },
65+ // {
66+ // component: FlashingMethodStep,
67+ // id: 'FlashingMethod',
68+ // title: l10n.getString('firmware_tool-flash_method_step'),
69+ // },
70+ // {
71+ // component: BuildStep,
72+ // title: l10n.getString('firmware_tool-build_step'),
73+ // },
74+ // {
75+ // component: FlashingStep,
76+ // title: l10n.getString('firmware_tool-flashing_step'),
77+ // },
6078 ] ;
6179
62- if (
63- context . defaultConfig ?. needBootPress &&
64- context . selectedDevices ?. find (
65- ( { type } ) => type === FirmwareUpdateMethod . SerialFirmwareUpdate
66- )
67- ) {
68- steps . splice ( 5 , 0 , {
69- component : FlashBtnStep ,
70- title : l10n . getString ( 'firmware_tool-flashbtn_step' ) ,
71- } ) ;
72- }
80+ // if (
81+ // context.defaultConfig?.needBootPress &&
82+ // context.selectedDevices?.find(
83+ // ({ type }) => type === FirmwareUpdateMethod.SerialFirmwareUpdate
84+ // )
85+ // ) {
86+ // steps.splice(5, 0, {
87+ // component: FlashBtnStep,
88+ // title: l10n.getString('firmware_tool-flashbtn_step'),
89+ // });
90+ // }
7391 return steps ;
74- } , [ context . defaultConfig ?. needBootPress , context . selectedDevices , l10n ] ) ;
92+ } , [
93+ /* context.defaultConfig?.needBootPress, context.selectedDevices */ l10n ,
94+ ] ) ;
95+
96+ const retry = async ( ) => {
97+ await refetch ( ) ;
98+ } ;
7599
76100 return (
77101 < FirmwareToolContextC . Provider value = { context } >
0 commit comments