Skip to content

Commit 2523101

Browse files
committed
firmware: consolidate back/next button props
This reduces duplicate code and fixes "Back" not being translated on the last step.
1 parent 56dbf57 commit 2523101

File tree

4 files changed

+23
-65
lines changed

4 files changed

+23
-65
lines changed

src/firmware/dfuWindowsDriverInstallDialog/DfuWindowsDriverInstallDialog.tsx

Lines changed: 11 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -358,66 +358,23 @@ const DfuWindowsDriverInstallDialog: React.VoidFunctionComponent = () => {
358358
className="pb-dfu-windows-driver-install-dialog"
359359
isOpen={isOpen}
360360
onClose={() => dispatch(firmwareDfuWindowsDriverInstallDialogDialogHide())}
361+
backButtonProps={{ text: i18n.translate('backButton.label') }}
362+
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
361363
finalButtonProps={{
362364
text: i18n.translate('doneButton.label'),
363365
onClick: () =>
364366
dispatch(firmwareDfuWindowsDriverInstallDialogDialogHide()),
365367
}}
366368
>
367-
<DialogStep
368-
id="1"
369-
panel={<Step1 />}
370-
backButtonProps={{ text: i18n.translate('backButton.label') }}
371-
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
372-
/>
373-
<DialogStep
374-
id="2"
375-
panel={<Step2 hub={hub} />}
376-
backButtonProps={{ text: i18n.translate('backButton.label') }}
377-
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
378-
/>
379-
<DialogStep
380-
id="3"
381-
panel={<Step3 hub={hub} />}
382-
backButtonProps={{ text: i18n.translate('backButton.label') }}
383-
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
384-
/>
385-
<DialogStep
386-
id="4"
387-
panel={<Step4 hub={hub} />}
388-
backButtonProps={{ text: i18n.translate('backButton.label') }}
389-
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
390-
/>
391-
<DialogStep
392-
id="5"
393-
panel={<Step5 hub={hub} />}
394-
backButtonProps={{ text: i18n.translate('backButton.label') }}
395-
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
396-
/>
397-
<DialogStep
398-
id="6"
399-
panel={<Step6 hub={hub} />}
400-
backButtonProps={{ text: i18n.translate('backButton.label') }}
401-
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
402-
/>
403-
<DialogStep
404-
id="7"
405-
panel={<Step7 hub={hub} />}
406-
backButtonProps={{ text: i18n.translate('backButton.label') }}
407-
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
408-
/>
409-
<DialogStep
410-
id="8"
411-
panel={<Step8 />}
412-
backButtonProps={{ text: i18n.translate('backButton.label') }}
413-
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
414-
/>
415-
<DialogStep
416-
id="9"
417-
panel={<Step9 hub={hub} />}
418-
backButtonProps={{ text: i18n.translate('backButton.label') }}
419-
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
420-
/>
369+
<DialogStep id="1" panel={<Step1 />} />
370+
<DialogStep id="2" panel={<Step2 hub={hub} />} />
371+
<DialogStep id="3" panel={<Step3 hub={hub} />} />
372+
<DialogStep id="4" panel={<Step4 hub={hub} />} />
373+
<DialogStep id="5" panel={<Step5 hub={hub} />} />
374+
<DialogStep id="6" panel={<Step6 hub={hub} />} />
375+
<DialogStep id="7" panel={<Step7 hub={hub} />} />
376+
<DialogStep id="8" panel={<Step8 />} />
377+
<DialogStep id="9" panel={<Step9 hub={hub} />} />
421378
</MultistepDialog>
422379
);
423380
};

src/firmware/installPybricksDialog/InstallPybricksDialog.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ export const InstallPybricksDialog: React.VoidFunctionComponent = () => {
461461
title={i18n.translate('title')}
462462
isOpen={isOpen}
463463
onClose={() => dispatch(firmwareInstallPybricksDialogCancel())}
464+
backButtonProps={{ text: i18n.translate('backButton.label') }}
465+
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
464466
finalButtonProps={{
465467
text: i18n.translate('flashFirmwareButton.label'),
466468
onClick: () =>
@@ -482,7 +484,6 @@ export const InstallPybricksDialog: React.VoidFunctionComponent = () => {
482484
onCustomFirmwareZip={setCustomFirmwareZip}
483485
/>
484486
}
485-
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
486487
/>
487488
<DialogStep
488489
id="license"
@@ -495,7 +496,6 @@ export const InstallPybricksDialog: React.VoidFunctionComponent = () => {
495496
onLicenseAcceptedChanged={setLicenseAccepted}
496497
/>
497498
}
498-
backButtonProps={{ text: i18n.translate('backButton.label') }}
499499
nextButtonProps={{
500500
disabled: !licenseAccepted,
501501
text: i18n.translate('nextButton.label'),
@@ -510,14 +510,11 @@ export const InstallPybricksDialog: React.VoidFunctionComponent = () => {
510510
onChangeHubName={setHubName}
511511
/>
512512
}
513-
backButtonProps={{ text: i18n.translate('backButton.label') }}
514-
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
515513
/>
516514
<DialogStep
517515
id="bootloader"
518516
title={i18n.translate('bootloaderPanel.title')}
519517
panel={<BootloaderModePanel hubType={selectedHubType} />}
520-
backButtonProps={{ text: i18n.translate('backButton.label') }}
521518
/>
522519
</MultistepDialog>
523520
);

src/firmware/restoreOfficialDialog/RestoreOfficialDialog.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ const SelectHubPanel: React.VoidFunctionComponent = () => {
3333
<p>
3434
{i18n.translate('selectHubPanel.message', {
3535
lego: legoRegisteredTrademark,
36-
next: (
37-
<strong>{i18n.translate('selectHubPanel.nextButton')}</strong>
38-
),
36+
next: <strong>{i18n.translate('nextButton.label')}</strong>,
3937
})}
4038
</p>
4139
<div className="pb-spacer" />
@@ -96,6 +94,8 @@ const RestoreOfficialDialog: React.VoidFunctionComponent = () => {
9694
isOpen={isOpen}
9795
title={i18n.translate('title', { lego: legoRegisteredTrademark })}
9896
onClose={() => dispatch(firmwareRestoreOfficialDialogHide())}
97+
backButtonProps={{ text: i18n.translate('backButton.label') }}
98+
nextButtonProps={{ text: i18n.translate('nextButton.label') }}
9999
finalButtonProps={{
100100
text: i18n.translate('doneButton.label'),
101101
onClick: () => dispatch(firmwareRestoreOfficialDialogHide()),
@@ -105,7 +105,6 @@ const RestoreOfficialDialog: React.VoidFunctionComponent = () => {
105105
id="hub"
106106
title={i18n.translate('selectHubPanel.title')}
107107
panel={<SelectHubPanel />}
108-
nextButtonProps={{ text: i18n.translate('selectHubPanel.nextButton') }}
109108
/>
110109
<DialogStep
111110
id="restore"

src/firmware/restoreOfficialDialog/translations/en.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
{
22
"title": "Restore official {lego} Firmware",
3+
"backButton": {
4+
"label": "Back"
5+
},
6+
"nextButton": {
7+
"label": "Next"
8+
},
39
"doneButton": {
410
"label": "Done"
511
},
612
"selectHubPanel": {
713
"title": "Select hub",
8-
"message": "Select the hub to restore the official {lego} firmware on, then click {next}.",
9-
"nextButton": "Next"
14+
"message": "Select the hub to restore the official {lego} firmware on, then click {next}."
1015
},
1116
"restoreFirmwarePanel": {
1217
"title": "Restore firmware",

0 commit comments

Comments
 (0)