mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 11:16:39 +00:00
refactor(GUI): remove selection-state clear options to simplify (#2043)
We refactor and simplify the selection-state `.clear()` by removing the options argument. Change-Type: patch Changelog-Entry: Remove `selectionState.clear()` options argument to simplify.
This commit is contained in:
parent
a56755e2c6
commit
2c0cdcf947
@ -48,7 +48,10 @@ module.exports = function ($state) {
|
|||||||
* FinishController.restart({ preserveImage: true });
|
* FinishController.restart({ preserveImage: true });
|
||||||
*/
|
*/
|
||||||
this.restart = (options) => {
|
this.restart = (options) => {
|
||||||
selectionState.clear(options)
|
if (!options.preserveImage) {
|
||||||
|
selectionState.deselectImage()
|
||||||
|
}
|
||||||
|
selectionState.deselectDrive()
|
||||||
analytics.logEvent('Restart', options)
|
analytics.logEvent('Restart', options)
|
||||||
$state.go('main')
|
$state.go('main')
|
||||||
}
|
}
|
||||||
|
@ -304,25 +304,15 @@ exports.deselectImage = () => {
|
|||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
*
|
*
|
||||||
* @param {Object} options - options
|
|
||||||
* @param {Boolean} [options.preserveImage] - preserve image
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* selectionState.clear();
|
* selectionState.clear();
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* selectionState.clear({ preserveImage: true });
|
* selectionState.clear({ preserveImage: true });
|
||||||
*/
|
*/
|
||||||
exports.clear = (options = {}) => {
|
exports.clear = () => {
|
||||||
if (!options.preserveImage) {
|
exports.deselectImage()
|
||||||
store.dispatch({
|
exports.deselectDrive()
|
||||||
type: store.Actions.DESELECT_IMAGE
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
store.dispatch({
|
|
||||||
type: store.Actions.DESELECT_DRIVE
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -853,7 +853,7 @@ describe('Model: selectionState', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('given a drive', function () {
|
describe('given a drive and an image', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
availableDrives.setDrives([
|
availableDrives.setDrives([
|
||||||
{
|
{
|
||||||
@ -890,37 +890,16 @@ describe('Model: selectionState', function () {
|
|||||||
m.chai.expect(selectionState.hasImage()).to.be.false
|
m.chai.expect(selectionState.hasImage()).to.be.false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
describe('.deselectImage()', function () {
|
||||||
describe('given the preserveImage option', function () {
|
it('should not clear any drives', function () {
|
||||||
beforeEach(function () {
|
selectionState.deselectImage()
|
||||||
selectionState.clear({
|
m.chai.expect(selectionState.hasDrive()).to.be.true
|
||||||
preserveImage: true
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
})
|
||||||
it('getDrive() should return undefined', function () {
|
describe('.deselectDrive()', function () {
|
||||||
const drive = selectionState.getDrive()
|
it('should not clear the image', function () {
|
||||||
m.chai.expect(drive).to.be.undefined
|
selectionState.deselectDrive()
|
||||||
})
|
m.chai.expect(selectionState.hasImage()).to.be.true
|
||||||
|
|
||||||
it('getImagePath() should return the image path', function () {
|
|
||||||
const imagePath = selectionState.getImagePath()
|
|
||||||
m.chai.expect(imagePath).to.equal('foo.img')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('getImageSize() should return the image size', function () {
|
|
||||||
const imageSize = selectionState.getImageSize()
|
|
||||||
m.chai.expect(imageSize).to.equal(999999999)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('hasDrive() should return false', function () {
|
|
||||||
const hasDrive = selectionState.hasDrive()
|
|
||||||
m.chai.expect(hasDrive).to.be.false
|
|
||||||
})
|
|
||||||
|
|
||||||
it('hasImage() should return true', function () {
|
|
||||||
const hasImage = selectionState.hasImage()
|
|
||||||
m.chai.expect(hasImage).to.be.true
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user