2019-08-12 13:51:44 +03:00
|
|
|
/*
|
2019-08-13 12:46:42 +03:00
|
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
2019-08-12 13:51:44 +03:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import url from 'url';
|
|
|
|
import React from 'react';
|
2019-08-26 20:25:50 +03:00
|
|
|
import PropTypes from 'prop-types';
|
2019-08-12 13:51:44 +03:00
|
|
|
import {_t} from "../../../languageHandler";
|
|
|
|
import sdk from '../../../index';
|
|
|
|
import MatrixClientPeg from "../../../MatrixClientPeg";
|
2019-08-12 16:36:48 +03:00
|
|
|
import Modal from '../../../Modal';
|
2019-08-13 20:40:27 +03:00
|
|
|
import dis from "../../../dispatcher";
|
2019-09-11 13:33:58 +03:00
|
|
|
import { getThreepidsWithBindStatus } from '../../../boundThreepids';
|
2019-08-16 00:59:44 +03:00
|
|
|
import IdentityAuthClient from "../../../IdentityAuthClient";
|
2019-08-21 17:46:10 +03:00
|
|
|
import {abbreviateUrl, unabbreviateUrl} from "../../../utils/UrlUtils";
|
2019-10-31 14:58:31 +03:00
|
|
|
import { getDefaultIdentityServerUrl, doesIdentityServerHaveTerms } from '../../../utils/IdentityServerUtils';
|
2019-08-12 13:51:44 +03:00
|
|
|
|
2019-10-18 14:40:50 +03:00
|
|
|
// We'll wait up to this long when checking for 3PID bindings on the IS.
|
|
|
|
const REACHABILITY_TIMEOUT = 10000; // ms
|
|
|
|
|
2019-08-12 13:51:44 +03:00
|
|
|
/**
|
|
|
|
* Check an IS URL is valid, including liveness check
|
|
|
|
*
|
2019-08-13 14:59:34 +03:00
|
|
|
* @param {string} u The url to check
|
2019-08-12 13:51:44 +03:00
|
|
|
* @returns {string} null if url passes all checks, otherwise i18ned error string
|
|
|
|
*/
|
2019-08-13 14:59:34 +03:00
|
|
|
async function checkIdentityServerUrl(u) {
|
|
|
|
const parsedUrl = url.parse(u);
|
2019-08-12 13:51:44 +03:00
|
|
|
|
|
|
|
if (parsedUrl.protocol !== 'https:') return _t("Identity Server URL must be HTTPS");
|
|
|
|
|
|
|
|
// XXX: duplicated logic from js-sdk but it's quite tied up in the validation logic in the
|
|
|
|
// js-sdk so probably as easy to duplicate it than to separate it out so we can reuse it
|
2019-08-13 18:37:56 +03:00
|
|
|
try {
|
|
|
|
const response = await fetch(u + '/_matrix/identity/api/v1');
|
|
|
|
if (response.ok) {
|
|
|
|
return null;
|
|
|
|
} else if (response.status < 200 || response.status >= 300) {
|
|
|
|
return _t("Not a valid Identity Server (status code %(code)s)", {code: response.status});
|
|
|
|
} else {
|
|
|
|
return _t("Could not connect to Identity Server");
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
return _t("Could not connect to Identity Server");
|
|
|
|
}
|
2019-08-12 13:51:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export default class SetIdServer extends React.Component {
|
2019-08-26 20:25:50 +03:00
|
|
|
static propTypes = {
|
|
|
|
// Whether or not the ID server is missing terms. This affects the text
|
|
|
|
// shown to the user.
|
|
|
|
missingTerms: PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
2019-08-12 13:51:44 +03:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
2019-08-13 19:55:10 +03:00
|
|
|
let defaultIdServer = '';
|
2019-08-29 17:20:14 +03:00
|
|
|
if (!MatrixClientPeg.get().getIdentityServerUrl() && getDefaultIdentityServerUrl()) {
|
2019-08-13 19:55:10 +03:00
|
|
|
// If no ID server is configured but there's one in the config, prepopulate
|
|
|
|
// the field to help the user.
|
2019-08-29 17:20:14 +03:00
|
|
|
defaultIdServer = abbreviateUrl(getDefaultIdentityServerUrl());
|
2019-08-12 13:51:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
this.state = {
|
2019-08-19 16:20:01 +03:00
|
|
|
defaultIdServer,
|
2019-08-12 13:51:44 +03:00
|
|
|
currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(),
|
2019-08-19 16:20:01 +03:00
|
|
|
idServer: "",
|
2019-08-12 13:51:44 +03:00
|
|
|
error: null,
|
|
|
|
busy: false,
|
2019-08-15 14:04:07 +03:00
|
|
|
disconnectBusy: false,
|
2019-08-16 00:59:44 +03:00
|
|
|
checking: false,
|
2019-08-12 13:51:44 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-08-16 22:10:41 +03:00
|
|
|
componentDidMount(): void {
|
|
|
|
this.dispatcherRef = dis.register(this.onAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount(): void {
|
|
|
|
dis.unregister(this.dispatcherRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
onAction = (payload) => {
|
|
|
|
// We react to changes in the ID server in the event the user is staring at this form
|
2019-09-06 16:27:20 +03:00
|
|
|
// when changing their identity server on another device.
|
2019-08-16 22:10:41 +03:00
|
|
|
if (payload.action !== "id_server_changed") return;
|
|
|
|
|
|
|
|
this.setState({
|
2019-09-06 16:27:20 +03:00
|
|
|
currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(),
|
2019-08-16 22:10:41 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-08-12 13:51:44 +03:00
|
|
|
_onIdentityServerChanged = (ev) => {
|
|
|
|
const u = ev.target.value;
|
|
|
|
|
|
|
|
this.setState({idServer: u});
|
|
|
|
};
|
|
|
|
|
|
|
|
_getTooltip = () => {
|
2019-08-16 00:59:44 +03:00
|
|
|
if (this.state.checking) {
|
2019-08-12 13:51:44 +03:00
|
|
|
const InlineSpinner = sdk.getComponent('views.elements.InlineSpinner');
|
|
|
|
return <div>
|
|
|
|
<InlineSpinner />
|
2019-08-13 12:51:26 +03:00
|
|
|
{ _t("Checking server") }
|
2019-08-12 13:51:44 +03:00
|
|
|
</div>;
|
|
|
|
} else if (this.state.error) {
|
2019-08-16 00:59:44 +03:00
|
|
|
return <span className='warning'>{this.state.error}</span>;
|
2019-08-12 13:51:44 +03:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
_idServerChangeEnabled = () => {
|
|
|
|
return !!this.state.idServer && !this.state.busy;
|
|
|
|
};
|
|
|
|
|
2019-08-19 19:27:57 +03:00
|
|
|
_saveIdServer = (fullUrl) => {
|
2019-08-16 22:10:41 +03:00
|
|
|
// Account data change will update localstorage, client, etc through dispatcher
|
|
|
|
MatrixClientPeg.get().setAccountData("m.identity_server", {
|
|
|
|
base_url: fullUrl,
|
|
|
|
});
|
2019-09-05 19:51:27 +03:00
|
|
|
this.setState({
|
|
|
|
busy: false,
|
|
|
|
error: null,
|
|
|
|
currentClientIdServer: fullUrl,
|
|
|
|
idServer: '',
|
|
|
|
});
|
2019-08-16 00:59:44 +03:00
|
|
|
};
|
|
|
|
|
2019-08-19 19:27:57 +03:00
|
|
|
_checkIdServer = async (e) => {
|
2019-08-13 18:20:30 +03:00
|
|
|
e.preventDefault();
|
2019-09-06 13:18:25 +03:00
|
|
|
const { idServer, currentClientIdServer } = this.state;
|
2019-08-13 18:20:30 +03:00
|
|
|
|
2019-08-16 00:59:44 +03:00
|
|
|
this.setState({busy: true, checking: true, error: null});
|
2019-08-12 13:51:44 +03:00
|
|
|
|
2019-09-06 13:18:25 +03:00
|
|
|
const fullUrl = unabbreviateUrl(idServer);
|
2019-08-12 13:51:44 +03:00
|
|
|
|
2019-08-16 00:59:44 +03:00
|
|
|
let errStr = await checkIdentityServerUrl(fullUrl);
|
2019-08-12 13:51:44 +03:00
|
|
|
if (!errStr) {
|
2019-08-16 00:59:44 +03:00
|
|
|
try {
|
|
|
|
this.setState({checking: false}); // clear tooltip
|
|
|
|
|
|
|
|
// Test the identity server by trying to register with it. This
|
|
|
|
// may result in a terms of service prompt.
|
|
|
|
const authClient = new IdentityAuthClient(fullUrl);
|
|
|
|
await authClient.getAccessToken();
|
|
|
|
|
2019-09-05 19:51:27 +03:00
|
|
|
let save = true;
|
|
|
|
|
2019-08-16 00:59:44 +03:00
|
|
|
// Double check that the identity server even has terms of service.
|
2019-10-31 14:58:31 +03:00
|
|
|
const hasTerms = await doesIdentityServerHaveTerms(fullUrl);
|
|
|
|
if (!hasTerms) {
|
2019-09-06 12:48:24 +03:00
|
|
|
const [confirmed] = await this._showNoTermsWarning(fullUrl);
|
2019-09-06 13:18:25 +03:00
|
|
|
save = confirmed;
|
2019-08-16 00:59:44 +03:00
|
|
|
}
|
|
|
|
|
2019-09-05 19:51:27 +03:00
|
|
|
// Show a general warning, possibly with details about any bound
|
|
|
|
// 3PIDs that would be left behind.
|
2019-09-06 13:18:25 +03:00
|
|
|
if (save && currentClientIdServer && fullUrl !== currentClientIdServer) {
|
2019-09-06 12:48:24 +03:00
|
|
|
const [confirmed] = await this._showServerChangeWarning({
|
2019-09-05 19:51:27 +03:00
|
|
|
title: _t("Change identity server"),
|
|
|
|
unboundMessage: _t(
|
|
|
|
"Disconnect from the identity server <current /> and " +
|
|
|
|
"connect to <new /> instead?", {},
|
|
|
|
{
|
2019-09-06 13:18:25 +03:00
|
|
|
current: sub => <b>{abbreviateUrl(currentClientIdServer)}</b>,
|
|
|
|
new: sub => <b>{abbreviateUrl(idServer)}</b>,
|
2019-09-05 19:51:27 +03:00
|
|
|
},
|
|
|
|
),
|
|
|
|
button: _t("Continue"),
|
|
|
|
});
|
2019-09-06 13:18:25 +03:00
|
|
|
save = confirmed;
|
2019-08-16 00:59:44 +03:00
|
|
|
}
|
|
|
|
|
2019-09-05 19:51:27 +03:00
|
|
|
if (save) {
|
|
|
|
this._saveIdServer(fullUrl);
|
|
|
|
}
|
2019-08-16 00:59:44 +03:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
errStr = _t("Terms of service not accepted or the identity server is invalid.");
|
|
|
|
}
|
2019-08-12 13:51:44 +03:00
|
|
|
}
|
|
|
|
this.setState({
|
|
|
|
busy: false,
|
2019-08-16 00:59:44 +03:00
|
|
|
checking: false,
|
2019-08-12 13:51:44 +03:00
|
|
|
error: errStr,
|
|
|
|
currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(),
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-08-23 20:58:04 +03:00
|
|
|
_showNoTermsWarning(fullUrl) {
|
|
|
|
const QuestionDialog = sdk.getComponent("views.dialogs.QuestionDialog");
|
2019-09-06 12:48:24 +03:00
|
|
|
const { finished } = Modal.createTrackedDialog('No Terms Warning', '', QuestionDialog, {
|
2019-08-23 20:58:04 +03:00
|
|
|
title: _t("Identity server has no terms of service"),
|
|
|
|
description: (
|
|
|
|
<div>
|
|
|
|
<span className="warning">
|
|
|
|
{_t("The identity server you have chosen does not have any terms of service.")}
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
{_t("Only continue if you trust the owner of the server.")}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
button: _t("Continue"),
|
|
|
|
});
|
2019-09-06 12:48:24 +03:00
|
|
|
return finished;
|
2019-08-23 21:01:47 +03:00
|
|
|
}
|
2019-08-23 20:58:04 +03:00
|
|
|
|
2019-08-15 14:04:07 +03:00
|
|
|
_onDisconnectClicked = async () => {
|
|
|
|
this.setState({disconnectBusy: true});
|
|
|
|
try {
|
2019-09-06 12:48:24 +03:00
|
|
|
const [confirmed] = await this._showServerChangeWarning({
|
2019-09-05 19:51:27 +03:00
|
|
|
title: _t("Disconnect identity server"),
|
|
|
|
unboundMessage: _t(
|
2019-08-15 14:04:07 +03:00
|
|
|
"Disconnect from the identity server <idserver />?", {},
|
|
|
|
{idserver: sub => <b>{abbreviateUrl(this.state.currentClientIdServer)}</b>},
|
2019-09-05 19:51:27 +03:00
|
|
|
),
|
2019-08-15 14:04:07 +03:00
|
|
|
button: _t("Disconnect"),
|
|
|
|
});
|
2019-09-05 19:51:27 +03:00
|
|
|
if (confirmed) {
|
|
|
|
this._disconnectIdServer();
|
|
|
|
}
|
2019-08-15 14:04:07 +03:00
|
|
|
} finally {
|
|
|
|
this.setState({disconnectBusy: false});
|
|
|
|
}
|
2019-08-12 16:36:48 +03:00
|
|
|
};
|
|
|
|
|
2019-09-05 19:51:27 +03:00
|
|
|
async _showServerChangeWarning({ title, unboundMessage, button }) {
|
2019-10-11 17:57:12 +03:00
|
|
|
const { currentClientIdServer } = this.state;
|
|
|
|
|
|
|
|
let threepids = [];
|
|
|
|
let currentServerReachable = true;
|
|
|
|
try {
|
2019-10-18 14:40:50 +03:00
|
|
|
threepids = await Promise.race([
|
|
|
|
getThreepidsWithBindStatus(MatrixClientPeg.get()),
|
|
|
|
new Promise((resolve, reject) => {
|
|
|
|
setTimeout(() => {
|
|
|
|
reject(new Error("Timeout attempting to reach identity server"));
|
|
|
|
}, REACHABILITY_TIMEOUT);
|
|
|
|
}),
|
|
|
|
]);
|
2019-10-11 17:57:12 +03:00
|
|
|
} catch (e) {
|
|
|
|
currentServerReachable = false;
|
|
|
|
console.warn(
|
|
|
|
`Unable to reach identity server at ${currentClientIdServer} to check ` +
|
|
|
|
`for 3PIDs during IS change flow`,
|
|
|
|
);
|
|
|
|
console.warn(e);
|
|
|
|
}
|
2019-09-05 19:51:27 +03:00
|
|
|
const boundThreepids = threepids.filter(tp => tp.bound);
|
|
|
|
let message;
|
2019-09-06 15:43:21 +03:00
|
|
|
let danger = false;
|
2019-10-11 17:57:12 +03:00
|
|
|
const messageElements = {
|
|
|
|
idserver: sub => <b>{abbreviateUrl(currentClientIdServer)}</b>,
|
|
|
|
b: sub => <b>{sub}</b>,
|
|
|
|
};
|
|
|
|
if (!currentServerReachable) {
|
|
|
|
message = <div>
|
|
|
|
<p>{_t(
|
|
|
|
"You should <b>remove your personal data</b> from identity server " +
|
|
|
|
"<idserver /> before disconnecting. Unfortunately, identity server " +
|
|
|
|
"<idserver /> is currently offline or cannot be reached.",
|
|
|
|
{}, messageElements,
|
|
|
|
)}</p>
|
|
|
|
<p>{_t("You should:")}</p>
|
|
|
|
<ul>
|
|
|
|
<li>{_t(
|
|
|
|
"check your browser plugins for anything that might block " +
|
|
|
|
"the identity server (such as Privacy Badger)",
|
|
|
|
)}</li>
|
|
|
|
<li>{_t("contact the administrators of identity server <idserver />", {}, {
|
|
|
|
idserver: messageElements.idserver,
|
|
|
|
})}</li>
|
|
|
|
<li>{_t("wait and try again later")}</li>
|
|
|
|
</ul>
|
|
|
|
</div>;
|
|
|
|
danger = true;
|
|
|
|
button = _t("Disconnect anyway");
|
|
|
|
} else if (boundThreepids.length) {
|
2019-09-09 12:27:02 +03:00
|
|
|
message = <div>
|
|
|
|
<p>{_t(
|
|
|
|
"You are still <b>sharing your personal data</b> on the identity " +
|
2019-10-11 17:57:12 +03:00
|
|
|
"server <idserver />.", {}, messageElements,
|
2019-09-09 12:27:02 +03:00
|
|
|
)}</p>
|
|
|
|
<p>{_t(
|
|
|
|
"We recommend that you remove your email addresses and phone numbers " +
|
|
|
|
"from the identity server before disconnecting.",
|
|
|
|
)}</p>
|
|
|
|
</div>;
|
2019-09-06 15:43:21 +03:00
|
|
|
danger = true;
|
|
|
|
button = _t("Disconnect anyway");
|
2019-09-05 19:51:27 +03:00
|
|
|
} else {
|
|
|
|
message = unboundMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
2019-09-06 12:48:24 +03:00
|
|
|
const { finished } = Modal.createTrackedDialog('Identity Server Bound Warning', '', QuestionDialog, {
|
|
|
|
title,
|
|
|
|
description: message,
|
|
|
|
button,
|
2019-09-06 15:43:21 +03:00
|
|
|
cancelButton: _t("Go back"),
|
|
|
|
danger,
|
2019-09-05 19:51:27 +03:00
|
|
|
});
|
2019-09-06 12:48:24 +03:00
|
|
|
return finished;
|
2019-09-05 19:51:27 +03:00
|
|
|
}
|
|
|
|
|
2019-08-12 16:36:48 +03:00
|
|
|
_disconnectIdServer = () => {
|
2019-08-16 22:10:41 +03:00
|
|
|
// Account data change will update localstorage, client, etc through dispatcher
|
|
|
|
MatrixClientPeg.get().setAccountData("m.identity_server", {
|
|
|
|
base_url: null, // clear
|
|
|
|
});
|
2019-08-14 12:06:05 +03:00
|
|
|
|
|
|
|
let newFieldVal = '';
|
2019-08-29 17:20:14 +03:00
|
|
|
if (getDefaultIdentityServerUrl()) {
|
2019-08-14 12:06:05 +03:00
|
|
|
// Prepopulate the client's default so the user at least has some idea of
|
|
|
|
// a valid value they might enter
|
2019-08-29 17:20:14 +03:00
|
|
|
newFieldVal = abbreviateUrl(getDefaultIdentityServerUrl());
|
2019-08-14 12:06:05 +03:00
|
|
|
}
|
|
|
|
|
2019-08-12 16:36:48 +03:00
|
|
|
this.setState({
|
|
|
|
busy: false,
|
|
|
|
error: null,
|
|
|
|
currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(),
|
2019-08-14 12:06:05 +03:00
|
|
|
idServer: newFieldVal,
|
2019-08-12 16:36:48 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-08-12 13:51:44 +03:00
|
|
|
render() {
|
2019-08-12 16:36:48 +03:00
|
|
|
const AccessibleButton = sdk.getComponent('views.elements.AccessibleButton');
|
2019-08-14 12:03:32 +03:00
|
|
|
const Field = sdk.getComponent('elements.Field');
|
2019-08-12 13:51:44 +03:00
|
|
|
const idServerUrl = this.state.currentClientIdServer;
|
|
|
|
let sectionTitle;
|
|
|
|
let bodyText;
|
|
|
|
if (idServerUrl) {
|
|
|
|
sectionTitle = _t("Identity Server (%(server)s)", { server: abbreviateUrl(idServerUrl) });
|
|
|
|
bodyText = _t(
|
|
|
|
"You are currently using <server></server> to discover and be discoverable by " +
|
|
|
|
"existing contacts you know. You can change your identity server below.",
|
|
|
|
{},
|
|
|
|
{ server: sub => <b>{abbreviateUrl(idServerUrl)}</b> },
|
|
|
|
);
|
2019-08-26 20:25:50 +03:00
|
|
|
if (this.props.missingTerms) {
|
|
|
|
bodyText = _t(
|
|
|
|
"If you don't want to use <server /> to discover and be discoverable by existing " +
|
|
|
|
"contacts you know, enter another identity server below.",
|
|
|
|
{}, {server: sub => <b>{abbreviateUrl(idServerUrl)}</b>},
|
|
|
|
);
|
|
|
|
}
|
2019-08-12 13:51:44 +03:00
|
|
|
} else {
|
|
|
|
sectionTitle = _t("Identity Server");
|
|
|
|
bodyText = _t(
|
2019-08-13 12:51:26 +03:00
|
|
|
"You are not currently using an identity server. " +
|
2019-08-12 13:51:44 +03:00
|
|
|
"To discover and be discoverable by existing contacts you know, " +
|
2019-08-13 12:51:26 +03:00
|
|
|
"add one below.",
|
2019-08-12 13:51:44 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-08-12 16:36:48 +03:00
|
|
|
let discoSection;
|
|
|
|
if (idServerUrl) {
|
2019-08-15 14:04:07 +03:00
|
|
|
let discoButtonContent = _t("Disconnect");
|
2019-08-26 20:25:50 +03:00
|
|
|
let discoBodyText = _t(
|
|
|
|
"Disconnecting from your identity server will mean you " +
|
|
|
|
"won't be discoverable by other users and you won't be " +
|
|
|
|
"able to invite others by email or phone.",
|
|
|
|
);
|
|
|
|
if (this.props.missingTerms) {
|
|
|
|
discoBodyText = _t(
|
|
|
|
"Using an identity server is optional. If you choose not to " +
|
|
|
|
"use an identity server, you won't be discoverable by other users " +
|
|
|
|
"and you won't be able to invite others by email or phone.",
|
|
|
|
);
|
|
|
|
discoButtonContent = _t("Do not use an identity server");
|
|
|
|
}
|
2019-08-15 14:04:07 +03:00
|
|
|
if (this.state.disconnectBusy) {
|
|
|
|
const InlineSpinner = sdk.getComponent('views.elements.InlineSpinner');
|
|
|
|
discoButtonContent = <InlineSpinner />;
|
|
|
|
}
|
2019-08-12 16:36:48 +03:00
|
|
|
discoSection = <div>
|
2019-08-26 20:25:50 +03:00
|
|
|
<span className="mx_SettingsTab_subsectionText">{discoBodyText}</span>
|
2019-08-20 22:20:07 +03:00
|
|
|
<AccessibleButton onClick={this._onDisconnectClicked} kind="danger_sm">
|
2019-08-15 14:04:07 +03:00
|
|
|
{discoButtonContent}
|
2019-08-12 16:36:48 +03:00
|
|
|
</AccessibleButton>
|
|
|
|
</div>;
|
|
|
|
}
|
|
|
|
|
2019-08-12 13:51:44 +03:00
|
|
|
return (
|
2019-08-19 19:27:57 +03:00
|
|
|
<form className="mx_SettingsTab_section mx_SetIdServer" onSubmit={this._checkIdServer}>
|
2019-08-12 13:51:44 +03:00
|
|
|
<span className="mx_SettingsTab_subheading">
|
|
|
|
{sectionTitle}
|
|
|
|
</span>
|
|
|
|
<span className="mx_SettingsTab_subsectionText">
|
|
|
|
{bodyText}
|
|
|
|
</span>
|
2019-08-19 16:44:53 +03:00
|
|
|
<Field label={_t("Enter a new identity server")}
|
2019-08-12 13:51:44 +03:00
|
|
|
id="mx_SetIdServer_idServer"
|
2019-08-19 16:20:01 +03:00
|
|
|
type="text"
|
|
|
|
autoComplete="off"
|
|
|
|
placeholder={this.state.defaultIdServer}
|
|
|
|
value={this.state.idServer}
|
2019-08-12 13:51:44 +03:00
|
|
|
onChange={this._onIdentityServerChanged}
|
2019-08-13 13:01:04 +03:00
|
|
|
tooltipContent={this._getTooltip()}
|
2019-08-20 22:20:07 +03:00
|
|
|
tooltipClassName="mx_SetIdServer_tooltip"
|
|
|
|
disabled={this.state.busy}
|
|
|
|
flagInvalid={!!this.state.error}
|
2019-08-12 13:51:44 +03:00
|
|
|
/>
|
2019-08-13 18:20:30 +03:00
|
|
|
<AccessibleButton type="submit" kind="primary_sm"
|
2019-08-19 19:27:57 +03:00
|
|
|
onClick={this._checkIdServer}
|
2019-08-12 13:51:44 +03:00
|
|
|
disabled={!this._idServerChangeEnabled()}
|
2019-08-13 18:20:30 +03:00
|
|
|
>{_t("Change")}</AccessibleButton>
|
2019-08-12 16:36:48 +03:00
|
|
|
{discoSection}
|
2019-08-12 13:51:44 +03:00
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|