@@ -3,7 +3,7 @@ import { Typography } from '@/components/commons/Typography';
33import { QueryClient , QueryClientProvider } from '@tanstack/react-query' ;
44import {
55 FirmwareToolContextC ,
6- provideFirmwareTool ,
6+ useFirmwareToolContext ,
77} from '@/hooks/firmware-tool' ;
88import { AddImusStep } from './AddImusStep' ;
99import { SelectBoardStep } from './SelectBoardStep' ;
@@ -15,87 +15,63 @@ 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' ;
1820import { 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' ;
2521
2622function FirmwareToolContent ( ) {
2723 const { l10n } = useLocalization ( ) ;
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 ) ;
24+ const context = useFirmwareToolContext ( ) ;
25+ const { isError, isGlobalLoading : isLoading , retry, isCompatible } = context ;
4026
4127 const steps = useMemo ( ( ) => {
4228 const steps = [
4329 {
44- id : 'SelectSource' ,
45- component : SelectSourceSetep ,
46- title : l10n . getString ( 'firmware_tool-step-select_source' ) ,
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' ) ,
4737 } ,
4838 {
49- component : BoardDefaultsStep ,
50- title : l10n . getString ( 'firmware_tool-step-board_defaults' ) ,
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' ) ,
5159 } ,
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- // },
7860 ] ;
7961
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- // }
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+ }
9173 return steps ;
92- } , [
93- /* context.defaultConfig?.needBootPress, context.selectedDevices */ l10n ,
94- ] ) ;
95-
96- const retry = async ( ) => {
97- await refetch ( ) ;
98- } ;
74+ } , [ context . defaultConfig ?. needBootPress , context . selectedDevices , l10n ] ) ;
9975
10076 return (
10177 < FirmwareToolContextC . Provider value = { context } >
0 commit comments