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 <jv@jviotti.com>
This commit is contained in:
Juan Cruz Viotti 2017-12-13 13:50:32 -04:00 committed by Jonas Hermsmeier
parent d7211b130b
commit 4c40c8ff30
No known key found for this signature in database
GPG Key ID: 1B870F801A0CEE9F
4 changed files with 26 additions and 3 deletions

View File

@ -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()
})
}

View File

@ -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'))

View File

@ -6,7 +6,7 @@
<div class="modal-body">
<ul class="list-group">
<li class="list-group-item" ng-repeat="drive in modal.getDrives() track by drive.device"
ng-disabled="!modal.constraints.isDriveValid(drive, modal.state.getImage())"
ng-disabled="!modal.constraints.isDriveValid(drive, modal.state.getImage()) && !drive.link"
ng-dblclick="modal.selectDriveAndClose(drive)"
ng-click="modal.toggleDrive(drive)">
<img class="list-group-item-section" alt="Drive device type logo"

View File

@ -273,6 +273,8 @@ class USBBootAdapter extends EventEmitter {
disabled: true,
icon: 'warning',
size: null,
link: 'https://github.com/raspberrypi/usbboot/raw/master/win32/rpiboot_setup.exe',
message: 'Etcher will now download the necessary drivers from the Raspberry Pi Foundation',
adaptor: USBBootAdapter.id
}
}