mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-27 21:26:38 +00:00
Removed disableExplicitDriveSelection setting, use autoSelectAllDrives instead
Change-type: patch
This commit is contained in:
parent
ef3b8915d8
commit
1e0a6a3129
@ -23,17 +23,13 @@ import * as ReactDOM from 'react-dom';
|
|||||||
import { v4 as uuidV4 } from 'uuid';
|
import { v4 as uuidV4 } from 'uuid';
|
||||||
|
|
||||||
import * as packageJSON from '../../../package.json';
|
import * as packageJSON from '../../../package.json';
|
||||||
import {
|
import { DrivelistDrive, isSourceDrive } from '../../shared/drive-constraints';
|
||||||
DrivelistDrive,
|
|
||||||
isDriveValid,
|
|
||||||
isSourceDrive,
|
|
||||||
} from '../../shared/drive-constraints';
|
|
||||||
import * as EXIT_CODES from '../../shared/exit-codes';
|
import * as EXIT_CODES from '../../shared/exit-codes';
|
||||||
import * as messages from '../../shared/messages';
|
import * as messages from '../../shared/messages';
|
||||||
import * as availableDrives from './models/available-drives';
|
import * as availableDrives from './models/available-drives';
|
||||||
import * as flashState from './models/flash-state';
|
import * as flashState from './models/flash-state';
|
||||||
import { init as ledsInit } from './models/leds';
|
import { init as ledsInit } from './models/leds';
|
||||||
import { deselectImage, getImage, selectDrive } from './models/selection-state';
|
import { deselectImage, getImage } from './models/selection-state';
|
||||||
import * as settings from './models/settings';
|
import * as settings from './models/settings';
|
||||||
import { Actions, observe, store } from './models/store';
|
import { Actions, observe, store } from './models/store';
|
||||||
import * as analytics from './modules/analytics';
|
import * as analytics from './modules/analytics';
|
||||||
@ -251,14 +247,6 @@ async function addDrive(drive: Drive) {
|
|||||||
const drives = getDrives();
|
const drives = getDrives();
|
||||||
drives[preparedDrive.device] = preparedDrive;
|
drives[preparedDrive.device] = preparedDrive;
|
||||||
setDrives(drives);
|
setDrives(drives);
|
||||||
if (
|
|
||||||
(await settings.get('autoSelectAllDrives')) &&
|
|
||||||
drive instanceof sdk.sourceDestination.BlockDevice &&
|
|
||||||
// @ts-ignore BlockDevice.drive is private
|
|
||||||
isDriveValid(drive.drive, getImage())
|
|
||||||
) {
|
|
||||||
selectDrive(drive.device);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeDrive(drive: Drive) {
|
function removeDrive(drive: Drive) {
|
||||||
|
@ -29,7 +29,6 @@ import {
|
|||||||
deselectDrive,
|
deselectDrive,
|
||||||
selectDrive,
|
selectDrive,
|
||||||
} from '../../models/selection-state';
|
} from '../../models/selection-state';
|
||||||
import * as settings from '../../models/settings';
|
|
||||||
import { observe } from '../../models/store';
|
import { observe } from '../../models/store';
|
||||||
import * as analytics from '../../modules/analytics';
|
import * as analytics from '../../modules/analytics';
|
||||||
import { TargetSelectorButton } from './target-selector-button';
|
import { TargetSelectorButton } from './target-selector-button';
|
||||||
@ -45,12 +44,7 @@ export const getDriveListLabel = () => {
|
|||||||
.join('\n');
|
.join('\n');
|
||||||
};
|
};
|
||||||
|
|
||||||
const shouldShowDrivesButton = () => {
|
|
||||||
return !settings.getSync('disableExplicitDriveSelection');
|
|
||||||
};
|
|
||||||
|
|
||||||
const getDriveSelectionStateSlice = () => ({
|
const getDriveSelectionStateSlice = () => ({
|
||||||
showDrivesButton: shouldShowDrivesButton(),
|
|
||||||
driveListLabel: getDriveListLabel(),
|
driveListLabel: getDriveListLabel(),
|
||||||
targets: getSelectedDrives(),
|
targets: getSelectedDrives(),
|
||||||
image: getImage(),
|
image: getImage(),
|
||||||
@ -114,10 +108,9 @@ export const TargetSelector = ({
|
|||||||
flashing,
|
flashing,
|
||||||
}: TargetSelectorProps) => {
|
}: TargetSelectorProps) => {
|
||||||
// TODO: inject these from redux-connector
|
// TODO: inject these from redux-connector
|
||||||
const [
|
const [{ driveListLabel, targets }, setStateSlice] = React.useState(
|
||||||
{ showDrivesButton, driveListLabel, targets },
|
getDriveSelectionStateSlice(),
|
||||||
setStateSlice,
|
);
|
||||||
] = React.useState(getDriveSelectionStateSlice());
|
|
||||||
const [showTargetSelectorModal, setShowTargetSelectorModal] = React.useState(
|
const [showTargetSelectorModal, setShowTargetSelectorModal] = React.useState(
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
@ -141,7 +134,7 @@ export const TargetSelector = ({
|
|||||||
|
|
||||||
<TargetSelectorButton
|
<TargetSelectorButton
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
show={!hasDrive && showDrivesButton}
|
show={!hasDrive}
|
||||||
tooltip={driveListLabel}
|
tooltip={driveListLabel}
|
||||||
openDriveSelector={() => {
|
openDriveSelector={() => {
|
||||||
setShowTargetSelectorModal(true);
|
setShowTargetSelectorModal(true);
|
||||||
|
@ -175,7 +175,7 @@ function storeReducer(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const shouldAutoselectAll = Boolean(
|
const shouldAutoselectAll = Boolean(
|
||||||
settings.getSync('disableExplicitDriveSelection'),
|
settings.getSync('autoSelectAllDrives'),
|
||||||
);
|
);
|
||||||
const AUTOSELECT_DRIVE_COUNT = 1;
|
const AUTOSELECT_DRIVE_COUNT = 1;
|
||||||
const nonStaleSelectedDevices = nonStaleNewState
|
const nonStaleSelectedDevices = nonStaleNewState
|
||||||
@ -197,18 +197,12 @@ function storeReducer(
|
|||||||
drives,
|
drives,
|
||||||
(accState, drive) => {
|
(accState, drive) => {
|
||||||
if (
|
if (
|
||||||
_.every([
|
constraints.isDriveValid(drive, image) &&
|
||||||
constraints.isDriveValid(drive, image),
|
constraints.isDriveSizeRecommended(drive, image) &&
|
||||||
constraints.isDriveSizeRecommended(drive, image),
|
// We don't want to auto-select large drives execpt is autoSelectAllDrives is true
|
||||||
|
(!constraints.isDriveSizeLarge(drive) || shouldAutoselectAll) &&
|
||||||
// We don't want to auto-select large drives
|
// We don't want to auto-select system drives
|
||||||
!constraints.isDriveSizeLarge(drive),
|
!constraints.isSystemDrive(drive)
|
||||||
|
|
||||||
// We don't want to auto-select system drives,
|
|
||||||
// even when "unsafe mode" is enabled
|
|
||||||
!constraints.isSystemDrive(drive),
|
|
||||||
]) ||
|
|
||||||
(shouldAutoselectAll && constraints.isDriveValid(drive, image))
|
|
||||||
) {
|
) {
|
||||||
// Auto-select this drive
|
// Auto-select this drive
|
||||||
return storeReducer(accState, {
|
return storeReducer(accState, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user