Add retry button to the errors modal in success screen

Change-type: patch
Signed-off-by: Lorenzo Alberto Maria Ambrosi <lorenzothunder.ambrosi@gmail.com>
This commit is contained in:
Lorenzo Alberto Maria Ambrosi 2020-08-24 14:14:39 +02:00
parent e484ae9837
commit 611e659626
4 changed files with 36 additions and 38 deletions

View File

@ -65,7 +65,7 @@ function FinishPage({ goToMain }: { goToMain: () => void }) {
averageFlashingSpeed: averageSpeed, averageFlashingSpeed: averageSpeed,
devices: { failed, successful: 0 }, devices: { failed, successful: 0 },
}, },
} = flashState.getFlashResults(); } = flashResults;
return ( return (
<Flex height="100%" justifyContent="space-between"> <Flex height="100%" justifyContent="space-between">
<Flex <Flex
@ -87,6 +87,7 @@ function FinishPage({ goToMain }: { goToMain: () => void }) {
skip={skip} skip={skip}
errors={errors} errors={errors}
mb="32px" mb="32px"
goToMain={goToMain}
/> />
<FlashAnother <FlashAnother

View File

@ -16,6 +16,7 @@
import CircleSvg from '@fortawesome/fontawesome-free/svgs/solid/circle.svg'; import CircleSvg from '@fortawesome/fontawesome-free/svgs/solid/circle.svg';
import CheckCircleSvg from '@fortawesome/fontawesome-free/svgs/solid/check-circle.svg'; import CheckCircleSvg from '@fortawesome/fontawesome-free/svgs/solid/check-circle.svg';
import TimesCircleSvg from '@fortawesome/fontawesome-free/svgs/solid/times-circle.svg';
import * as _ from 'lodash'; import * as _ from 'lodash';
import outdent from 'outdent'; import outdent from 'outdent';
import * as React from 'react'; import * as React from 'react';
@ -32,32 +33,25 @@ import * as selection from '../../models/selection-state';
import { middleEllipsis } from '../../utils/middle-ellipsis'; import { middleEllipsis } from '../../utils/middle-ellipsis';
import { Modal } from '../../styled-components'; import { Modal } from '../../styled-components';
const ErrorsTable = styled(({ refFn, ...props }) => { const ErrorsTable = styled((props) => <Table<FlashError> {...props} />)`
return ( &&& [data-display='table-head'],
<div> &&& [data-display='table-body'] {
<Table<FlashError> ref={refFn} {...props} /> > [data-display='table-row'] {
</div> > [data-display='table-cell'] {
); &:first-child {
})` width: 30%;
[data-display='table-head'] [data-display='table-cell'] { }
width: 50%;
position: sticky;
top: 0;
background-color: ${(props) => props.theme.colors.quartenary.light};
}
[data-display='table-cell']:first-child { &:nth-child(2) {
padding-left: 15px; width: 20%;
} }
[data-display='table-cell']:last-child { &:last-child {
width: 150px; width: 50%;
} }
}
&& [data-display='table-row'] > [data-display='table-cell'] {
padding: 6px 8px;
color: #2a506f;
} }
}
`; `;
const DoneIcon = (props: { const DoneIcon = (props: {
skipped: boolean; skipped: boolean;
@ -71,7 +65,6 @@ const DoneIcon = (props: {
marginTop: '-25px', marginTop: '-25px',
marginLeft: '13px', marginLeft: '13px',
zIndex: 1, zIndex: 1,
color: props.color,
}, },
}; };
return props.allFailed && !props.skipped ? ( return props.allFailed && !props.skipped ? (
@ -112,12 +105,14 @@ const columns: Array<TableColumn<FlashError>> = [
]; ];
export function FlashResults({ export function FlashResults({
goToMain,
image = '', image = '',
errors, errors,
results, results,
skip, skip,
...props ...props
}: { }: {
goToMain: () => void;
image?: string; image?: string;
errors: FlashError[]; errors: FlashError[];
skip: boolean; skip: boolean;
@ -167,7 +162,7 @@ export function FlashResults({
<Flex flexDirection="column" color="#7e8085"> <Flex flexDirection="column" color="#7e8085">
{results.devices.successful !== 0 ? ( {results.devices.successful !== 0 ? (
<Flex alignItems="center"> <Flex alignItems="center">
<CircleSvg width="14px" fill="#1ac135" color="#1ac135" /> <CircleSvg width="14px" fill="#1ac135" />
<Txt ml="10px" color="#fff"> <Txt ml="10px" color="#fff">
{results.devices.successful} {results.devices.successful}
</Txt> </Txt>
@ -178,7 +173,7 @@ export function FlashResults({
) : null} ) : null}
{errors.length !== 0 ? ( {errors.length !== 0 ? (
<Flex alignItems="center"> <Flex alignItems="center">
<CircleSvg width="14px" fill="#ff4444" color="#ff4444" /> <CircleSvg width="14px" fill="#ff4444" />
<Txt ml="10px" color="#fff"> <Txt ml="10px" color="#fff">
{errors.length} {errors.length}
</Txt> </Txt>
@ -222,10 +217,14 @@ export function FlashResults({
setShowErrorsInfo(false); setShowErrorsInfo(false);
resetState(); resetState();
getDrives() getDrives()
.filter((drive) => .map((drive) => {
errors.some((error) => error.device === drive.device), selection.deselectDrive(drive.device);
return drive.device;
})
.filter((driveDevice) =>
errors.some((error) => error.device === driveDevice),
) )
.forEach((drive) => selection.selectDrive(drive.device)); .forEach((driveDevice) => selection.selectDrive(driveDevice));
goToMain(); goToMain();
}} }}
> >

View File

@ -334,12 +334,12 @@ function storeReducer(
action.data.results.averageFlashingSpeed = state.get( action.data.results.averageFlashingSpeed = state.get(
'lastAverageFlashingSpeed', 'lastAverageFlashingSpeed',
); );
}
if (action.data.results.skip) { if (action.data.skip) {
return state return state
.set('isFlashing', false) .set('isFlashing', false)
.set('flashResults', Immutable.fromJS(action.data)); .set('flashResults', Immutable.fromJS(action.data));
}
} }
return state return state

View File

@ -73,9 +73,7 @@ export function isSourceDrive(
): boolean { ): boolean {
if (selection) { if (selection) {
if (selection.drive) { if (selection.drive) {
const sourcePath = selection.drive.devicePath || selection.drive.device; return selection.drive.device === drive.device;
const drivePath = drive.devicePath || drive.device;
return pathIsInside(sourcePath, drivePath);
} }
if (selection.path) { if (selection.path) {
return sourceIsInsideDrive(selection.path, drive); return sourceIsInsideDrive(selection.path, drive);