mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-24 03:36:36 +00:00
Merge pull request #2272 from resin-io/fix-store-warning-deselect
fix(store): keep single warning-drives selected
This commit is contained in:
commit
8f969374c7
@ -199,7 +199,9 @@ const storeReducer = (state = DEFAULT_STATE, action) => {
|
||||
|
||||
const AUTOSELECT_DRIVE_COUNT = 1
|
||||
const numberOfDrives = drives.length
|
||||
if (numberOfDrives === AUTOSELECT_DRIVE_COUNT) {
|
||||
const nonStaleSelectedDevices = nonStaleNewState.getIn([ 'selection', 'devices' ]).toJS()
|
||||
const hasSelectedDevices = nonStaleSelectedDevices.length >= AUTOSELECT_DRIVE_COUNT
|
||||
if (numberOfDrives === AUTOSELECT_DRIVE_COUNT && !hasSelectedDevices) {
|
||||
const [ drive ] = drives
|
||||
|
||||
// Even if there's no image selected, we need to call several
|
||||
|
@ -80,6 +80,40 @@ describe('Model: selectionState', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('given one available drive', function () {
|
||||
beforeEach(function () {
|
||||
this.drives = [
|
||||
{
|
||||
device: '/dev/disk2',
|
||||
name: 'USB Drive',
|
||||
size: 999999999,
|
||||
isReadOnly: false
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
selectionState.clear()
|
||||
availableDrives.setDrives([])
|
||||
})
|
||||
|
||||
describe('.selectDrive()', function () {
|
||||
it('should not deselect when warning is attached to image-drive pair', function () {
|
||||
this.drives[0].size = 64e10
|
||||
|
||||
availableDrives.setDrives(this.drives)
|
||||
selectionState.selectDrive('/dev/disk2')
|
||||
availableDrives.setDrives(this.drives)
|
||||
m.chai.expect(selectionState.getCurrentDrive()).to.deep.equal({
|
||||
device: '/dev/disk2',
|
||||
name: 'USB Drive',
|
||||
size: 64e10,
|
||||
isReadOnly: false
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('given a drive', function () {
|
||||
beforeEach(function () {
|
||||
availableDrives.setDrives([
|
||||
|
Loading…
x
Reference in New Issue
Block a user