diff --git a/src/components/views/settings/SetIdServer.js b/src/components/views/settings/SetIdServer.js index 466ac01dd0..8f7f30a2e1 100644 --- a/src/components/views/settings/SetIdServer.js +++ b/src/components/views/settings/SetIdServer.js @@ -22,6 +22,7 @@ import sdk from '../../../index'; import MatrixClientPeg from "../../../MatrixClientPeg"; import SdkConfig from "../../../SdkConfig"; import Field from "../elements/Field"; +import Modal from '../../../Modal'; /** * If a url has no path component, etc. abbreviate it to just the hostname @@ -148,7 +149,39 @@ export default class SetIdServer extends React.Component { }); }; + _onDisconnectClicked = () => { + const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + Modal.createTrackedDialog('ID Server Disconnect Warning', '', QuestionDialog, { + title: _t("Disconnect ID Server"), + description: +
+ {_t( + "Disconnect from the ID Server ?", {}, + {idserver: sub => {abbreviateUrl(this.state.currentClientIdServer)}}, + )}, +
, + button: _t("Disconnect"), + onFinished: (confirmed) => { + if (confirmed) { + this._disconnectIdServer(); + } + }, + }); + }; + + _disconnectIdServer = () => { + MatrixClientPeg.get().setIdentityServerUrl(null); + localStorage.removeItem("mx_is_url"); + this.setState({ + busy: false, + error: null, + currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(), + idServer: '', + }); + }; + render() { + const AccessibleButton = sdk.getComponent('views.elements.AccessibleButton'); const idServerUrl = this.state.currentClientIdServer; let sectionTitle; let bodyText; @@ -169,6 +202,20 @@ export default class SetIdServer extends React.Component { ); } + let discoSection; + if (idServerUrl) { + discoSection =
+ {_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.", + )} + + {_t("Disconnect")} + +
; + } + return (
@@ -187,6 +234,7 @@ export default class SetIdServer extends React.Component { type="submit" value={_t("Change")} disabled={!this._idServerChangeEnabled()} /> + {discoSection} ); } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 61d9fbc49e..9c4bcef197 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -541,10 +541,14 @@ "Could not connect to ID Server": "Could not connect to ID Server", "Not a valid ID Server (status code %(code)s)": "Not a valid ID Server (status code %(code)s)", "Checking Server": "Checking Server", + "Disconnect ID Server": "Disconnect ID Server", + "Disconnect from the ID Server %(idserver)s?": "Disconnect from the ID Server %(idserver)s?", + "Disconnect": "Disconnect", "Identity Server (%(server)s)": "Identity Server (%(server)s)", "You are currently using to discover and be discoverable by existing contacts you know. You can change your identity server below.": "You are currently using to discover and be discoverable by existing contacts you know. You can change your identity server below.", "Identity Server": "Identity Server", "You are not currently using an Identity Server. To discover and be discoverable by existing contacts you know, add one below": "You are not currently using an Identity Server. To discover and be discoverable by existing contacts you know, add one below", + "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.": "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.", "Change": "Change", "Flair": "Flair", "Failed to change password. Is your password correct?": "Failed to change password. Is your password correct?",