From 25231012f6ee497d3103561ee7dc756df2bbfc44 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Tue, 20 Dec 2022 12:28:06 -0600 Subject: [PATCH] firmware: consolidate back/next button props This reduces duplicate code and fixes "Back" not being translated on the last step. --- .../DfuWindowsDriverInstallDialog.tsx | 65 ++++--------------- .../InstallPybricksDialog.tsx | 7 +- .../RestoreOfficialDialog.tsx | 7 +- .../translations/en.json | 9 ++- 4 files changed, 23 insertions(+), 65 deletions(-) diff --git a/src/firmware/dfuWindowsDriverInstallDialog/DfuWindowsDriverInstallDialog.tsx b/src/firmware/dfuWindowsDriverInstallDialog/DfuWindowsDriverInstallDialog.tsx index 5ab158fd..ab9c0886 100644 --- a/src/firmware/dfuWindowsDriverInstallDialog/DfuWindowsDriverInstallDialog.tsx +++ b/src/firmware/dfuWindowsDriverInstallDialog/DfuWindowsDriverInstallDialog.tsx @@ -358,66 +358,23 @@ const DfuWindowsDriverInstallDialog: React.VoidFunctionComponent = () => { className="pb-dfu-windows-driver-install-dialog" isOpen={isOpen} onClose={() => dispatch(firmwareDfuWindowsDriverInstallDialogDialogHide())} + backButtonProps={{ text: i18n.translate('backButton.label') }} + nextButtonProps={{ text: i18n.translate('nextButton.label') }} finalButtonProps={{ text: i18n.translate('doneButton.label'), onClick: () => dispatch(firmwareDfuWindowsDriverInstallDialogDialogHide()), }} > - } - backButtonProps={{ text: i18n.translate('backButton.label') }} - nextButtonProps={{ text: i18n.translate('nextButton.label') }} - /> - } - backButtonProps={{ text: i18n.translate('backButton.label') }} - nextButtonProps={{ text: i18n.translate('nextButton.label') }} - /> - } - backButtonProps={{ text: i18n.translate('backButton.label') }} - nextButtonProps={{ text: i18n.translate('nextButton.label') }} - /> - } - backButtonProps={{ text: i18n.translate('backButton.label') }} - nextButtonProps={{ text: i18n.translate('nextButton.label') }} - /> - } - backButtonProps={{ text: i18n.translate('backButton.label') }} - nextButtonProps={{ text: i18n.translate('nextButton.label') }} - /> - } - backButtonProps={{ text: i18n.translate('backButton.label') }} - nextButtonProps={{ text: i18n.translate('nextButton.label') }} - /> - } - backButtonProps={{ text: i18n.translate('backButton.label') }} - nextButtonProps={{ text: i18n.translate('nextButton.label') }} - /> - } - backButtonProps={{ text: i18n.translate('backButton.label') }} - nextButtonProps={{ text: i18n.translate('nextButton.label') }} - /> - } - backButtonProps={{ text: i18n.translate('backButton.label') }} - nextButtonProps={{ text: i18n.translate('nextButton.label') }} - /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> ); }; diff --git a/src/firmware/installPybricksDialog/InstallPybricksDialog.tsx b/src/firmware/installPybricksDialog/InstallPybricksDialog.tsx index 27f124ad..3f0cec69 100644 --- a/src/firmware/installPybricksDialog/InstallPybricksDialog.tsx +++ b/src/firmware/installPybricksDialog/InstallPybricksDialog.tsx @@ -461,6 +461,8 @@ export const InstallPybricksDialog: React.VoidFunctionComponent = () => { title={i18n.translate('title')} isOpen={isOpen} onClose={() => dispatch(firmwareInstallPybricksDialogCancel())} + backButtonProps={{ text: i18n.translate('backButton.label') }} + nextButtonProps={{ text: i18n.translate('nextButton.label') }} finalButtonProps={{ text: i18n.translate('flashFirmwareButton.label'), onClick: () => @@ -482,7 +484,6 @@ export const InstallPybricksDialog: React.VoidFunctionComponent = () => { onCustomFirmwareZip={setCustomFirmwareZip} /> } - nextButtonProps={{ text: i18n.translate('nextButton.label') }} /> { onLicenseAcceptedChanged={setLicenseAccepted} /> } - backButtonProps={{ text: i18n.translate('backButton.label') }} nextButtonProps={{ disabled: !licenseAccepted, text: i18n.translate('nextButton.label'), @@ -510,14 +510,11 @@ export const InstallPybricksDialog: React.VoidFunctionComponent = () => { onChangeHubName={setHubName} /> } - backButtonProps={{ text: i18n.translate('backButton.label') }} - nextButtonProps={{ text: i18n.translate('nextButton.label') }} /> } - backButtonProps={{ text: i18n.translate('backButton.label') }} /> ); diff --git a/src/firmware/restoreOfficialDialog/RestoreOfficialDialog.tsx b/src/firmware/restoreOfficialDialog/RestoreOfficialDialog.tsx index 7f9c5bce..98f2bdc4 100644 --- a/src/firmware/restoreOfficialDialog/RestoreOfficialDialog.tsx +++ b/src/firmware/restoreOfficialDialog/RestoreOfficialDialog.tsx @@ -33,9 +33,7 @@ const SelectHubPanel: React.VoidFunctionComponent = () => {

{i18n.translate('selectHubPanel.message', { lego: legoRegisteredTrademark, - next: ( - {i18n.translate('selectHubPanel.nextButton')} - ), + next: {i18n.translate('nextButton.label')}, })}

@@ -96,6 +94,8 @@ const RestoreOfficialDialog: React.VoidFunctionComponent = () => { isOpen={isOpen} title={i18n.translate('title', { lego: legoRegisteredTrademark })} onClose={() => dispatch(firmwareRestoreOfficialDialogHide())} + backButtonProps={{ text: i18n.translate('backButton.label') }} + nextButtonProps={{ text: i18n.translate('nextButton.label') }} finalButtonProps={{ text: i18n.translate('doneButton.label'), onClick: () => dispatch(firmwareRestoreOfficialDialogHide()), @@ -105,7 +105,6 @@ const RestoreOfficialDialog: React.VoidFunctionComponent = () => { id="hub" title={i18n.translate('selectHubPanel.title')} panel={} - nextButtonProps={{ text: i18n.translate('selectHubPanel.nextButton') }} />