mirror of
https://github.com/balena-io/etcher.git
synced 2025-11-09 10:28:32 +00:00
The current "Close" button makes it confusing to the user to know if he's accepting his changes, or just discarding them. The "Close" button in the top right corner was replaced with a standard cross icon, and there is a new "Continue" block button fixed in the bottom of the modal. Fixes: https://github.com/resin-io/etcher/issues/294 Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
90 lines
2.1 KiB
JavaScript
90 lines
2.1 KiB
JavaScript
/*
|
|
* Copyright 2016 Resin.io
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const _ = require('lodash');
|
|
|
|
module.exports = function(SelectionStateModel) {
|
|
let self = this;
|
|
|
|
/**
|
|
* @summary Toggle select drive
|
|
* @function
|
|
* @public
|
|
*
|
|
* @param {Object} drive - drive
|
|
*
|
|
* @example
|
|
* DriveSelectorController.toggleSelectDrive({ drive });
|
|
*/
|
|
this.toggleSelectDrive = function(drive) {
|
|
if (this.isSelectedDrive(drive)) {
|
|
SelectionStateModel.removeDrive();
|
|
} else {
|
|
SelectionStateModel.setDrive(drive);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @summary Check if a drive is the selected one
|
|
* @function
|
|
* @public
|
|
*
|
|
* @param {Object} drive - drive
|
|
* @returns {Boolean} whether the drive is selected
|
|
*
|
|
* @example
|
|
* if (DriveSelectorController.isSelectedDrive({ drive })) {
|
|
* console.log('The drive is selected!');
|
|
* }
|
|
*/
|
|
this.isSelectedDrive = function(drive) {
|
|
if (!_.has(drive, 'device')) {
|
|
return false;
|
|
}
|
|
|
|
return drive.device === _.get(self.getSelectedDrive(), 'device');
|
|
};
|
|
|
|
/**
|
|
* @summary Get selected drive
|
|
* @function
|
|
* @public
|
|
*
|
|
* @returns {Object} selected drive
|
|
*
|
|
* @example
|
|
* const drive = DriveSelectorStateService.getSelectedDrive();
|
|
*/
|
|
this.getSelectedDrive = SelectionStateModel.getDrive;
|
|
|
|
/**
|
|
* @summary Has a selected drive
|
|
* @function
|
|
* @public
|
|
*
|
|
* @returns {Boolean} whether there is a selected drive
|
|
*
|
|
* @example
|
|
* if (DriveSelectorStateService.hasSelectedDrive()) {
|
|
* console.log('There is a selected drive');
|
|
* }
|
|
*/
|
|
this.hasSelectedDrive = SelectionStateModel.hasDrive;
|
|
|
|
};
|