From 2c80ca23a783135b20425f1ce493e31c02b113e7 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Wed, 3 Aug 2016 11:23:22 -0400 Subject: [PATCH] feat(GUI): show "Unmounting..." while unmounting a drive (#618) Currently, we show "Finishing..." indenpendently on if we're waiting for the flash to emit the "done" event, or we're waiting for the drive to be unmounted. As a way to simplify things, we move the hairy `ngShow` stack from the main template to a nice function in the controller. Change-Type: minor Changelog-Entry: Show "Unmounting..." while unmounting a drive. Signed-off-by: Juan Cruz Viotti --- lib/gui/pages/main/controllers/main.js | 26 ++++++++++++++++++++++ lib/gui/pages/main/templates/main.tpl.html | 8 +------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/lib/gui/pages/main/controllers/main.js b/lib/gui/pages/main/controllers/main.js index 95427f21..286e6afc 100644 --- a/lib/gui/pages/main/controllers/main.js +++ b/lib/gui/pages/main/controllers/main.js @@ -93,6 +93,32 @@ module.exports = function( } }); + this.getProgressButtonLabel = () => { + const flashState = this.state.getFlashState(); + + if (!this.state.isFlashing()) { + return 'Flash!'; + } + + if (flashState.percentage === 100) { + if (flashState.type === 'check' && this.settings.get('unmountOnSuccess')) { + return 'Unmounting...'; + } + + return 'Finishing...'; + } + + if (flashState.percentage === 0) { + return 'Starting...'; + } + + if (flashState.type === 'check') { + return `${flashState.percentage}% Validating...`; + } + + return `${flashState.percentage}%`; + }; + this.selectImage = (image) => { if (!SupportedFormatsModel.isSupportedImage(image.path)) { OSDialogService.showError('Invalid image', `${image.path} is not a supported image type.`); diff --git a/lib/gui/pages/main/templates/main.tpl.html b/lib/gui/pages/main/templates/main.tpl.html index 5333351c..2ba9ee20 100644 --- a/lib/gui/pages/main/templates/main.tpl.html +++ b/lib/gui/pages/main/templates/main.tpl.html @@ -90,13 +90,7 @@ ng-show="main.state.wasLastFlashSuccessful()" ng-click="main.flash(main.selection.getImagePath(), main.selection.getDrive())" ng-disabled="!main.selection.hasImage() || !main.selection.hasDrive()"> - Finishing... - Flash! - Starting... - - +