diff --git a/src/client/web/src/client/index.ts b/src/client/web/src/client/index.ts index 140a9b6..b2d390d 100644 --- a/src/client/web/src/client/index.ts +++ b/src/client/web/src/client/index.ts @@ -89,12 +89,10 @@ export interface GetSharingDirResp { } export interface ClientConfigMsg { - clientCfg: ClientConfig; -} -export interface ClientConfig { siteName: string; siteDesc: string; bg: BgConfig; + captchaEnabled?: boolean; } export interface ClientErrorReport { @@ -154,7 +152,7 @@ export interface IFilesClient { export interface ISettingsClient { health: () => Promise; getClientCfg: () => Promise; - setClientCfg: (cfg: ClientConfig) => Promise; + setClientCfg: (cfg: ClientConfigMsg) => Promise; reportErrors: (reports: List) => Promise; } diff --git a/src/client/web/src/client/settings.ts b/src/client/web/src/client/settings.ts index 847bca1..d6dd4e4 100644 --- a/src/client/web/src/client/settings.ts +++ b/src/client/web/src/client/settings.ts @@ -1,7 +1,7 @@ import { List } from "immutable"; import { BaseClient, Response, userIDParam, Quota } from "."; -import { ClientConfig, ClientErrorReport } from "./"; +import { ClientConfigMsg, ClientErrorReport } from "./"; export class SettingsClient extends BaseClient { constructor(url: string) { @@ -22,13 +22,11 @@ export class SettingsClient extends BaseClient { }); }; - setClientCfg = (cfg: ClientConfig): Promise => { + setClientCfg = (cfg: ClientConfigMsg): Promise => { return this.do({ method: "patch", url: `${this.url}/v1/settings/client`, - data: { - clientCfg: cfg, - }, + data: cfg, }); }; diff --git a/src/client/web/src/client/settings_mock.ts b/src/client/web/src/client/settings_mock.ts index 01f7799..1dc7263 100644 --- a/src/client/web/src/client/settings_mock.ts +++ b/src/client/web/src/client/settings_mock.ts @@ -15,15 +15,13 @@ export const resps = { status: 200, statusText: "", data: { - clientCfg: { - siteName: "", - siteDesc: "", - bg: { - url: "clientCfg_bg_url", - repeat: "clientCfg_bg_repeat", - position: "clientCfg_bg_position", - align: "clientCfg_bg_align", - }, + siteName: "", + siteDesc: "", + bg: { + url: "clientCfg_bg_url", + repeat: "clientCfg_bg_repeat", + position: "clientCfg_bg_position", + align: "clientCfg_bg_align", }, }, }, @@ -33,41 +31,6 @@ export const resps = { data: {}, }, }; -export class MockSettingsClient { - private url: string; - private resps: SettingsClientResps; - - constructor(url: string) { - this.url = url; - this.resps = resps; - } - - setMock = (resps: SettingsClientResps) => { - this.resps = resps; - }; - - wrapPromise = (resp: any): Promise => { - return new Promise((resolve) => { - resolve(resp); - }); - }; - - health = (): Promise => { - return this.wrapPromise(this.resps.healthMockResp); - }; - - setClientCfg = (): Promise => { - return this.wrapPromise(this.resps.setClientCfgMockResp); - }; - - getClientCfg = (): Promise => { - return this.wrapPromise(this.resps.getClientCfgMockResp); - }; - - reportErrors = (): Promise => { - return this.wrapPromise(this.resps.reportErrorsMockResp); - }; -} export class JestSettingsClient { url: string = ""; diff --git a/src/client/web/src/components/__test__/pane_login.test.tsx b/src/client/web/src/components/__test__/pane_login.test.tsx index c15d916..97ea8ae 100644 --- a/src/client/web/src/components/__test__/pane_login.test.tsx +++ b/src/client/web/src/components/__test__/pane_login.test.tsx @@ -34,6 +34,7 @@ describe("Login", () => { const pane = new AuthPane({ login: coreState.login, msg: coreState.msg, + ui: coreState.ui, update: (updater: (prevState: ICoreState) => ICoreState) => {}, }); diff --git a/src/client/web/src/components/__test__/state_mgr.test.tsx b/src/client/web/src/components/__test__/state_mgr.test.tsx index 0e6a3fa..e3b39fe 100644 --- a/src/client/web/src/components/__test__/state_mgr.test.tsx +++ b/src/client/web/src/components/__test__/state_mgr.test.tsx @@ -124,7 +124,7 @@ describe("State Manager", () => { // ui expect(coreState.ui.bg).toEqual( - settingsResps.getClientCfgMockResp.data.clientCfg.bg + settingsResps.getClientCfgMockResp.data.bg ); }); @@ -226,7 +226,7 @@ describe("State Manager", () => { // ui expect(coreState.ui.bg).toEqual( - settingsResps.getClientCfgMockResp.data.clientCfg.bg + settingsResps.getClientCfgMockResp.data.bg ); }); diff --git a/src/client/web/src/components/core_state.ts b/src/client/web/src/components/core_state.ts index fb00e74..c321a40 100644 --- a/src/client/web/src/components/core_state.ts +++ b/src/client/web/src/components/core_state.ts @@ -28,6 +28,7 @@ export interface UIProps { isVertical: boolean; siteName: string; siteDesc: string; + captchaEnabled: boolean; bg: { url: string; repeat: string; @@ -111,6 +112,7 @@ export function initState(): ICoreState { position: "", align: "", }, + captchaEnabled: true, control: { controls: Map({ [panelTabs]: "filesPanel", diff --git a/src/client/web/src/components/layers.tsx b/src/client/web/src/components/layers.tsx index 2fd4a60..14ed160 100644 --- a/src/client/web/src/components/layers.tsx +++ b/src/client/web/src/components/layers.tsx @@ -57,6 +57,7 @@ export class Layers extends React.Component {
diff --git a/src/client/web/src/components/pane_login.tsx b/src/client/web/src/components/pane_login.tsx index 0a3714c..3157e98 100644 --- a/src/client/web/src/components/pane_login.tsx +++ b/src/client/web/src/components/pane_login.tsx @@ -1,7 +1,7 @@ import * as React from "react"; import { List } from "immutable"; -import { ICoreState, MsgProps } from "./core_state"; +import { ICoreState, MsgProps, UIProps } from "./core_state"; import { Flexbox } from "./layout/flexbox"; import { updater } from "./state_updater"; import { alertMsg } from "../common/env"; @@ -26,6 +26,7 @@ export interface LoginProps { export interface Props { login: LoginProps; msg: MsgProps; + ui: UIProps; update?: (updater: (prevState: ICoreState) => ICoreState) => void; } @@ -106,6 +107,34 @@ export class AuthPane extends React.Component { }; render() { + const row3 = this.props.ui.captchaEnabled ? ( + + +
, + + this.setState({ captchaLoaded: true })} + />, + ])} + childrenStyles={List([ + { justifyContent: "flex-start" }, + { justifyContent: "flex-end" }, + ])} + /> + ) : null; + return (
{ />
- - - , - - this.setState({ captchaLoaded: true })} - />, - ])} - childrenStyles={List([ - { justifyContent: "flex-start" }, - { justifyContent: "flex-end" }, - ])} - /> + {row3}