diff --git a/lib/gui/app/components/drive-selector/controllers/drive-selector.js b/lib/gui/app/components/drive-selector/controllers/drive-selector.js index dd3bb49a..0b873049 100644 --- a/lib/gui/app/components/drive-selector/controllers/drive-selector.js +++ b/lib/gui/app/components/drive-selector/controllers/drive-selector.js @@ -28,7 +28,7 @@ const utils = require('../../../../../shared/utils') module.exports = function ( $q, $uibModalInstance, - WarningModalService, + ConfirmModalService, OSOpenExternalService ) { /** @@ -100,26 +100,52 @@ module.exports = function ( }) selectionState.toggleDrive(drive.device) - } else if (drive.link) { - analytics.logEvent('Open drive link modal', { - url: drive.link - }) - - const message = drive.message || `Etcher will open ${drive.link} in your browser` - return WarningModalService.display({ - confirmationLabel: 'Yes, continue', - description: `${message}. Are you sure you want to continue?` - }).then((answer) => { - if (answer) { - OSOpenExternalService.open(drive.link) - } - }) } return Bluebird.resolve() }) } + /** + * @summary Prompt the user to install missing usbboot drivers + * @function + * @public + * + * @param {Object} drive - drive + * @returns {Promise} - resolved promise + * + * @example + * DriveSelectorController.installMissingDrivers({ + * linkTitle: 'Go to example.com', + * linkMessage: 'Examples are great, right?', + * linkCTA: 'Call To Action', + * link: 'https://example.com' + * }); + */ + this.installMissingDrivers = (drive) => { + if (drive.link) { + analytics.logEvent('Open driver link modal', { + url: drive.link + }) + + return ConfirmModalService.show({ + confirmationLabel: 'Yes, continue', + rejectionLabel: 'Cancel', + title: drive.linkTitle, + confirmButton: 'primary', + message: drive.linkMessage || `Etcher will open ${drive.link} in your browser` + }).then((shouldContinue) => { + if (shouldContinue) { + OSOpenExternalService.open(drive.link) + } + }).catch((error) => { + analytics.logException(error) + }) + } + + return Bluebird.resolve() + } + /** * @summary Close the modal and resolve the selected drive * @function diff --git a/lib/gui/app/components/drive-selector/drive-selector.js b/lib/gui/app/components/drive-selector/drive-selector.js index e181d5a2..adf0ed6b 100644 --- a/lib/gui/app/components/drive-selector/drive-selector.js +++ b/lib/gui/app/components/drive-selector/drive-selector.js @@ -24,7 +24,7 @@ const angular = require('angular') const MODULE_NAME = 'Etcher.Components.DriveSelector' const DriveSelector = angular.module(MODULE_NAME, [ require('../modal/modal'), - require('../warning-modal/warning-modal'), + require('../confirm-modal/confirm-modal'), require('../../utils/byte-size/byte-size'), require('../../os/open-external/open-external') ]) diff --git a/lib/gui/app/components/drive-selector/templates/drive-selector-modal.tpl.html b/lib/gui/app/components/drive-selector/templates/drive-selector-modal.tpl.html index ea1bbe02..07520725 100644 --- a/lib/gui/app/components/drive-selector/templates/drive-selector-modal.tpl.html +++ b/lib/gui/app/components/drive-selector/templates/drive-selector-modal.tpl.html @@ -6,7 +6,7 @@