additions to merge changes
parent
767d6936f2
commit
d3626ddac8
|
@ -27,7 +27,7 @@ describe("maybeToggleFeature()", () => {
|
|||
value: false,
|
||||
description: "I stub this.",
|
||||
storageKey: BooleanSetting.stub_config,
|
||||
experimental: true
|
||||
confirmationMessage: "are you sure?"
|
||||
};
|
||||
const out = maybeToggleFeature(data);
|
||||
expect(data.value).toBeFalsy();
|
||||
|
@ -42,7 +42,7 @@ describe("maybeToggleFeature()", () => {
|
|||
value: (mockStorj[BooleanSetting.stub_config] = false),
|
||||
description: "I stub this.",
|
||||
storageKey: BooleanSetting.stub_config,
|
||||
experimental: true
|
||||
confirmationMessage: "are you sure?"
|
||||
};
|
||||
const out = maybeToggleFeature(data);
|
||||
out ?
|
||||
|
@ -58,7 +58,7 @@ describe("maybeToggleFeature()", () => {
|
|||
value: (mockStorj[BooleanSetting.stub_config] = true),
|
||||
description: "I stub this.",
|
||||
storageKey: BooleanSetting.stub_config,
|
||||
experimental: true
|
||||
confirmationMessage: "are you sure?"
|
||||
});
|
||||
expect(conf).not.toHaveBeenCalled();
|
||||
output ?
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Content } from "../../constants";
|
||||
import { Session } from "../../session";
|
||||
import { trim } from "../../util";
|
||||
import { t } from "i18next";
|
||||
|
@ -6,12 +5,16 @@ import { BooleanConfigKey } from "../../config_storage/web_app_configs";
|
|||
import { BooleanSetting } from "../../session_keys";
|
||||
|
||||
export interface LabsFeature {
|
||||
/** Toggle label. */
|
||||
name: string;
|
||||
description: string;
|
||||
/** Entry for localStorage. Must be unique. */
|
||||
storageKey: BooleanConfigKey;
|
||||
/** Placeholder value (use false). */
|
||||
value: boolean;
|
||||
experimental?: boolean;
|
||||
/** Confirmation message to display before allowing a toggle to true. */
|
||||
confirmationMessage?: string;
|
||||
/** Invert displayed toggle value for `disable_` settings. */
|
||||
displayInvert?: boolean;
|
||||
/** If the feature requires any special logic after being flipped, add it
|
||||
* here. */
|
||||
|
@ -73,9 +76,11 @@ export const fetchLabFeatures = (): LabsFeature[] => ([
|
|||
{
|
||||
name: t("Discard Unsaved Changes"),
|
||||
description: trim(t(`Don't ask about saving work before
|
||||
closing browser tab.`)),
|
||||
closing browser tab. Warning: may cause loss of data.`)),
|
||||
storageKey: BooleanSetting.discard_unsaved,
|
||||
value: false
|
||||
value: false,
|
||||
confirmationMessage: trim(t(`Warning! When enabled, any unsaved changes
|
||||
will be discarded when refreshing or closing the page. Are you sure?`))
|
||||
},
|
||||
].map(fetchRealValue));
|
||||
|
||||
|
@ -84,8 +89,8 @@ export const fetchLabFeatures = (): LabsFeature[] => ([
|
|||
export const maybeToggleFeature =
|
||||
(x: LabsFeature): LabsFeature | undefined => {
|
||||
return (x.value
|
||||
|| !x.experimental
|
||||
|| window.confirm(Content.EXPERIMENTAL_WARNING)) ?
|
||||
|| !x.confirmationMessage
|
||||
|| window.confirm(x.confirmationMessage)) ?
|
||||
toggleFeatureValue(x) : undefined;
|
||||
};
|
||||
|
||||
|
|
|
@ -8,12 +8,6 @@ jest.mock("../../api/crud", () => {
|
|||
});
|
||||
|
||||
let mockConfig = fakeWebAppConfig();
|
||||
jest.mock("../../resources/selectors", () => {
|
||||
return {
|
||||
assertUuid: jest.fn()
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock("../../resources/config_selectors", () => {
|
||||
return {
|
||||
getWebAppConfig: () => mockConfig
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
import { fakeFbosConfig } from "../../__test_support__/fake_state/resources";
|
||||
|
||||
let mockFbosConfig: TaggedFbosConfig | undefined = fakeFbosConfig();
|
||||
jest.mock("../../resources/selectors", () => ({
|
||||
getDeviceAccountSettings: jest.fn(),
|
||||
assertUuid: jest.fn(),
|
||||
getFbosConfig: () => mockFbosConfig,
|
||||
selectAllImages: jest.fn()
|
||||
jest.mock("../../resources/config_selectors", () => ({
|
||||
getFbosConfig: () => mockFbosConfig
|
||||
}));
|
||||
|
||||
import { mapStateToProps } from "../state_to_props";
|
||||
|
|
|
@ -12,7 +12,7 @@ import { Sequence } from "../sequences/interfaces";
|
|||
import { ControlPanelState } from "../devices/interfaces";
|
||||
import { API } from "../api/index";
|
||||
import { User } from "../auth/interfaces";
|
||||
import { getDeviceAccountSettings, getFbosConfig } from "../resources/selectors";
|
||||
import { getDeviceAccountSettings } from "../resources/selectors";
|
||||
import { TaggedDevice } from "../resources/tagged_resources";
|
||||
import { versionOK } from "./reducer";
|
||||
import { HttpData, oneOf } from "../util";
|
||||
|
@ -21,6 +21,7 @@ import { mcuParamValidator } from "./update_interceptor";
|
|||
import { pingAPI } from "../connectivity/ping_mqtt";
|
||||
import { edit, save as apiSave } from "../api/crud";
|
||||
import { WebAppConfig } from "../config_storage/web_app_configs";
|
||||
import { getFbosConfig } from "../resources/config_selectors";
|
||||
|
||||
const ON = 1, OFF = 0;
|
||||
export type ConfigKey = keyof McuParams;
|
||||
|
|
|
@ -2,10 +2,10 @@ import { Everything } from "../interfaces";
|
|||
import { Props } from "./interfaces";
|
||||
import {
|
||||
selectAllImages,
|
||||
getDeviceAccountSettings,
|
||||
getFbosConfig
|
||||
getDeviceAccountSettings
|
||||
} from "../resources/selectors";
|
||||
import { sourceFbosConfigValue } from "./components/source_fbos_config_value";
|
||||
import { getFbosConfig } from "../resources/config_selectors";
|
||||
|
||||
export function mapStateToProps(props: Everything): Props {
|
||||
const conf = getFbosConfig(props.resources.index);
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import { Everything } from "../interfaces";
|
||||
import {
|
||||
selectAllLogs, maybeGetTimeOffset, getFbosConfig
|
||||
} from "../resources/selectors";
|
||||
import { selectAllLogs, maybeGetTimeOffset } from "../resources/selectors";
|
||||
import * as _ from "lodash";
|
||||
import { LogsProps } from "./interfaces";
|
||||
import {
|
||||
sourceFbosConfigValue
|
||||
} from "../devices/components/source_fbos_config_value";
|
||||
import { getFbosConfig } from "../resources/config_selectors";
|
||||
|
||||
export function mapStateToProps(props: Everything): LogsProps {
|
||||
const { hardware } = props.bot;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { ResourceIndex } from "./interfaces";
|
||||
import { TaggedWebAppConfig } from "./tagged_resources";
|
||||
import { TaggedWebAppConfig, TaggedFbosConfig } from "./tagged_resources";
|
||||
|
||||
export function getWebAppConfig(i: ResourceIndex): TaggedWebAppConfig | undefined {
|
||||
const conf = i.references[i.byKind.WebAppConfig[0] || "NO"];
|
||||
|
@ -7,3 +7,10 @@ export function getWebAppConfig(i: ResourceIndex): TaggedWebAppConfig | undefine
|
|||
return conf;
|
||||
}
|
||||
}
|
||||
|
||||
export function getFbosConfig(i: ResourceIndex): TaggedFbosConfig | undefined {
|
||||
const conf = i.references[i.byKind.FbosConfig[0] || "NO"];
|
||||
if (conf && conf.kind === "FbosConfig") {
|
||||
return conf;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import {
|
|||
TaggedUser,
|
||||
TaggedWebcamFeed,
|
||||
TaggedDevice,
|
||||
TaggedFbosConfig,
|
||||
SpecialStatus,
|
||||
TaggedPoint
|
||||
} from "./tagged_resources";
|
||||
|
@ -488,13 +487,6 @@ export function findToolBySlotId(input: ResourceIndex, tool_slot_id: number):
|
|||
}
|
||||
}
|
||||
|
||||
export function getFbosConfig(i: ResourceIndex): TaggedFbosConfig | undefined {
|
||||
const conf = i.references[i.byKind.FbosConfig[0] || "NO"];
|
||||
if (conf && conf.kind === "FbosConfig") {
|
||||
return conf;
|
||||
}
|
||||
}
|
||||
|
||||
export function getAllPeripherals(input: ResourceIndex) {
|
||||
return input
|
||||
.byKind
|
||||
|
|
|
@ -13,7 +13,7 @@ export const BooleanSetting: Record<BooleanConfigKey, BooleanConfigKey> = {
|
|||
show_farmbot: "show_farmbot",
|
||||
show_images: "show_images",
|
||||
|
||||
/** "Labs" feature names. */
|
||||
/** "Labs" feature names. (App preferences) */
|
||||
stub_config: "stub_config",
|
||||
disable_i18n: "disable_i18n",
|
||||
confirm_step_deletion: "confirm_step_deletion",
|
||||
|
@ -24,12 +24,10 @@ export const BooleanSetting: Record<BooleanConfigKey, BooleanConfigKey> = {
|
|||
display_trail: "display_trail",
|
||||
encoder_figure: "encoder_figure",
|
||||
enable_browser_speak: "enable_browser_speak",
|
||||
discard_unsaved: "discard_unsaved",
|
||||
|
||||
/** Farmware Settings Panel */
|
||||
show_first_party_farmware: "show_first_party_farmware",
|
||||
|
||||
/** App preferences */
|
||||
discard_unsaved: "discard_unsaved"
|
||||
};
|
||||
|
||||
export const NumericSetting: Record<NumberConfigKey, NumberConfigKey> = {
|
||||
|
|
Loading…
Reference in New Issue