ManageEventIndex: Remove some useless divs and add the enable case.

pull/21833/head
Damir Jelić 2020-01-23 12:24:06 +01:00
parent 0d545ed335
commit 9bee024da7
1 changed files with 35 additions and 34 deletions

View File

@ -116,7 +116,11 @@ export default class ManageEventIndex extends React.Component {
SettingsStore.setValue("crawlerSleepTime", null, SettingLevel.DEVICE, e.target.value); SettingsStore.setValue("crawlerSleepTime", null, SettingLevel.DEVICE, e.target.value);
} }
_onDisable = () => { _onDisable = async () => {
this.props.onFinished(false);
}
_onEnable = async () => {
this.props.onFinished(false); this.props.onFinished(false);
} }
@ -126,17 +130,16 @@ export default class ManageEventIndex extends React.Component {
render() { render() {
let eventIndexingSettings = null; let eventIndexingSettings = null;
let buttons;
let crawlerState; let crawlerState;
if (!this.state.eventIndexingEnabled) { if (!this.state.eventIndexingEnabled) {
crawlerState = <div>{_t("Message search for encrypted rooms is disabled.")}</div>; crawlerState = _t("Message search for encrypted rooms is disabled.");
} else if (this.state.currentRoom === null) { } else if (this.state.currentRoom === null) {
crawlerState = <div>{_t("Not downloading messages for any room.")}</div>; crawlerState = _t("Not downloading messages for any room.");
} else { } else {
crawlerState = ( crawlerState = (
<div> _t("Downloading mesages for %(currentRoom)s.", { currentRoom: this.state.currentRoom })
{_t("Downloading mesages for %(currentRoom)s.", { currentRoom: this.state.currentRoom })}
</div>
); );
} }
@ -154,18 +157,30 @@ export default class ManageEventIndex extends React.Component {
{_t("Number of rooms:")} {this.state.roomCount}<br /> {_t("Number of rooms:")} {this.state.roomCount}<br />
{crawlerState}<br /> {crawlerState}<br />
</div> </div>
</div>
);
<LabelledToggleSwitch buttons = (
value={this.state.eventIndexingEnabled} <div className="mx_Dialog_buttons">
onChange={this._onEventIndexingEnabledChange} <AccessibleButton kind="secondary" onClick={this._onDisable}>
label={_t('Download and index encrypted messages')} /> {_t("Disable")}
</AccessibleButton>
<Field <AccessibleButton kind="primary" onClick={this._onDone}>
id={"crawlerSleepTimeMs"} {_t("Done")}
label={_t('Message downloading sleep time(ms)')} </AccessibleButton>
type='number' </div>
value={this.state.crawlerSleepTime} );
onChange={this._onCrawlerSleepTimeChange} /> } else if (!this.state.eventIndexingEnabled && this.state.eventIndexingInstalled) {
eventIndexingSettings = (
<div>
{_t( "Securely cache encrypted messages locally for them to appear in search results.")}
</div>
);
buttons = (
<div className="mx_Dialog_buttons">
<AccessibleButton kind="primary" onClick={this._onEnable}>
{_t("Enable")}
</AccessibleButton>
</div> </div>
); );
} else { } else {
@ -182,28 +197,14 @@ export default class ManageEventIndex extends React.Component {
} }
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const buttons = <div>
<div className="mx_Dialog_buttons">
<AccessibleButton kind="secondary" onClick={this._onDisable}>
{_t("Disable")}
</AccessibleButton>
<AccessibleButton kind="primary" onClick={this._onDone}>
{_t("Done")}
</AccessibleButton>
</div>
</div>;
return ( return (
<BaseDialog className='mx_ManageEventIndexDialog' <BaseDialog className='mx_ManageEventIndexDialog'
onFinished={() => {}} onFinished={this.props.onFinished}
title={_t("Message search")} title={_t("Message search")}
> >
<div> {eventIndexingSettings}
{eventIndexingSettings} {buttons}
</div>
<div>
{buttons}
</div>
</BaseDialog> </BaseDialog>
); );
} }