Use Dictionary type from lodash

Change-type: patch
This commit is contained in:
Alexis Svinartchouk 2020-01-14 17:45:14 +01:00
parent bd35c89c04
commit 2671c83337
5 changed files with 8 additions and 14 deletions

View File

@ -23,7 +23,6 @@ import { Badge, Checkbox, Modal } from 'rendition';
import styled from 'styled-components';
import { version } from '../../../../../package.json';
import { Dictionary } from '../../../../shared/utils';
import * as settings from '../../models/settings';
import { store } from '../../models/store';
import * as analytics from '../../modules/analytics';
@ -122,8 +121,8 @@ interface SettingsModalProps {
export const SettingsModal: any = styled(
({ toggleModal }: SettingsModalProps) => {
const [currentSettings, setCurrentSettings]: [
Dictionary<any>,
React.Dispatch<React.SetStateAction<Dictionary<any>>>,
_.Dictionary<any>,
React.Dispatch<React.SetStateAction<_.Dictionary<any>>>,
] = useState(settings.getAll());
const [warning, setWarning]: [
any,

View File

@ -19,12 +19,11 @@ import * as _ from 'lodash';
import * as packageJSON from '../../../../package.json';
import * as errors from '../../../shared/errors';
import { Dictionary } from '../../../shared/utils';
import * as localSettings from './local-settings';
const debug = _debug('etcher:models:settings');
const DEFAULT_SETTINGS: Dictionary<any> = {
const DEFAULT_SETTINGS: _.Dictionary<any> = {
unsafeMode: false,
errorReporting: true,
unmountOnSuccess: true,
@ -53,7 +52,7 @@ export async function reset(): Promise<void> {
/**
* @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);
if (_.isNil(value)) {
throw errors.createError({

View File

@ -30,7 +30,7 @@ import * as settings from './settings';
* @summary Verify and throw if any state fields are nil
*/
function verifyNoNilFields(
object: utils.Dictionary<any>,
object: _.Dictionary<any>,
fields: string[],
name: string,
) {

View File

@ -26,7 +26,7 @@ import { promisify } from 'util';
import { sudo as catalinaSudo } from './catalina-sudo/sudo';
import * as errors from './errors';
import { Dictionary, tmpFileDisposer } from './utils';
import { tmpFileDisposer } from './utils';
const execAsync = promisify(childProcess.exec);
const execFileAsync = promisify(childProcess.execFile);
@ -88,7 +88,7 @@ function setEnvVarCmd(value: any, name: string): string {
export function createLaunchScript(
command: string,
argv: string[],
environment: Dictionary<string>,
environment: _.Dictionary<string>,
): string {
const isWindows = os.platform() === 'win32';
const lines = [];
@ -144,7 +144,7 @@ async function elevateScriptCatalina(
export async function elevateCommand(
command: string[],
options: {
environment: Dictionary<string | undefined>;
environment: _.Dictionary<string | undefined>;
applicationName: string;
},
): Promise<{ cancelled: boolean }> {

View File

@ -24,10 +24,6 @@ import * as errors from './errors';
const getAsync = promisify(request.get);
export interface Dictionary<T> {
[key: string]: T;
}
export function isValidPercentage(percentage: any): boolean {
return _.every([_.isNumber(percentage), percentage >= 0, percentage <= 100]);
}