mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 03:06:38 +00:00
Remove unused warning in settings
Change-type: patch Changelog-entry: Remove unused warning in settings Signed-off-by: Lorenzo Alberto Maria Ambrosi <lorenzothunder.ambrosi@gmail.com>
This commit is contained in:
parent
3ca50a1e2d
commit
098ca9a9a1
@ -19,7 +19,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Checkbox, Flex, Modal as SmallModal, Txt } from 'rendition';
|
import { Checkbox, Flex, Txt } from 'rendition';
|
||||||
|
|
||||||
import { version, packageType } from '../../../../../package.json';
|
import { version, packageType } from '../../../../../package.json';
|
||||||
import * as settings from '../../models/settings';
|
import * as settings from '../../models/settings';
|
||||||
@ -29,36 +29,6 @@ import { Modal } from '../../styled-components';
|
|||||||
|
|
||||||
const platform = os.platform();
|
const platform = os.platform();
|
||||||
|
|
||||||
interface WarningModalProps {
|
|
||||||
message: string;
|
|
||||||
confirmLabel: string;
|
|
||||||
cancel: () => void;
|
|
||||||
done: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const WarningModal = ({
|
|
||||||
message,
|
|
||||||
confirmLabel,
|
|
||||||
cancel,
|
|
||||||
done,
|
|
||||||
}: WarningModalProps) => {
|
|
||||||
return (
|
|
||||||
<SmallModal
|
|
||||||
title={confirmLabel}
|
|
||||||
action={confirmLabel}
|
|
||||||
cancel={cancel}
|
|
||||||
done={done}
|
|
||||||
style={{
|
|
||||||
width: 420,
|
|
||||||
height: 300,
|
|
||||||
}}
|
|
||||||
primaryButtonProps={{ warning: true }}
|
|
||||||
>
|
|
||||||
{message}
|
|
||||||
</SmallModal>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
interface Setting {
|
interface Setting {
|
||||||
name: string;
|
name: string;
|
||||||
label: string | JSX.Element;
|
label: string | JSX.Element;
|
||||||
@ -97,13 +67,6 @@ async function getSettingsList(): Promise<Setting[]> {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Warning {
|
|
||||||
setting: string;
|
|
||||||
settingValue: boolean;
|
|
||||||
description: string;
|
|
||||||
confirmLabel: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SettingsModalProps {
|
interface SettingsModalProps {
|
||||||
toggleModal: (value: boolean) => void;
|
toggleModal: (value: boolean) => void;
|
||||||
}
|
}
|
||||||
@ -127,7 +90,6 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) {
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
const [warning, setWarning] = React.useState<Warning | undefined>(undefined);
|
|
||||||
|
|
||||||
const toggleSetting = async (
|
const toggleSetting = async (
|
||||||
setting: string,
|
setting: string,
|
||||||
@ -142,22 +104,12 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) {
|
|||||||
dangerous,
|
dangerous,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (value || options === undefined) {
|
await settings.set(setting, !value);
|
||||||
await settings.set(setting, !value);
|
setCurrentSettings({
|
||||||
setCurrentSettings({
|
...currentSettings,
|
||||||
...currentSettings,
|
[setting]: !value,
|
||||||
[setting]: !value,
|
});
|
||||||
});
|
return;
|
||||||
setWarning(undefined);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
// Show warning since it's a dangerous setting
|
|
||||||
setWarning({
|
|
||||||
setting,
|
|
||||||
settingValue: value,
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -205,24 +157,6 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) {
|
|||||||
<Txt style={{ borderBottom: '1px solid #00aeef' }}>{version}</Txt>
|
<Txt style={{ borderBottom: '1px solid #00aeef' }}>{version}</Txt>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
{warning === undefined ? null : (
|
|
||||||
<WarningModal
|
|
||||||
message={warning.description}
|
|
||||||
confirmLabel={warning.confirmLabel}
|
|
||||||
done={async () => {
|
|
||||||
await settings.set(warning.setting, !warning.settingValue);
|
|
||||||
setCurrentSettings({
|
|
||||||
...currentSettings,
|
|
||||||
[warning.setting]: true,
|
|
||||||
});
|
|
||||||
setWarning(undefined);
|
|
||||||
}}
|
|
||||||
cancel={() => {
|
|
||||||
setWarning(undefined);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user