move disableI18n to app settings
This commit is contained in:
parent
5470bae8b9
commit
7ab26c950b
|
@ -82,7 +82,7 @@ describe("maybeToggleFeature()", () => {
|
||||||
describe("fetchLabFeatures", () => {
|
describe("fetchLabFeatures", () => {
|
||||||
it("basically just initializes stuff", () => {
|
it("basically just initializes stuff", () => {
|
||||||
const val = fetchLabFeatures();
|
const val = fetchLabFeatures();
|
||||||
expect(val.length).toBe(2);
|
expect(val.length).toBe(3);
|
||||||
expect(val[0].value).toBeFalsy();
|
expect(val[0].value).toBeFalsy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,14 +2,15 @@ import * as React from "react";
|
||||||
import { WidgetHeader, Widget, WidgetBody } from "../../ui/index";
|
import { WidgetHeader, Widget, WidgetBody } from "../../ui/index";
|
||||||
import { LabsFeaturesList } from "./labs_features_list_ui";
|
import { LabsFeaturesList } from "./labs_features_list_ui";
|
||||||
import { maybeToggleFeature } from "./labs_features_list_data";
|
import { maybeToggleFeature } from "./labs_features_list_data";
|
||||||
|
import { t } from "i18next";
|
||||||
|
|
||||||
export class LabsFeatures extends React.Component<{}, {}> {
|
export class LabsFeatures extends React.Component<{}, {}> {
|
||||||
state = {};
|
state = {};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <Widget className="peripherals-widget">
|
return <Widget className="peripherals-widget">
|
||||||
<WidgetHeader title={"App Settings"}
|
<WidgetHeader title={t("App Settings")}
|
||||||
helpText={"Customize your web app experience."}>
|
helpText={t("Customize your web app experience.")}>
|
||||||
</WidgetHeader>
|
</WidgetHeader>
|
||||||
<WidgetBody>
|
<WidgetBody>
|
||||||
<LabsFeaturesList onToggle={(x) => {
|
<LabsFeaturesList onToggle={(x) => {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { Content } from "../../constants";
|
||||||
import { Session } from "../../session";
|
import { Session } from "../../session";
|
||||||
import { BooleanSetting } from "../../session_keys";
|
import { BooleanSetting } from "../../session_keys";
|
||||||
import { trim } from "../../util";
|
import { trim } from "../../util";
|
||||||
|
import { t } from "i18next";
|
||||||
|
|
||||||
export interface LabsFeature {
|
export interface LabsFeature {
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -14,18 +15,24 @@ export interface LabsFeature {
|
||||||
|
|
||||||
export const fetchLabFeatures = (): LabsFeature[] => ([
|
export const fetchLabFeatures = (): LabsFeature[] => ([
|
||||||
{
|
{
|
||||||
name: "Hide Webcam Widget",
|
name: t("Disable Web App internationalization"),
|
||||||
description: trim(`If not using a webcam, use this setting to remove the
|
description: t("Set Web App to English."),
|
||||||
widget from the Controls page.`),
|
storageKey: BooleanSetting.disableI18n,
|
||||||
storageKey: BooleanSetting.hideWebcamWidget,
|
|
||||||
value: false
|
value: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Confirm Sequence Step Deletion",
|
name: t("Confirm Sequence step deletion"),
|
||||||
description: trim(`Show a confirmation dialog when the sequence delete step
|
description: trim(t(`Show a confirmation dialog when the sequence delete step
|
||||||
icon is pressed.`),
|
icon is pressed.`)),
|
||||||
storageKey: BooleanSetting.confirmStepDeletion,
|
storageKey: BooleanSetting.confirmStepDeletion,
|
||||||
value: false
|
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));
|
].map(fetchRealValue));
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ describe("AdditionalMenu", () => {
|
||||||
close={jest.fn()} />);
|
close={jest.fn()} />);
|
||||||
const text = wrapper.text();
|
const text = wrapper.text();
|
||||||
expect(text).toContain("Account Settings");
|
expect(text).toContain("Account Settings");
|
||||||
expect(text).toContain("Set Page to English");
|
|
||||||
expect(text).toContain("Documentation");
|
expect(text).toContain("Documentation");
|
||||||
expect(text).toContain("Logout");
|
expect(text).toContain("Logout");
|
||||||
expect(text).toContain("VERSION");
|
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 * as React from "react";
|
||||||
import { Link } from "react-router";
|
import { Link } from "react-router";
|
||||||
import { t } from "i18next";
|
import { t } from "i18next";
|
||||||
import { LangToggle } from "./lang_toggle";
|
|
||||||
import { AccountMenuProps } from "./interfaces";
|
import { AccountMenuProps } from "./interfaces";
|
||||||
|
|
||||||
export const AdditionalMenu = (props: AccountMenuProps) => {
|
export const AdditionalMenu = (props: AccountMenuProps) => {
|
||||||
|
@ -10,7 +9,6 @@ export const AdditionalMenu = (props: AccountMenuProps) => {
|
||||||
<i className="fa fa-cog"></i>
|
<i className="fa fa-cog"></i>
|
||||||
{t("Account Settings")}
|
{t("Account Settings")}
|
||||||
</Link>
|
</Link>
|
||||||
<LangToggle />
|
|
||||||
<div>
|
<div>
|
||||||
<a href="https://software.farmbot.io/docs/the-farmbot-web-app"
|
<a href="https://software.farmbot.io/docs/the-farmbot-web-app"
|
||||||
target="_blank">
|
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",
|
zAxisInverted = "zAxisInverted",
|
||||||
rawEncoders = "rawEncoders",
|
rawEncoders = "rawEncoders",
|
||||||
scaledEncoders = "scaledEncoders",
|
scaledEncoders = "scaledEncoders",
|
||||||
disableI18n = "disableI18n",
|
|
||||||
legendMenuOpen = "legendMenuOpen",
|
legendMenuOpen = "legendMenuOpen",
|
||||||
showPlants = "showPlants",
|
showPlants = "showPlants",
|
||||||
showPoints = "showPoints",
|
showPoints = "showPoints",
|
||||||
|
@ -13,8 +12,9 @@ export enum BooleanSetting {
|
||||||
|
|
||||||
/** "Labs" feature names. */
|
/** "Labs" feature names. */
|
||||||
weedDetector = "weedDetector",
|
weedDetector = "weedDetector",
|
||||||
hideWebcamWidget = "hideWebcamWidget",
|
disableI18n = "disableI18n",
|
||||||
confirmStepDeletion = "confirmStepDeletion",
|
confirmStepDeletion = "confirmStepDeletion",
|
||||||
|
hideWebcamWidget = "hideWebcamWidget",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NumericSetting {
|
export enum NumericSetting {
|
||||||
|
|
Loading…
Reference in a new issue