mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-18 00:36:33 +00:00
chore(app): Use settings instead of env vars
Change-Type: patch
This commit is contained in:
parent
6728382141
commit
c08cf61d0c
@ -64,9 +64,7 @@ window.localStorage.debug = process.env.DEBUG
|
|||||||
* @constant
|
* @constant
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
const BLACKLISTED_DRIVES = process.env.ETCHER_BLACKLISTED_DRIVES
|
const BLACKLISTED_DRIVES = settings.get('driveBlacklist')
|
||||||
? process.env.ETCHER_BLACKLISTED_DRIVES.split(',')
|
|
||||||
: []
|
|
||||||
|
|
||||||
const app = angular.module('Etcher', [
|
const app = angular.module('Etcher', [
|
||||||
require('angular-ui-router'),
|
require('angular-ui-router'),
|
||||||
@ -362,7 +360,7 @@ app.controller('HeaderController', function (OSOpenExternalService) {
|
|||||||
* HeaderController.shouldShowHelp()
|
* HeaderController.shouldShowHelp()
|
||||||
*/
|
*/
|
||||||
this.shouldShowHelp = () => {
|
this.shouldShowHelp = () => {
|
||||||
return !process.env.ETCHER_DISABLE_EXTERNAL_LINKS
|
return !settings.get('disableExternalLinks')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
const settings = require('../../../models/settings')
|
||||||
|
|
||||||
module.exports = function (
|
module.exports = function (
|
||||||
$uibModalInstance
|
$uibModalInstance
|
||||||
) {
|
) {
|
||||||
@ -43,6 +45,7 @@ module.exports = function (
|
|||||||
*/
|
*/
|
||||||
this.getFolderConstraint = () => {
|
this.getFolderConstraint = () => {
|
||||||
// TODO(Shou): get this dynamically from the mountpoint of a specific port in Etcher Pro
|
// TODO(Shou): get this dynamically from the mountpoint of a specific port in Etcher Pro
|
||||||
return process.env.ETCHER_FILE_BROWSER_CONSTRAIN_FOLDER
|
// TODO: Make this handle multiple constraints
|
||||||
|
return settings.get('fileBrowserConstraintPath')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ const react = require('react')
|
|||||||
const propTypes = require('prop-types')
|
const propTypes = require('prop-types')
|
||||||
const { react2angular } = require('react2angular')
|
const { react2angular } = require('react2angular')
|
||||||
const analytics = require('../modules/analytics')
|
const analytics = require('../modules/analytics')
|
||||||
|
const settings = require('../models/settings')
|
||||||
const packageJSON = require('../../../../package.json')
|
const packageJSON = require('../../../../package.json')
|
||||||
|
|
||||||
const MODULE_NAME = 'Etcher.Components.SafeWebview'
|
const MODULE_NAME = 'Etcher.Components.SafeWebview'
|
||||||
@ -217,7 +218,7 @@ class SafeWebview extends react.PureComponent {
|
|||||||
event.disposition === 'foreground-tab',
|
event.disposition === 'foreground-tab',
|
||||||
|
|
||||||
// Don't open links if they're disabled by the env var
|
// Don't open links if they're disabled by the env var
|
||||||
!process.env.ETCHER_DISABLE_EXTERNAL_LINKS
|
!settings.get('disableExternalLinks')
|
||||||
])) {
|
])) {
|
||||||
electron.shell.openExternal(url.href)
|
electron.shell.openExternal(url.href)
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ const currentWindow = electron.remote.getCurrentWindow()
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
exports.shouldCheckForUpdates = (options) => {
|
exports.shouldCheckForUpdates = (options) => {
|
||||||
if (process.env.ELECTRON_RESIN_UPDATE_LOCK) {
|
if (settings.get('resinUpdateLock')) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +79,8 @@ const readConfigFile = (filename) => {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(contents)
|
data = JSON.parse(contents)
|
||||||
} catch(e) {
|
} catch (parseError) {
|
||||||
// ignore (?)
|
// Ignore (?)
|
||||||
}
|
}
|
||||||
resolve(data)
|
resolve(data)
|
||||||
}
|
}
|
||||||
|
@ -184,6 +184,22 @@ exports.get = (key) => {
|
|||||||
return _.cloneDeep(_.get(settings, [ key ]))
|
return _.cloneDeep(_.get(settings, [ key ]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Check if setting value exists
|
||||||
|
* @function
|
||||||
|
* @public
|
||||||
|
*
|
||||||
|
* @param {String} key - setting key
|
||||||
|
* @returns {Boolean} exists
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const hasValue = settings.has('unmountOnSuccess');
|
||||||
|
*/
|
||||||
|
exports.has = (key) => {
|
||||||
|
/* eslint-disable no-eq-null */
|
||||||
|
return settings[key] != null
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Get all setting values
|
* @summary Get all setting values
|
||||||
* @function
|
* @function
|
||||||
|
@ -25,6 +25,7 @@ const supportedFormats = require('../../../shared/supported-formats')
|
|||||||
const errors = require('../../../shared/errors')
|
const errors = require('../../../shared/errors')
|
||||||
const fileExtensions = require('../../../shared/file-extensions')
|
const fileExtensions = require('../../../shared/file-extensions')
|
||||||
const utils = require('../../../shared/utils')
|
const utils = require('../../../shared/utils')
|
||||||
|
const settings = require('./settings')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Verify and throw if any state fields are nil
|
* @summary Verify and throw if any state fields are nil
|
||||||
@ -184,7 +185,7 @@ const storeReducer = (state = DEFAULT_STATE, action) => {
|
|||||||
return accState
|
return accState
|
||||||
}, newState)
|
}, newState)
|
||||||
|
|
||||||
const shouldAutoselectAll = Boolean(process.env.ETCHER_DISABLE_EXPLICIT_DRIVE_SELECTION)
|
const shouldAutoselectAll = Boolean(settings.get('disableExplicitDriveSelection'))
|
||||||
const AUTOSELECT_DRIVE_COUNT = 1
|
const AUTOSELECT_DRIVE_COUNT = 1
|
||||||
const nonStaleSelectedDevices = nonStaleNewState.getIn([ 'selection', 'devices' ]).toJS()
|
const nonStaleSelectedDevices = nonStaleNewState.getIn([ 'selection', 'devices' ]).toJS()
|
||||||
const hasSelectedDevices = nonStaleSelectedDevices.length >= AUTOSELECT_DRIVE_COUNT
|
const hasSelectedDevices = nonStaleSelectedDevices.length >= AUTOSELECT_DRIVE_COUNT
|
||||||
|
@ -23,9 +23,9 @@ const settings = require('../models/settings')
|
|||||||
|
|
||||||
resinCorvus.install({
|
resinCorvus.install({
|
||||||
services: {
|
services: {
|
||||||
sentry: process.env.ANALYTICS_SENTRY_TOKEN ||
|
sentry: settings.get('analyticsSentryToken') ||
|
||||||
_.get(packageJSON, [ 'analytics', 'sentry', 'token' ]),
|
_.get(packageJSON, [ 'analytics', 'sentry', 'token' ]),
|
||||||
mixpanel: process.env.ANALYTICS_MIXPANEL_TOKEN ||
|
mixpanel: settings.get('analyticsMixpanelToken') ||
|
||||||
_.get(packageJSON, [ 'analytics', 'mixpanel', 'token' ])
|
_.get(packageJSON, [ 'analytics', 'mixpanel', 'token' ])
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
@ -23,7 +23,7 @@ const permissions = require('../../../shared/permissions')
|
|||||||
const scanner = SDK.createScanner({
|
const scanner = SDK.createScanner({
|
||||||
blockdevice: {
|
blockdevice: {
|
||||||
get includeSystemDrives () {
|
get includeSystemDrives () {
|
||||||
return settings.get('unsafeMode') && !process.env.ETCHER_HIDE_UNSAFE_MODE
|
return settings.get('unsafeMode') && !settings.get('disableUnsafeMode')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
usbboot: {}
|
usbboot: {}
|
||||||
|
@ -21,6 +21,7 @@ const EventEmitter = require('events')
|
|||||||
const createInactivityTimer = require('inactivity-timer')
|
const createInactivityTimer = require('inactivity-timer')
|
||||||
const debug = require('debug')('etcher:update-lock')
|
const debug = require('debug')('etcher:update-lock')
|
||||||
const analytics = require('./analytics')
|
const analytics = require('./analytics')
|
||||||
|
const settings = require('../models/settings')
|
||||||
|
|
||||||
/* eslint-disable no-magic-numbers, callback-return */
|
/* eslint-disable no-magic-numbers, callback-return */
|
||||||
|
|
||||||
@ -29,8 +30,8 @@ const analytics = require('./analytics')
|
|||||||
* @type {Number}
|
* @type {Number}
|
||||||
* @constant
|
* @constant
|
||||||
*/
|
*/
|
||||||
const INTERACTION_TIMEOUT_MS = process.env.ETCHER_INTERACTION_TIMEOUT_MS
|
const INTERACTION_TIMEOUT_MS = settings.has('interactionTimeout')
|
||||||
? parseInt(process.env.ETCHER_INTERACTION_TIMEOUT_MS, 10)
|
? parseInt(settings.get('interactionTimeout'), 10)
|
||||||
: 5 * 60 * 1000
|
: 5 * 60 * 1000
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +61,7 @@ class UpdateLock extends EventEmitter {
|
|||||||
* this.on('inactive', onInactive)
|
* this.on('inactive', onInactive)
|
||||||
*/
|
*/
|
||||||
static onInactive () {
|
static onInactive () {
|
||||||
if (process.env.ELECTRON_RESIN_UPDATE_LOCK) {
|
if (settings.get('resinUpdateLock')) {
|
||||||
UpdateLock.check((checkError, isLocked) => {
|
UpdateLock.check((checkError, isLocked) => {
|
||||||
debug('inactive-check', Boolean(checkError))
|
debug('inactive-check', Boolean(checkError))
|
||||||
if (checkError) {
|
if (checkError) {
|
||||||
@ -89,7 +90,7 @@ class UpdateLock extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
static acquire (callback) {
|
static acquire (callback) {
|
||||||
debug('lock')
|
debug('lock')
|
||||||
if (process.env.ELECTRON_RESIN_UPDATE_LOCK) {
|
if (settings.get('resinUpdateLock')) {
|
||||||
electron.ipcRenderer.once('resin-update-lock', (event, error) => {
|
electron.ipcRenderer.once('resin-update-lock', (event, error) => {
|
||||||
callback(error)
|
callback(error)
|
||||||
})
|
})
|
||||||
@ -110,7 +111,7 @@ class UpdateLock extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
static release (callback) {
|
static release (callback) {
|
||||||
debug('unlock')
|
debug('unlock')
|
||||||
if (process.env.ELECTRON_RESIN_UPDATE_LOCK) {
|
if (settings.get('resinUpdateLock')) {
|
||||||
electron.ipcRenderer.once('resin-update-lock', (event, error) => {
|
electron.ipcRenderer.once('resin-update-lock', (event, error) => {
|
||||||
callback(error)
|
callback(error)
|
||||||
})
|
})
|
||||||
@ -133,7 +134,7 @@ class UpdateLock extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
static check (callback) {
|
static check (callback) {
|
||||||
debug('check')
|
debug('check')
|
||||||
if (process.env.ELECTRON_RESIN_UPDATE_LOCK) {
|
if (settings.get('resinUpdateLock')) {
|
||||||
electron.ipcRenderer.once('resin-update-lock', (event, error, isLocked) => {
|
electron.ipcRenderer.once('resin-update-lock', (event, error, isLocked) => {
|
||||||
callback(error, isLocked)
|
callback(error, isLocked)
|
||||||
})
|
})
|
||||||
@ -160,7 +161,7 @@ class UpdateLock extends EventEmitter {
|
|||||||
|
|
||||||
// When extending, check that we have the lock,
|
// When extending, check that we have the lock,
|
||||||
// and acquire it, if not
|
// and acquire it, if not
|
||||||
if (process.env.ELECTRON_RESIN_UPDATE_LOCK) {
|
if (settings.get('resinUpdateLock')) {
|
||||||
UpdateLock.check((checkError, isLocked) => {
|
UpdateLock.check((checkError, isLocked) => {
|
||||||
if (checkError) {
|
if (checkError) {
|
||||||
analytics.logException(checkError)
|
analytics.logException(checkError)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const analytics = require('../../../modules/analytics')
|
const analytics = require('../../../modules/analytics')
|
||||||
|
const settings = require('../../../models/settings')
|
||||||
|
|
||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
/**
|
/**
|
||||||
@ -32,7 +33,7 @@ module.exports = function () {
|
|||||||
*/
|
*/
|
||||||
this.open = (url) => {
|
this.open = (url) => {
|
||||||
// Don't open links if they're disabled by the env var
|
// Don't open links if they're disabled by the env var
|
||||||
if (process.env.ETCHER_DISABLE_EXTERNAL_LINKS) {
|
if (settings.get('disableExternalLinks')) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ module.exports = function (DriveSelectorService) {
|
|||||||
|
|
||||||
analytics.logEvent('Select drive', {
|
analytics.logEvent('Select drive', {
|
||||||
device: drive.device,
|
device: drive.device,
|
||||||
unsafeMode: settings.get('unsafeMode') && !process.env.ETCHER_HIDE_UNSAFE_MODE
|
unsafeMode: settings.get('unsafeMode') && !settings.get('disableUnsafeMode')
|
||||||
})
|
})
|
||||||
}).catch(exceptionReporter.report)
|
}).catch(exceptionReporter.report)
|
||||||
}
|
}
|
||||||
@ -148,6 +148,6 @@ module.exports = function (DriveSelectorService) {
|
|||||||
* DriveSelectionController.shouldShowDrivesButton()
|
* DriveSelectionController.shouldShowDrivesButton()
|
||||||
*/
|
*/
|
||||||
this.shouldShowDrivesButton = () => {
|
this.shouldShowDrivesButton = () => {
|
||||||
return !process.env.ETCHER_DISABLE_EXPLICIT_DRIVE_SELECTION
|
return !settings.get('disableExplicitDriveSelection')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ const errors = require('../../../../../shared/errors')
|
|||||||
const imageStream = require('../../../../../sdk/image-stream')
|
const imageStream = require('../../../../../sdk/image-stream')
|
||||||
const supportedFormats = require('../../../../../shared/supported-formats')
|
const supportedFormats = require('../../../../../shared/supported-formats')
|
||||||
const analytics = require('../../../modules/analytics')
|
const analytics = require('../../../modules/analytics')
|
||||||
|
const settings = require('../../../models/settings')
|
||||||
const selectionState = require('../../../models/selection-state')
|
const selectionState = require('../../../models/selection-state')
|
||||||
const osDialog = require('../../../os/dialog')
|
const osDialog = require('../../../os/dialog')
|
||||||
const exceptionReporter = require('../../../modules/exception-reporter')
|
const exceptionReporter = require('../../../modules/exception-reporter')
|
||||||
@ -156,7 +157,7 @@ module.exports = function (
|
|||||||
this.openImageSelector = () => {
|
this.openImageSelector = () => {
|
||||||
analytics.logEvent('Open image selector')
|
analytics.logEvent('Open image selector')
|
||||||
|
|
||||||
if (process.env.ETCHER_EXPERIMENTAL_FILE_PICKER) {
|
if (settings.get('experimentalFilePicker')) {
|
||||||
FileSelectorService.open()
|
FileSelectorService.open()
|
||||||
} else {
|
} else {
|
||||||
osDialog.selectImage().then((imagePath) => {
|
osDialog.selectImage().then((imagePath) => {
|
||||||
|
@ -116,6 +116,6 @@ module.exports = function (WarningModalService) {
|
|||||||
* SettingsController.shouldShowUnsafeMode()
|
* SettingsController.shouldShowUnsafeMode()
|
||||||
*/
|
*/
|
||||||
this.shouldShowUnsafeMode = () => {
|
this.shouldShowUnsafeMode = () => {
|
||||||
return !process.env.ETCHER_HIDE_UNSAFE_MODE
|
return !settings.get('disableUnsafeMode')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user