From 6584cef77420b4892b6ff5d6faa57a5e464a01ca Mon Sep 17 00:00:00 2001 From: Lorenzo Alberto Maria Ambrosi Date: Mon, 24 Aug 2020 14:14:39 +0200 Subject: [PATCH] Add retry button to the errors modal in success screen Change-type: patch Signed-off-by: Lorenzo Alberto Maria Ambrosi --- lib/gui/app/components/finish/finish.tsx | 6 +- .../flash-results/flash-results.tsx | 59 ++++++++++++++----- lib/gui/app/models/store.ts | 10 ++-- 3 files changed, 54 insertions(+), 21 deletions(-) diff --git a/lib/gui/app/components/finish/finish.tsx b/lib/gui/app/components/finish/finish.tsx index e5c3a9aa..e8018627 100644 --- a/lib/gui/app/components/finish/finish.tsx +++ b/lib/gui/app/components/finish/finish.tsx @@ -41,7 +41,8 @@ function restart(goToMain: () => void) { function FinishPage({ goToMain }: { goToMain: () => void }) { const [webviewShowing, setWebviewShowing] = React.useState(false); - let errors = flashState.getFlashResults().results?.errors; + const flashResults = flashState.getFlashResults(); + let errors = flashResults?.results?.errors; if (errors === undefined) { errors = (store.getState().toJS().failedDevicePaths || []).map( ([, error]: [string, FlashError]) => ({ @@ -67,7 +68,7 @@ function FinishPage({ goToMain }: { goToMain: () => void }) { averageFlashingSpeed: averageSpeed, devices: { failed, successful: 0 }, }, - } = flashState.getFlashResults(); + } = flashResults; return ( void }) { skip={skip} errors={errors} mb="32px" + goToMain={goToMain} /> { } `; +const DoneIcon = (props: { allFailed: boolean; someFailed: boolean }) => { + const { allFailed, someFailed } = props; + const someOrAllFailed = allFailed || someFailed; + const svgProps = { + width: '24px', + fill: someOrAllFailed ? '#c6c8c9' : '#1ac135', + style: { + width: '28px', + height: '28px', + marginTop: '-25px', + marginLeft: '13px', + zIndex: 1, + color: someOrAllFailed ? '#c6c8c9' : '#1ac135', + }, + }; + return allFailed ? ( + + ) : ( + + ); +}; + export interface FlashError extends Error { description: string; device: string; @@ -88,12 +113,14 @@ const columns: Array> = [ ]; export function FlashResults({ + goToMain, image = '', errors, results, skip, ...props }: { + goToMain: () => void; image?: string; errors: FlashError[]; skip: boolean; @@ -108,7 +135,7 @@ export function FlashResults({ }; } & FlexProps) { const [showErrorsInfo, setShowErrorsInfo] = React.useState(false); - const allDevicesFailed = results.devices.successful === 0; + const allFailed = results.devices.successful === 0; const effectiveSpeed = _.round( bytesToMegabytes( results.sourceMetadata.size / @@ -127,17 +154,9 @@ export function FlashResults({ flexDirection="column" > - {middleEllipsis(image, 16)} @@ -173,7 +192,7 @@ export function FlashResults({ ) : null; })} - {!allDevicesFailed && ( + {!allFailed && ( } - done={() => setShowErrorsInfo(false)} + action="Retry failed targets" + cancel={() => setShowErrorsInfo(false)} + done={() => { + setShowErrorsInfo(false); + resetState(); + selection + .getSelectedDrives() + .filter((drive) => + errors.every((error) => error.device !== drive.device), + ) + .forEach((drive) => selection.deselectDrive(drive.device)); + goToMain(); + }} > diff --git a/lib/gui/app/models/store.ts b/lib/gui/app/models/store.ts index b9301d7c..17373af6 100644 --- a/lib/gui/app/models/store.ts +++ b/lib/gui/app/models/store.ts @@ -334,12 +334,12 @@ function storeReducer( action.data.results.averageFlashingSpeed = state.get( 'lastAverageFlashingSpeed', ); + } - if (action.data.results.skip) { - return state - .set('isFlashing', false) - .set('flashResults', Immutable.fromJS(action.data)); - } + if (action.data.skip) { + return state + .set('isFlashing', false) + .set('flashResults', Immutable.fromJS(action.data)); } return state