mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-18 08:46:32 +00:00
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:
parent
5d95fcb81f
commit
f8cc7c36b4
@ -50,6 +50,7 @@ interface ProgressButtonProps {
|
|||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
cancel: () => void;
|
cancel: () => void;
|
||||||
callback: () => void;
|
callback: () => void;
|
||||||
|
warning?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const colors = {
|
const colors = {
|
||||||
@ -97,7 +98,8 @@ export class ProgressButton extends React.PureComponent<ProgressButtonProps> {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<StepButton
|
<StepButton
|
||||||
primary
|
primary={!this.props.warning}
|
||||||
|
warning={this.props.warning}
|
||||||
onClick={this.props.callback}
|
onClick={this.props.callback}
|
||||||
disabled={this.props.disabled}
|
disabled={this.props.disabled}
|
||||||
>
|
>
|
||||||
|
@ -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() {
|
private async tryFlash() {
|
||||||
const devices = selection.getSelectedDevices();
|
const devices = selection.getSelectedDevices();
|
||||||
const image = selection.getImage();
|
const image = selection.getImage();
|
||||||
@ -209,10 +216,7 @@ export class FlashStep extends React.PureComponent<
|
|||||||
if (drives.length === 0 || this.props.isFlashing) {
|
if (drives.length === 0 || this.props.isFlashing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const hasDangerStatus = constraints.hasListDriveImageCompatibilityStatus(
|
const hasDangerStatus = this.hasListWarnings(drives, image);
|
||||||
drives,
|
|
||||||
image,
|
|
||||||
);
|
|
||||||
if (hasDangerStatus) {
|
if (hasDangerStatus) {
|
||||||
this.setState({ warningMessages: getWarningMessages(drives, image) });
|
this.setState({ warningMessages: getWarningMessages(drives, image) });
|
||||||
return;
|
return;
|
||||||
@ -245,6 +249,10 @@ export class FlashStep extends React.PureComponent<
|
|||||||
position={this.props.position}
|
position={this.props.position}
|
||||||
disabled={this.props.shouldFlashStepBeDisabled}
|
disabled={this.props.shouldFlashStepBeDisabled}
|
||||||
cancel={imageWriter.cancel}
|
cancel={imageWriter.cancel}
|
||||||
|
warning={this.hasListWarnings(
|
||||||
|
selection.getSelectedDrives(),
|
||||||
|
selection.getImage(),
|
||||||
|
)}
|
||||||
callback={() => {
|
callback={() => {
|
||||||
this.tryFlash();
|
this.tryFlash();
|
||||||
}}
|
}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user