move disableI18n to app settings
parent
5470bae8b9
commit
7ab26c950b
|
@ -82,7 +82,7 @@ describe("maybeToggleFeature()", () => {
|
|||
describe("fetchLabFeatures", () => {
|
||||
it("basically just initializes stuff", () => {
|
||||
const val = fetchLabFeatures();
|
||||
expect(val.length).toBe(2);
|
||||
expect(val.length).toBe(3);
|
||||
expect(val[0].value).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,14 +2,15 @@ import * as React from "react";
|
|||
import { WidgetHeader, Widget, WidgetBody } from "../../ui/index";
|
||||
import { LabsFeaturesList } from "./labs_features_list_ui";
|
||||
import { maybeToggleFeature } from "./labs_features_list_data";
|
||||
import { t } from "i18next";
|
||||
|
||||
export class LabsFeatures extends React.Component<{}, {}> {
|
||||
state = {};
|
||||
|
||||
render() {
|
||||
return <Widget className="peripherals-widget">
|
||||
<WidgetHeader title={"App Settings"}
|
||||
helpText={"Customize your web app experience."}>
|
||||
<WidgetHeader title={t("App Settings")}
|
||||
helpText={t("Customize your web app experience.")}>
|
||||
</WidgetHeader>
|
||||
<WidgetBody>
|
||||
<LabsFeaturesList onToggle={(x) => {
|
||||
|
|
|
@ -2,6 +2,7 @@ import { Content } from "../../constants";
|
|||
import { Session } from "../../session";
|
||||
import { BooleanSetting } from "../../session_keys";
|
||||
import { trim } from "../../util";
|
||||
import { t } from "i18next";
|
||||
|
||||
export interface LabsFeature {
|
||||
name: string;
|
||||
|
@ -14,18 +15,24 @@ export interface LabsFeature {
|
|||
|
||||
export const fetchLabFeatures = (): LabsFeature[] => ([
|
||||
{
|
||||
name: "Hide Webcam Widget",
|
||||
description: trim(`If not using a webcam, use this setting to remove the
|
||||
widget from the Controls page.`),
|
||||
storageKey: BooleanSetting.hideWebcamWidget,
|
||||
name: t("Disable Web App internationalization"),
|
||||
description: t("Set Web App to English."),
|
||||
storageKey: BooleanSetting.disableI18n,
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Confirm Sequence Step Deletion",
|
||||
description: trim(`Show a confirmation dialog when the sequence delete step
|
||||
icon is pressed.`),
|
||||
name: t("Confirm Sequence step deletion"),
|
||||
description: trim(t(`Show a confirmation dialog when the sequence delete step
|
||||
icon is pressed.`)),
|
||||
storageKey: BooleanSetting.confirmStepDeletion,
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: t("Hide Webcam widget"),
|
||||
description: trim(t(`If not using a webcam, use this setting to remove the
|
||||
widget from the Controls page.`)),
|
||||
storageKey: BooleanSetting.hideWebcamWidget,
|
||||
value: false
|
||||
}
|
||||
].map(fetchRealValue));
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ describe("AdditionalMenu", () => {
|
|||
close={jest.fn()} />);
|
||||
const text = wrapper.text();
|
||||
expect(text).toContain("Account Settings");
|
||||
expect(text).toContain("Set Page to English");
|
||||
expect(text).toContain("Documentation");
|
||||
expect(text).toContain("Logout");
|
||||
expect(text).toContain("VERSION");
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
import * as React from "react";
|
||||
import { LangToggle } from "../lang_toggle";
|
||||
import { mount } from "enzyme";
|
||||
import { Session } from "../../session";
|
||||
import { BooleanSetting } from "../../session_keys";
|
||||
|
||||
describe("<LangToggle/>", () => {
|
||||
it("allows toggling between English and local i18n", () => {
|
||||
jest.mock("../../i18n", () => {
|
||||
return {
|
||||
detectLanguage: () => {
|
||||
return Promise.resolve({
|
||||
nsSeparator: "",
|
||||
keySeparator: "",
|
||||
lng: "es",
|
||||
resources: {
|
||||
es: { translation: {} }
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
const el = mount(<LangToggle />);
|
||||
expect(Session.getBool(BooleanSetting.disableI18n)).toBeFalsy();
|
||||
expect(el.text().toLocaleLowerCase()).toContain("set page to english");
|
||||
el.find("a").first().simulate("click");
|
||||
el.update();
|
||||
expect(Session.getBool(BooleanSetting.disableI18n)).toBeTruthy();
|
||||
expect(el.text().toLocaleLowerCase()).not.toContain("set page to english");
|
||||
expect(el.text().toLocaleLowerCase()).toContain("internationalize page");
|
||||
});
|
||||
});
|
|
@ -1,7 +1,6 @@
|
|||
import * as React from "react";
|
||||
import { Link } from "react-router";
|
||||
import { t } from "i18next";
|
||||
import { LangToggle } from "./lang_toggle";
|
||||
import { AccountMenuProps } from "./interfaces";
|
||||
|
||||
export const AdditionalMenu = (props: AccountMenuProps) => {
|
||||
|
@ -10,7 +9,6 @@ export const AdditionalMenu = (props: AccountMenuProps) => {
|
|||
<i className="fa fa-cog"></i>
|
||||
{t("Account Settings")}
|
||||
</Link>
|
||||
<LangToggle />
|
||||
<div>
|
||||
<a href="https://software.farmbot.io/docs/the-farmbot-web-app"
|
||||
target="_blank">
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
import * as React from "react";
|
||||
import { Session } from "../session";
|
||||
import { BooleanSetting } from "../session_keys";
|
||||
|
||||
interface Props {
|
||||
|
||||
}
|
||||
|
||||
interface State {
|
||||
|
||||
}
|
||||
|
||||
export class LangToggle extends React.Component<Props, State> {
|
||||
state: State = {};
|
||||
|
||||
toggle = () => {
|
||||
Session.setBool(BooleanSetting.disableI18n, !this.disabled());
|
||||
this.setState({ clicked: true });
|
||||
};
|
||||
|
||||
disabled = () => Session.getBool(BooleanSetting.disableI18n);
|
||||
|
||||
verbiage() {
|
||||
return (this.disabled() ? "Internationalize Page" : "Set Page to English");
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div>
|
||||
<a onClick={this.toggle} href={window.location.href}>
|
||||
<i className="fa fa-globe"></i>
|
||||
{this.verbiage()}
|
||||
</a>
|
||||
</div>;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ export enum BooleanSetting {
|
|||
zAxisInverted = "zAxisInverted",
|
||||
rawEncoders = "rawEncoders",
|
||||
scaledEncoders = "scaledEncoders",
|
||||
disableI18n = "disableI18n",
|
||||
legendMenuOpen = "legendMenuOpen",
|
||||
showPlants = "showPlants",
|
||||
showPoints = "showPoints",
|
||||
|
@ -13,8 +12,9 @@ export enum BooleanSetting {
|
|||
|
||||
/** "Labs" feature names. */
|
||||
weedDetector = "weedDetector",
|
||||
hideWebcamWidget = "hideWebcamWidget",
|
||||
disableI18n = "disableI18n",
|
||||
confirmStepDeletion = "confirmStepDeletion",
|
||||
hideWebcamWidget = "hideWebcamWidget",
|
||||
}
|
||||
|
||||
export enum NumericSetting {
|
||||
|
|
Loading…
Reference in New Issue