From 4c40c8ff30b921c302883db9ae8f267a6d27095d Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Wed, 13 Dec 2017 13:50:32 -0400 Subject: [PATCH 1/3] feat(GUI): link to drivers when clicking a driverless usbboot device Step 2 until we support installing the drivers from within Etcher. This also introduces an "Open drive link" Mixpanel event. See: https://www.raspberrypi.org/documentation/hardware/computemodule/cm-emmc-flashing.md See: https://github.com/resin-io/etcher/pull/1892 Change-Type: patch Changelog-Entry: Download usbboot drivers installer when clicking a driverless usbboot device on Windows. Signed-off-by: Juan Cruz Viotti --- .../controllers/drive-selector.js | 21 ++++++++++++++++++- .../drive-selector/drive-selector.js | 4 +++- .../templates/drive-selector-modal.tpl.html | 2 +- lib/sdk/adapters/usbboot/index.js | 2 ++ 4 files changed, 26 insertions(+), 3 deletions(-) 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 cf5dd1e3..dd3bb49a 100644 --- a/lib/gui/app/components/drive-selector/controllers/drive-selector.js +++ b/lib/gui/app/components/drive-selector/controllers/drive-selector.js @@ -18,6 +18,7 @@ const angular = require('angular') const _ = require('lodash') +const Bluebird = require('bluebird') const constraints = require('../../../../../shared/drive-constraints') const analytics = require('../../../modules/analytics') const availableDrives = require('../../../../../shared/models/available-drives') @@ -26,7 +27,9 @@ const utils = require('../../../../../shared/utils') module.exports = function ( $q, - $uibModalInstance + $uibModalInstance, + WarningModalService, + OSOpenExternalService ) { /** * @summary The drive selector state @@ -97,7 +100,23 @@ 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() }) } diff --git a/lib/gui/app/components/drive-selector/drive-selector.js b/lib/gui/app/components/drive-selector/drive-selector.js index f41f6e30..e181d5a2 100644 --- a/lib/gui/app/components/drive-selector/drive-selector.js +++ b/lib/gui/app/components/drive-selector/drive-selector.js @@ -24,7 +24,9 @@ const angular = require('angular') const MODULE_NAME = 'Etcher.Components.DriveSelector' const DriveSelector = angular.module(MODULE_NAME, [ require('../modal/modal'), - require('../../utils/byte-size/byte-size') + require('../warning-modal/warning-modal'), + require('../../utils/byte-size/byte-size'), + require('../../os/open-external/open-external') ]) DriveSelector.controller('DriveSelectorController', require('./controllers/drive-selector')) 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 ed0d9971..ea1bbe02 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 @@