Add the toggle switch for provisioning

This commit is contained in:
Travis Ralston 2019-11-20 20:05:32 -07:00
parent 0a0e952691
commit 3391cc0d90
2 changed files with 25 additions and 0 deletions

View file

@ -17,6 +17,8 @@ limitations under the License.
import React from 'react';
import {_t} from "../../../languageHandler";
import {IntegrationManagers} from "../../../integrations/IntegrationManagers";
import sdk from '../../../index';
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
export default class SetIntegrationManager extends React.Component {
constructor() {
@ -26,10 +28,24 @@ export default class SetIntegrationManager extends React.Component {
this.state = {
currentManager,
provisioningEnabled: SettingsStore.getValue("integrationProvisioning"),
};
}
onProvisioningToggled = () => {
const current = this.state.provisioningEnabled;
SettingsStore.setValue("integrationProvisioning", null, SettingLevel.ACCOUNT, !current).catch(err => {
console.error("Error changing integration manager provisioning");
console.error(err);
this.setState({provisioningEnabled: current});
});
this.setState({provisioningEnabled: !current});
};
render() {
const ToggleSwitch = sdk.getComponent("views.elements.ToggleSwitch");
const currentManager = this.state.currentManager;
let managerName;
let bodyText;
@ -50,6 +66,7 @@ export default class SetIntegrationManager extends React.Component {
<div className="mx_SettingsTab_heading">
<span>{_t("Integrations")}</span>
<span className="mx_SettingsTab_subheading">{managerName}</span>
<ToggleSwitch checked={this.state.provisioningEnabled} onChange={this.onProvisioningToggled} />
</div>
<span className="mx_SettingsTab_subsectionText">
{bodyText}