Skip to content

Commit

Permalink
upgrade: angular to v1.6.1; angular-ui-bootstrap to v2.5.0
Browse files Browse the repository at this point in the history
Angular 1.5 has a bug that causes angular's `$exceptionHandler`
to be called for rejected `$q` promises even if they have
a rejection handler. This bug caused duplicate error messages
in Etcher.

A consequence of upgrading to Angular 1.6 is that `$q` promises
without a rejection handler will throw `Possibly unhandled rejection`
errors. To avoid these errors, this commit moves code responsible
for opening a tooltip from the template to the controller and handles
the rejection.

Other packages upgraded:
- angular-moment to v1.0.1
- angular-ui-router to v0.4.2
- angular-mocks to v1.6.1

Change-type: patch
Changelog-Entry: Fix duplicate error messages
Fixes: #1082
See: angular/angular.js#7992
See: angular/angular.js#13662
  • Loading branch information
stefan-mihaila committed Feb 7, 2017
1 parent 70c7ddc commit 87252f7
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 29 deletions.
5 changes: 5 additions & 0 deletions lib/gui/modules/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

const angular = require('angular');
const _ = require('lodash');

const MODULE_NAME = 'Etcher.Modules.Error';
const error = angular.module(MODULE_NAME, [
Expand All @@ -41,6 +42,10 @@ error.service('ErrorService', function(AnalyticsService, OSDialogService) {
* ErrorService.reportException(new Error('Something happened'));
*/
this.reportException = (exception) => {
if (_.isUndefined(exception)) {
return;
}

OSDialogService.showError(exception, exception.description);
AnalyticsService.logException(exception);
};
Expand Down
19 changes: 18 additions & 1 deletion lib/gui/pages/main/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = function(
FlashStateModel,
SettingsModel,
TooltipModalService,
ErrorService,
OSOpenExternalService
) {

Expand All @@ -31,7 +32,6 @@ module.exports = function(
this.state = FlashStateModel;
this.settings = SettingsModel;
this.external = OSOpenExternalService;
this.tooltipModal = TooltipModalService;

/**
* @summary Determine if the image step should be disabled
Expand Down Expand Up @@ -65,4 +65,21 @@ module.exports = function(
return !SelectionStateModel.hasImage() || this.shouldImageStepBeDisabled();
};

/**
* @summary Display a tooltip with the selected image details
* @function
* @public
*
* @returns {Promise}
*
* @example
* MainController.showSelectedImageDetails()
*/
this.showSelectedImageDetails = () => {
return TooltipModalService.show({
title: 'Image File Name',
message: SelectionStateModel.getImagePath()
}).catch(ErrorService.reportException);
};

};
5 changes: 4 additions & 1 deletion lib/gui/pages/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
const angular = require('angular');
const MODULE_NAME = 'Etcher.Pages.Main';

require('angular-moment');

const MainPage = angular.module(MODULE_NAME, [
'angularMoment',

require('angular-ui-router'),
require('angular-moment'),
require('angular-middle-ellipses'),
require('angular-seconds-to-date'),

Expand Down
5 changes: 1 addition & 4 deletions lib/gui/pages/main/templates/main.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@
<div ng-if="main.selection.hasImage()">
<div class="step-selection-text">
<span
ng-click="main.tooltipModal.show({
title: 'Image File Name',
message: main.selection.getImagePath()
})"
ng-click="main.showSelectedImageDetails()"
class="step-image step-name"
ng-class="{ 'text-disabled': main.shouldImageStepBeDisabled() }"
ng-bind="main.selection.getImageName() || main.selection.getImagePath() | basename | middleEllipses:20"
Expand Down
30 changes: 15 additions & 15 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
"removedrive": "^1.1.1"
},
"dependencies": {
"angular": "^1.5.3",
"angular": "^1.6.1",
"angular-if-state": "^1.0.0",
"angular-middle-ellipses": "^1.0.0",
"angular-moment": "^1.0.0-beta.6",
"angular-moment": "^1.0.1",
"angular-seconds-to-date": "^1.0.0",
"angular-ui-bootstrap": "^1.3.2",
"angular-ui-router": "^0.2.18",
"angular-ui-bootstrap": "^2.5.0",
"angular-ui-router": "^0.4.2",
"archive-type": "^3.2.0",
"bluebird": "^3.0.5",
"bootstrap-sass": "^3.3.5",
Expand Down Expand Up @@ -104,7 +104,7 @@
"yauzl": "^2.6.0"
},
"devDependencies": {
"angular-mocks": "^1.4.7",
"angular-mocks": "^1.6.1",
"browserify": "^13.0.1",
"electron-builder": "^2.6.0",
"electron-mocha": "^3.1.1",
Expand Down
6 changes: 3 additions & 3 deletions tests/gui/modules/image-writer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Browser: ImageWriter', function() {
});

ImageWriterService.flash('foo.img', '/dev/disk2');
ImageWriterService.flash('foo.img', '/dev/disk2');
ImageWriterService.flash('foo.img', '/dev/disk2').catch(angular.noop);
$rootScope.$apply();
m.chai.expect(this.performWriteStub).to.have.been.calledOnce;
});
Expand Down Expand Up @@ -97,13 +97,13 @@ describe('Browser: ImageWriter', function() {
});

it('should set flashing to false when done', function() {
ImageWriterService.flash('foo.img', '/dev/disk2');
ImageWriterService.flash('foo.img', '/dev/disk2').catch(angular.noop);
$rootScope.$apply();
m.chai.expect(FlashStateModel.isFlashing()).to.be.false;
});

it('should set the error code in the flash results', function() {
ImageWriterService.flash('foo.img', '/dev/disk2');
ImageWriterService.flash('foo.img', '/dev/disk2').catch(angular.noop);
$rootScope.$apply();
const flashResults = FlashStateModel.getFlashResults();
m.chai.expect(flashResults.errorCode).to.equal('FOO');
Expand Down

0 comments on commit 87252f7

Please sign in to comment.