Add warning color to Flash! button

Change-type: patch
Signed-off-by: Lorenzo Alberto Maria Ambrosi <lorenzothunder.ambrosi@gmail.com>
This commit is contained in:
Lorenzo Alberto Maria Ambrosi 2020-06-04 14:21:39 +02:00
parent 5d95fcb81f
commit f8cc7c36b4
2 changed files with 15 additions and 5 deletions

View File

@ -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<ProgressButtonProps> {
}
return (
<StepButton
primary
primary={!this.props.warning}
warning={this.props.warning}
onClick={this.props.callback}
disabled={this.props.disabled}
>

View File

@ -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();
}}