From f8cc7c36b4888babf65e65ba6f622e28306505aa Mon Sep 17 00:00:00 2001 From: Lorenzo Alberto Maria Ambrosi Date: Thu, 4 Jun 2020 14:21:39 +0200 Subject: [PATCH] Add warning color to Flash! button Change-type: patch Signed-off-by: Lorenzo Alberto Maria Ambrosi --- .../progress-button/progress-button.tsx | 4 +++- lib/gui/app/pages/main/Flash.tsx | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/gui/app/components/progress-button/progress-button.tsx b/lib/gui/app/components/progress-button/progress-button.tsx index 541e98f3..97258d67 100644 --- a/lib/gui/app/components/progress-button/progress-button.tsx +++ b/lib/gui/app/components/progress-button/progress-button.tsx @@ -50,6 +50,7 @@ interface ProgressButtonProps { disabled: boolean; cancel: () => void; callback: () => void; + warning?: boolean; } const colors = { @@ -97,7 +98,8 @@ export class ProgressButton extends React.PureComponent { } return ( diff --git a/lib/gui/app/pages/main/Flash.tsx b/lib/gui/app/pages/main/Flash.tsx index 42d7743e..a2fd2690 100644 --- a/lib/gui/app/pages/main/Flash.tsx +++ b/lib/gui/app/pages/main/Flash.tsx @@ -197,6 +197,13 @@ export class FlashStep extends React.PureComponent< } } + private hasListWarnings(drives: any[], image: any) { + if (drives.length === 0 || flashState.isFlashing()) { + return; + } + return constraints.hasListDriveImageCompatibilityStatus(drives, image); + } + private async tryFlash() { const devices = selection.getSelectedDevices(); const image = selection.getImage(); @@ -209,10 +216,7 @@ export class FlashStep extends React.PureComponent< if (drives.length === 0 || this.props.isFlashing) { return; } - const hasDangerStatus = constraints.hasListDriveImageCompatibilityStatus( - drives, - image, - ); + const hasDangerStatus = this.hasListWarnings(drives, image); if (hasDangerStatus) { this.setState({ warningMessages: getWarningMessages(drives, image) }); return; @@ -245,6 +249,10 @@ export class FlashStep extends React.PureComponent< position={this.props.position} disabled={this.props.shouldFlashStepBeDisabled} cancel={imageWriter.cancel} + warning={this.hasListWarnings( + selection.getSelectedDrives(), + selection.getImage(), + )} callback={() => { this.tryFlash(); }}