feat(GUI): allow opening drive selector modal when no drives (#1146)

We change the drive selector button text to be a static 'select drive'
and allow the user to open the dialog even if there are no drives,
displaying the 'no drives' warning inside the modal.

Closes: https://github.com/resin-io/etcher/issues/884
Changelog-Entry: Allow opening the drive selector modal when there are no
drives.
This commit is contained in:
Benedict Aas 2017-03-01 14:27:26 +00:00 committed by Juan Cruz Viotti
parent 4604e89b4f
commit 33a4ed8c95
3 changed files with 9 additions and 14 deletions

View File

@ -29,7 +29,6 @@ const messages = require('../shared/messages');
/* eslint-enable no-var */ /* eslint-enable no-var */
const _ = require('lodash');
const Store = require('./models/store'); const Store = require('./models/store');
const app = angular.module('Etcher', [ const app = angular.module('Etcher', [
@ -50,7 +49,6 @@ const app = angular.module('Etcher', [
// Components // Components
require('./components/svg-icon/svg-icon'), require('./components/svg-icon/svg-icon'),
require('./components/update-notifier/update-notifier'), require('./components/update-notifier/update-notifier'),
require('./components/drive-selector/drive-selector'),
require('./components/warning-modal/warning-modal'), require('./components/warning-modal/warning-modal'),
// Pages // Pages
@ -130,7 +128,7 @@ app.run((AnalyticsService, OSWindowProgressService, FlashStateModel) => {
}); });
}); });
app.run(($timeout, DriveScannerService, DrivesModel, ErrorService, DriveSelectorService) => { app.run(($timeout, DriveScannerService, DrivesModel, ErrorService) => {
DriveScannerService.on('drives', (drives) => { DriveScannerService.on('drives', (drives) => {
// Safely trigger a digest cycle. // Safely trigger a digest cycle.
@ -140,10 +138,6 @@ app.run(($timeout, DriveScannerService, DrivesModel, ErrorService, DriveSelector
$timeout(() => { $timeout(() => {
DrivesModel.setDrives(drives); DrivesModel.setDrives(drives);
}); });
if (_.isEmpty(drives)) {
DriveSelectorService.close();
}
}); });
DriveScannerService.on('error', ErrorService.reportException); DriveScannerService.on('error', ErrorService.reportException);

View File

@ -51,6 +51,13 @@
ng-show="modal.constraints.isDriveValid(drive, modal.state.getImage())" ng-show="modal.constraints.isDriveValid(drive, modal.state.getImage())"
ng-disabled="!modal.state.isCurrentDrive(drive.device)"></span> ng-disabled="!modal.state.isCurrentDrive(drive.device)"></span>
</li> </li>
<li class="list-group-item"
ng-show="!modal.drives.hasAvailableDrives()">
<div>
<b>Connect a drive!</b>
<div>No removable drive detected.</div>
</div>
</li>
</ul> </ul>
</div> </div>

View File

@ -48,18 +48,12 @@
<div class="space-vertical-large"> <div class="space-vertical-large">
<div ng-hide="main.selection.hasDrive()"> <div ng-hide="main.selection.hasDrive()">
<div ng-show="main.drives.hasAvailableDrives()"> <div>
<button class="button button-primary button-brick" <button class="button button-primary button-brick"
ng-disabled="main.shouldDriveStepBeDisabled()" ng-disabled="main.shouldDriveStepBeDisabled()"
ng-click="drive.openDriveSelector()">Select drive</button> ng-click="drive.openDriveSelector()">Select drive</button>
</div> </div>
<div ng-hide="main.drives.hasAvailableDrives()">
<button
class="button button-primary button-brick button-no-hover"
ng-disabled="main.shouldDriveStepBeDisabled()">Connect a drive</button>
</div>
</div> </div>
<div ng-show="main.selection.hasDrive()"> <div ng-show="main.selection.hasDrive()">