mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-20 17:56:31 +00:00
Use Dictionary type from lodash
Change-type: patch
This commit is contained in:
parent
bd35c89c04
commit
2671c83337
@ -23,7 +23,6 @@ import { Badge, Checkbox, Modal } from 'rendition';
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { version } from '../../../../../package.json';
|
import { version } from '../../../../../package.json';
|
||||||
import { Dictionary } from '../../../../shared/utils';
|
|
||||||
import * as settings from '../../models/settings';
|
import * as settings from '../../models/settings';
|
||||||
import { store } from '../../models/store';
|
import { store } from '../../models/store';
|
||||||
import * as analytics from '../../modules/analytics';
|
import * as analytics from '../../modules/analytics';
|
||||||
@ -122,8 +121,8 @@ interface SettingsModalProps {
|
|||||||
export const SettingsModal: any = styled(
|
export const SettingsModal: any = styled(
|
||||||
({ toggleModal }: SettingsModalProps) => {
|
({ toggleModal }: SettingsModalProps) => {
|
||||||
const [currentSettings, setCurrentSettings]: [
|
const [currentSettings, setCurrentSettings]: [
|
||||||
Dictionary<any>,
|
_.Dictionary<any>,
|
||||||
React.Dispatch<React.SetStateAction<Dictionary<any>>>,
|
React.Dispatch<React.SetStateAction<_.Dictionary<any>>>,
|
||||||
] = useState(settings.getAll());
|
] = useState(settings.getAll());
|
||||||
const [warning, setWarning]: [
|
const [warning, setWarning]: [
|
||||||
any,
|
any,
|
||||||
|
@ -19,12 +19,11 @@ import * as _ from 'lodash';
|
|||||||
|
|
||||||
import * as packageJSON from '../../../../package.json';
|
import * as packageJSON from '../../../../package.json';
|
||||||
import * as errors from '../../../shared/errors';
|
import * as errors from '../../../shared/errors';
|
||||||
import { Dictionary } from '../../../shared/utils';
|
|
||||||
import * as localSettings from './local-settings';
|
import * as localSettings from './local-settings';
|
||||||
|
|
||||||
const debug = _debug('etcher:models:settings');
|
const debug = _debug('etcher:models:settings');
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: Dictionary<any> = {
|
const DEFAULT_SETTINGS: _.Dictionary<any> = {
|
||||||
unsafeMode: false,
|
unsafeMode: false,
|
||||||
errorReporting: true,
|
errorReporting: true,
|
||||||
unmountOnSuccess: true,
|
unmountOnSuccess: true,
|
||||||
@ -53,7 +52,7 @@ export async function reset(): Promise<void> {
|
|||||||
/**
|
/**
|
||||||
* @summary Extend the current settings
|
* @summary Extend the current settings
|
||||||
*/
|
*/
|
||||||
export async function assign(value: Dictionary<any>): Promise<void> {
|
export async function assign(value: _.Dictionary<any>): Promise<void> {
|
||||||
debug('assign', value);
|
debug('assign', value);
|
||||||
if (_.isNil(value)) {
|
if (_.isNil(value)) {
|
||||||
throw errors.createError({
|
throw errors.createError({
|
||||||
|
@ -30,7 +30,7 @@ import * as settings from './settings';
|
|||||||
* @summary Verify and throw if any state fields are nil
|
* @summary Verify and throw if any state fields are nil
|
||||||
*/
|
*/
|
||||||
function verifyNoNilFields(
|
function verifyNoNilFields(
|
||||||
object: utils.Dictionary<any>,
|
object: _.Dictionary<any>,
|
||||||
fields: string[],
|
fields: string[],
|
||||||
name: string,
|
name: string,
|
||||||
) {
|
) {
|
||||||
|
@ -26,7 +26,7 @@ import { promisify } from 'util';
|
|||||||
|
|
||||||
import { sudo as catalinaSudo } from './catalina-sudo/sudo';
|
import { sudo as catalinaSudo } from './catalina-sudo/sudo';
|
||||||
import * as errors from './errors';
|
import * as errors from './errors';
|
||||||
import { Dictionary, tmpFileDisposer } from './utils';
|
import { tmpFileDisposer } from './utils';
|
||||||
|
|
||||||
const execAsync = promisify(childProcess.exec);
|
const execAsync = promisify(childProcess.exec);
|
||||||
const execFileAsync = promisify(childProcess.execFile);
|
const execFileAsync = promisify(childProcess.execFile);
|
||||||
@ -88,7 +88,7 @@ function setEnvVarCmd(value: any, name: string): string {
|
|||||||
export function createLaunchScript(
|
export function createLaunchScript(
|
||||||
command: string,
|
command: string,
|
||||||
argv: string[],
|
argv: string[],
|
||||||
environment: Dictionary<string>,
|
environment: _.Dictionary<string>,
|
||||||
): string {
|
): string {
|
||||||
const isWindows = os.platform() === 'win32';
|
const isWindows = os.platform() === 'win32';
|
||||||
const lines = [];
|
const lines = [];
|
||||||
@ -144,7 +144,7 @@ async function elevateScriptCatalina(
|
|||||||
export async function elevateCommand(
|
export async function elevateCommand(
|
||||||
command: string[],
|
command: string[],
|
||||||
options: {
|
options: {
|
||||||
environment: Dictionary<string | undefined>;
|
environment: _.Dictionary<string | undefined>;
|
||||||
applicationName: string;
|
applicationName: string;
|
||||||
},
|
},
|
||||||
): Promise<{ cancelled: boolean }> {
|
): Promise<{ cancelled: boolean }> {
|
||||||
|
@ -24,10 +24,6 @@ import * as errors from './errors';
|
|||||||
|
|
||||||
const getAsync = promisify(request.get);
|
const getAsync = promisify(request.get);
|
||||||
|
|
||||||
export interface Dictionary<T> {
|
|
||||||
[key: string]: T;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isValidPercentage(percentage: any): boolean {
|
export function isValidPercentage(percentage: any): boolean {
|
||||||
return _.every([_.isNumber(percentage), percentage >= 0, percentage <= 100]);
|
return _.every([_.isNumber(percentage), percentage >= 0, percentage <= 100]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user