mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-25 07:47:18 +00:00
Fix FlashResults component
Change-type: patch
This commit is contained in:
parent
7eddb16f2f
commit
63ad3739fd
@ -18,7 +18,6 @@ import * as _ from 'lodash';
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as uuidV4 from 'uuid/v4';
|
import * as uuidV4 from 'uuid/v4';
|
||||||
|
|
||||||
import * as messages from '../../../../shared/messages';
|
|
||||||
import * as flashState from '../../models/flash-state';
|
import * as flashState from '../../models/flash-state';
|
||||||
import * as selectionState from '../../models/selection-state';
|
import * as selectionState from '../../models/selection-state';
|
||||||
import { store } from '../../models/store';
|
import { store } from '../../models/store';
|
||||||
@ -67,18 +66,12 @@ const formattedErrors = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function FinishPage({ goToMain }: { goToMain: () => void }) {
|
function FinishPage({ goToMain }: { goToMain: () => void }) {
|
||||||
// @ts-ignore
|
|
||||||
const results = flashState.getFlashResults().results || {};
|
const results = flashState.getFlashResults().results || {};
|
||||||
const progressMessage = messages.progress;
|
|
||||||
return (
|
return (
|
||||||
<div className="page-finish row around-xs">
|
<div className="page-finish row around-xs">
|
||||||
<div className="col-xs">
|
<div className="col-xs">
|
||||||
<div className="box center">
|
<div className="box center">
|
||||||
<FlashResults
|
<FlashResults results={results} errors={formattedErrors()} />
|
||||||
results={results}
|
|
||||||
message={progressMessage}
|
|
||||||
errors={formattedErrors}
|
|
||||||
></FlashResults>
|
|
||||||
|
|
||||||
<FlashAnother
|
<FlashAnother
|
||||||
onClick={(options: any) => restart(options, goToMain)}
|
onClick={(options: any) => restart(options, goToMain)}
|
||||||
|
@ -18,24 +18,24 @@ import * as _ from 'lodash';
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { left, position, space, top } from 'styled-system';
|
import { left, position, space, top } from 'styled-system';
|
||||||
|
|
||||||
|
import { progress } from '../../../../shared/messages';
|
||||||
import { Underline } from '../../styled-components';
|
import { Underline } from '../../styled-components';
|
||||||
|
|
||||||
const Div: any = styled.div<any>`
|
const Div = styled.div<any>`
|
||||||
${position}
|
${position}
|
||||||
${top}
|
${top}
|
||||||
${left}
|
${left}
|
||||||
${space}
|
${space}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const FlashResults: any = ({
|
export function FlashResults({
|
||||||
errors,
|
errors,
|
||||||
results,
|
results,
|
||||||
message,
|
|
||||||
}: {
|
}: {
|
||||||
errors: () => string;
|
errors: string;
|
||||||
results: any;
|
results: { devices: { failed: number; successful: number } };
|
||||||
message: any;
|
}) {
|
||||||
}) => {
|
|
||||||
return (
|
return (
|
||||||
<Div position="absolute" left="153px" top="66px">
|
<Div position="absolute" left="153px" top="66px">
|
||||||
<div className="inline-flex title">
|
<div className="inline-flex title">
|
||||||
@ -43,9 +43,12 @@ export const FlashResults: any = ({
|
|||||||
<h3>Flash Complete!</h3>
|
<h3>Flash Complete!</h3>
|
||||||
</div>
|
</div>
|
||||||
<Div className="results" mt="11px" mr="0" mb="0" ml="40px">
|
<Div className="results" mt="11px" mr="0" mb="0" ml="40px">
|
||||||
<Underline tooltip={errors()}>
|
{_.map(results.devices, (quantity, type) => {
|
||||||
{_.map(results.devices, (quantity, type) => {
|
return quantity ? (
|
||||||
return quantity ? (
|
<Underline
|
||||||
|
tooltip={type === 'failed' ? errors : undefined}
|
||||||
|
key={type}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
key={type}
|
key={type}
|
||||||
className={`target-status-line target-status-${type}`}
|
className={`target-status-line target-status-${type}`}
|
||||||
@ -53,13 +56,13 @@ export const FlashResults: any = ({
|
|||||||
<span className="target-status-dot"></span>
|
<span className="target-status-dot"></span>
|
||||||
<span className="target-status-quantity">{quantity}</span>
|
<span className="target-status-quantity">{quantity}</span>
|
||||||
<span className="target-status-message">
|
<span className="target-status-message">
|
||||||
{message[type](quantity)}
|
{progress[type](quantity)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
) : null;
|
</Underline>
|
||||||
})}
|
) : null;
|
||||||
</Underline>
|
})}
|
||||||
</Div>
|
</Div>
|
||||||
</Div>
|
</Div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const progress = {
|
import { Dictionary } from 'lodash';
|
||||||
|
|
||||||
|
export const progress: Dictionary<(quantity: number) => string> = {
|
||||||
successful: (quantity: number) => {
|
successful: (quantity: number) => {
|
||||||
const plural = quantity === 1 ? '' : 's';
|
const plural = quantity === 1 ? '' : 's';
|
||||||
return `Successful device${plural}`;
|
return `Successful device${plural}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user