);
@@ -91,9 +78,9 @@ export default class IntegrationsManager extends React.Component {
if (!this.props.connected) {
return (
-
-
{_t("Cannot connect to integrations server")}
-
{_t("The integrations server is offline or it cannot reach your homeserver.")}
+
+
{_t("Cannot connect to integration manager")}
+
{_t("The integration manager is offline or it cannot reach your homeserver.")}
);
}
diff --git a/src/components/views/settings/SetIntegrationManager.js b/src/components/views/settings/SetIntegrationManager.js
index b1268c8048..26c45e3d2a 100644
--- a/src/components/views/settings/SetIntegrationManager.js
+++ b/src/components/views/settings/SetIntegrationManager.js
@@ -16,13 +16,9 @@ limitations under the License.
import React from 'react';
import {_t} from "../../../languageHandler";
-import sdk from '../../../index';
-import Field from "../elements/Field";
import {IntegrationManagers} from "../../../integrations/IntegrationManagers";
-import MatrixClientPeg from "../../../MatrixClientPeg";
-import {SERVICE_TYPES} from "matrix-js-sdk";
-import {IntegrationManagerInstance} from "../../../integrations/IntegrationManagerInstance";
-import Modal from "../../../Modal";
+import sdk from '../../../index';
+import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
export default class SetIntegrationManager extends React.Component {
constructor() {
@@ -32,135 +28,23 @@ export default class SetIntegrationManager extends React.Component {
this.state = {
currentManager,
- url: "", // user-entered text
- error: null,
- busy: false,
- checking: false,
+ provisioningEnabled: SettingsStore.getValue("integrationProvisioning"),
};
}
- _onUrlChanged = (ev) => {
- const u = ev.target.value;
- this.setState({url: u});
- };
+ 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);
- _getTooltip = () => {
- if (this.state.checking) {
- const InlineSpinner = sdk.getComponent('views.elements.InlineSpinner');
- return
-
- { _t("Checking server") }
-
;
- } else if (this.state.error) {
- return
{this.state.error};
- } else {
- return null;
- }
- };
-
- _canChange = () => {
- return !!this.state.url && !this.state.busy;
- };
-
- _continueTerms = async (manager) => {
- try {
- await IntegrationManagers.sharedInstance().overwriteManagerOnAccount(manager);
- this.setState({
- busy: false,
- error: null,
- currentManager: IntegrationManagers.sharedInstance().getPrimaryManager(),
- url: "", // clear input
- });
- } catch (e) {
- console.error(e);
- this.setState({
- busy: false,
- error: _t("Failed to update integration manager"),
- });
- }
- };
-
- _setManager = async (ev) => {
- // Don't reload the page when the user hits enter in the form.
- ev.preventDefault();
- ev.stopPropagation();
-
- this.setState({busy: true, checking: true, error: null});
-
- let offline = false;
- let manager: IntegrationManagerInstance;
- try {
- manager = await IntegrationManagers.sharedInstance().tryDiscoverManager(this.state.url);
- offline = !manager; // no manager implies offline
- } catch (e) {
- console.error(e);
- offline = true; // probably a connection error
- }
- if (offline) {
- this.setState({
- busy: false,
- checking: false,
- error: _t("Integration manager offline or not accessible."),
- });
- return;
- }
-
- // Test the manager (causes terms of service prompt if agreement is needed)
- // We also cancel the tooltip at this point so it doesn't collide with the dialog.
- this.setState({checking: false});
- try {
- const client = manager.getScalarClient();
- await client.connect();
- } catch (e) {
- console.error(e);
- this.setState({
- busy: false,
- error: _t("Terms of service not accepted or the integration manager is invalid."),
- });
- return;
- }
-
- // Specifically request the terms of service to see if there are any.
- // The above won't trigger a terms of service check if there are no terms to
- // sign, so when there's no terms at all we need to ensure we tell the user.
- let hasTerms = true;
- try {
- const terms = await MatrixClientPeg.get().getTerms(SERVICE_TYPES.IM, manager.trimmedApiUrl);
- hasTerms = terms && terms['policies'] && Object.keys(terms['policies']).length > 0;
- } catch (e) {
- // Assume errors mean there are no terms. This could be a 404, 500, etc
- console.error(e);
- hasTerms = false;
- }
- if (!hasTerms) {
- this.setState({busy: false});
- const QuestionDialog = sdk.getComponent("views.dialogs.QuestionDialog");
- Modal.createTrackedDialog('No Terms Warning', '', QuestionDialog, {
- title: _t("Integration manager has no terms of service"),
- description: (
-
-
- {_t("The integration manager you have chosen does not have any terms of service.")}
-
-
- {_t("Only continue if you trust the owner of the server.")}
-
-
- ),
- button: _t("Continue"),
- onFinished: async (confirmed) => {
- if (!confirmed) return;
- this._continueTerms(manager);
- },
- });
- return;
- }
-
- this._continueTerms(manager);
+ this.setState({provisioningEnabled: current});
+ });
+ this.setState({provisioningEnabled: !current});
};
render() {
- const AccessibleButton = sdk.getComponent('views.elements.AccessibleButton');
+ const ToggleSwitch = sdk.getComponent("views.elements.ToggleSwitch");
const currentManager = this.state.currentManager;
let managerName;
@@ -168,45 +52,32 @@ export default class SetIntegrationManager extends React.Component {
if (currentManager) {
managerName = `(${currentManager.name})`;
bodyText = _t(
- "You are currently using
%(serverName)s to manage your bots, widgets, " +
+ "Use an Integration Manager
(%(serverName)s) to manage bots, widgets, " +
"and sticker packs.",
{serverName: currentManager.name},
{ b: sub =>
{sub} },
);
} else {
- bodyText = _t(
- "Add which integration manager you want to manage your bots, widgets, " +
- "and sticker packs.",
- );
+ bodyText = _t("Use an Integration Manager to manage bots, widgets, and sticker packs.");
}
return (
-