mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-15 15:26:31 +00:00
feat(gui): Add CTA in drivelist, update drive download modal
This commit is contained in:
parent
4174991345
commit
8f762484f2
@ -28,7 +28,7 @@ const utils = require('../../../../../shared/utils')
|
|||||||
module.exports = function (
|
module.exports = function (
|
||||||
$q,
|
$q,
|
||||||
$uibModalInstance,
|
$uibModalInstance,
|
||||||
WarningModalService,
|
ConfirmModalService,
|
||||||
OSOpenExternalService
|
OSOpenExternalService
|
||||||
) {
|
) {
|
||||||
/**
|
/**
|
||||||
@ -100,26 +100,52 @@ module.exports = function (
|
|||||||
})
|
})
|
||||||
|
|
||||||
selectionState.toggleDrive(drive.device)
|
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()
|
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
|
* @summary Close the modal and resolve the selected drive
|
||||||
* @function
|
* @function
|
||||||
|
@ -24,7 +24,7 @@ const angular = require('angular')
|
|||||||
const MODULE_NAME = 'Etcher.Components.DriveSelector'
|
const MODULE_NAME = 'Etcher.Components.DriveSelector'
|
||||||
const DriveSelector = angular.module(MODULE_NAME, [
|
const DriveSelector = angular.module(MODULE_NAME, [
|
||||||
require('../modal/modal'),
|
require('../modal/modal'),
|
||||||
require('../warning-modal/warning-modal'),
|
require('../confirm-modal/confirm-modal'),
|
||||||
require('../../utils/byte-size/byte-size'),
|
require('../../utils/byte-size/byte-size'),
|
||||||
require('../../os/open-external/open-external')
|
require('../../os/open-external/open-external')
|
||||||
])
|
])
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
<li class="list-group-item" ng-repeat="drive in modal.getDrives() track by drive.device"
|
<li class="list-group-item" ng-repeat="drive in modal.getDrives() track by drive.device"
|
||||||
ng-disabled="!modal.constraints.isDriveValid(drive, modal.state.getImage()) && !drive.link"
|
ng-disabled="!modal.constraints.isDriveValid(drive, modal.state.getImage())"
|
||||||
ng-dblclick="modal.selectDriveAndClose(drive)"
|
ng-dblclick="modal.selectDriveAndClose(drive)"
|
||||||
ng-click="modal.toggleDrive(drive)">
|
ng-click="modal.toggleDrive(drive)">
|
||||||
<img class="list-group-item-section" alt="Drive device type logo"
|
<img class="list-group-item-section" alt="Drive device type logo"
|
||||||
@ -23,7 +23,8 @@
|
|||||||
<span class="word-keep"
|
<span class="word-keep"
|
||||||
ng-show="drive.size"> - {{ drive.size | closestUnit }}</span>
|
ng-show="drive.size"> - {{ drive.size | closestUnit }}</span>
|
||||||
</h4>
|
</h4>
|
||||||
<p class="list-group-item-text">{{ drive.displayName }}</p>
|
<p class="list-group-item-text" ng-if="!drive.link">{{ drive.displayName }}</p>
|
||||||
|
<p class="list-group-item-text" ng-if="drive.link">{{ drive.displayName }} - <b><a ng-click="modal.installMissingDrivers(drive)">{{ drive.linkCTA }}</a></b></p>
|
||||||
|
|
||||||
<footer class="list-group-item-footer">
|
<footer class="list-group-item-footer">
|
||||||
|
|
||||||
|
@ -273,8 +273,14 @@ class USBBootAdapter extends EventEmitter {
|
|||||||
disabled: true,
|
disabled: true,
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
size: null,
|
size: null,
|
||||||
link: 'https://github.com/raspberrypi/usbboot/raw/master/win32/rpiboot_setup.exe',
|
link: 'https://www.raspberrypi.org/documentation/hardware/computemodule/cm-emmc-flashing.md',
|
||||||
message: 'Etcher will now download the necessary drivers from the Raspberry Pi Foundation',
|
linkCTA: 'Install',
|
||||||
|
linkTitle: 'Install missing drivers',
|
||||||
|
linkMessage: [
|
||||||
|
'Would you like to download the necessary drivers from the Raspberry Pi Foundation?',
|
||||||
|
'This will open your browser.\n\n',
|
||||||
|
'Once opened, download and run the installer from the "Windows Installer" section to install the drivers.'
|
||||||
|
].join(' '),
|
||||||
adaptor: USBBootAdapter.id
|
adaptor: USBBootAdapter.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user