From 384f07adb2b6d11f0fbcc518494040fe6fc73ce6 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 12 Aug 2019 14:36:48 +0100 Subject: [PATCH 01/10] Disconnect from IS button --- src/components/views/settings/SetIdServer.js | 48 ++++++++++++++++++++ src/i18n/strings/en_EN.json | 4 ++ 2 files changed, 52 insertions(+) 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?", From 115e4c0370699be9b4cb2a68739e6b954721505f Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 12 Aug 2019 14:40:11 +0100 Subject: [PATCH 02/10] Remove IS access token too --- src/components/views/settings/SetIdServer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/views/settings/SetIdServer.js b/src/components/views/settings/SetIdServer.js index 0bb92d75e4..73b8514327 100644 --- a/src/components/views/settings/SetIdServer.js +++ b/src/components/views/settings/SetIdServer.js @@ -172,6 +172,7 @@ export default class SetIdServer extends React.Component { _disconnectIdServer = () => { MatrixClientPeg.get().setIdentityServerUrl(null); + localStorage.removeItem("mx_is_access_token", fullUrl); localStorage.removeItem("mx_is_url"); this.setState({ busy: false, From 0b51a5f45260a3b9172d1df10d14b9158c884bd0 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 12 Aug 2019 14:45:15 +0100 Subject: [PATCH 03/10] c+p fail --- src/components/views/settings/SetIdServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/settings/SetIdServer.js b/src/components/views/settings/SetIdServer.js index 73b8514327..b95a7f5ae5 100644 --- a/src/components/views/settings/SetIdServer.js +++ b/src/components/views/settings/SetIdServer.js @@ -172,7 +172,7 @@ export default class SetIdServer extends React.Component { _disconnectIdServer = () => { MatrixClientPeg.get().setIdentityServerUrl(null); - localStorage.removeItem("mx_is_access_token", fullUrl); + localStorage.removeItem("mx_is_access_token"); localStorage.removeItem("mx_is_url"); this.setState({ busy: false, From b694a56689325b7eed5a2a2f8eb8bf2510a1ee15 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 12 Aug 2019 14:48:02 +0100 Subject: [PATCH 04/10] i18n --- src/i18n/strings/en_EN.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 9c4bcef197..577048bd18 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -542,7 +542,7 @@ "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 from the ID Server ?": "Disconnect from the ID Server ?", "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.", From b0420c106eab05f8fe8a8615d2c3430d87f3a29c Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 14 Aug 2019 10:06:05 +0100 Subject: [PATCH 05/10] Prepopulate client default on disconnect --- src/components/views/settings/SetIdServer.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/views/settings/SetIdServer.js b/src/components/views/settings/SetIdServer.js index 96382d9cb4..ad11b20967 100644 --- a/src/components/views/settings/SetIdServer.js +++ b/src/components/views/settings/SetIdServer.js @@ -174,11 +174,19 @@ export default class SetIdServer extends React.Component { MatrixClientPeg.get().setIdentityServerUrl(null); localStorage.removeItem("mx_is_access_token"); localStorage.removeItem("mx_is_url"); + + let newFieldVal = ''; + if (SdkConfig.get()['validated_server_config']['isUrl']) { + // Prepopulate the client's default so the user at least has some idea of + // a valid value they might enter + newFieldVal = abbreviateUrl(SdkConfig.get()['validated_server_config']['isUrl']); + } + this.setState({ busy: false, error: null, currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(), - idServer: '', + idServer: newFieldVal, }); }; From 0d560108b6c6a759758d8b50db411afca3a68405 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 14 Aug 2019 10:07:50 +0100 Subject: [PATCH 06/10] Kill smart quotes Co-Authored-By: Travis Ralston --- src/components/views/settings/SetIdServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/settings/SetIdServer.js b/src/components/views/settings/SetIdServer.js index ad11b20967..907add6b2d 100644 --- a/src/components/views/settings/SetIdServer.js +++ b/src/components/views/settings/SetIdServer.js @@ -218,7 +218,7 @@ export default class SetIdServer extends React.Component { discoSection =
{_t( "Disconnecting from your identity server will mean you " + - "won’t be discoverable by other users and you won’t be " + + "won't be discoverable by other users and you won't be " + "able to invite others by email or phone.", )} From 85497610e333c28831817930f808ca16cbc3c50e Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 14 Aug 2019 10:08:15 +0100 Subject: [PATCH 07/10] Spell out identity server Co-Authored-By: J. Ryan Stinnett --- src/components/views/settings/SetIdServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/settings/SetIdServer.js b/src/components/views/settings/SetIdServer.js index 907add6b2d..334c9dfbfb 100644 --- a/src/components/views/settings/SetIdServer.js +++ b/src/components/views/settings/SetIdServer.js @@ -152,7 +152,7 @@ export default class SetIdServer extends React.Component { _onDisconnectClicked = () => { const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); - Modal.createTrackedDialog('ID Server Disconnect Warning', '', QuestionDialog, { + Modal.createTrackedDialog('Identity Server Disconnect Warning', '', QuestionDialog, { title: _t("Disconnect ID Server"), description:
From 3c3b530e1e9569751d069516620556a09515e364 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 14 Aug 2019 10:08:30 +0100 Subject: [PATCH 08/10] Spell out identity server Co-Authored-By: J. Ryan Stinnett --- src/components/views/settings/SetIdServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/settings/SetIdServer.js b/src/components/views/settings/SetIdServer.js index 334c9dfbfb..05e87c3e00 100644 --- a/src/components/views/settings/SetIdServer.js +++ b/src/components/views/settings/SetIdServer.js @@ -153,7 +153,7 @@ export default class SetIdServer extends React.Component { _onDisconnectClicked = () => { const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); Modal.createTrackedDialog('Identity Server Disconnect Warning', '', QuestionDialog, { - title: _t("Disconnect ID Server"), + title: _t("Disconnect Identity Server"), description:
{_t( From be7956db61ea059565924e2ed8ac0ee412cd13a3 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 14 Aug 2019 10:08:43 +0100 Subject: [PATCH 09/10] Spell out identity server Co-Authored-By: J. Ryan Stinnett --- src/components/views/settings/SetIdServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/settings/SetIdServer.js b/src/components/views/settings/SetIdServer.js index 05e87c3e00..6c6b8faab2 100644 --- a/src/components/views/settings/SetIdServer.js +++ b/src/components/views/settings/SetIdServer.js @@ -157,7 +157,7 @@ export default class SetIdServer extends React.Component { description:
{_t( - "Disconnect from the ID Server ?", {}, + "Disconnect from the identity server ?", {}, {idserver: sub => {abbreviateUrl(this.state.currentClientIdServer)}}, )},
, From c74da125b255df6aed316a4045ab045f29030904 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 14 Aug 2019 10:12:39 +0100 Subject: [PATCH 10/10] i18n --- src/components/views/settings/SetIdServer.js | 2 +- src/i18n/strings/en_EN.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/views/settings/SetIdServer.js b/src/components/views/settings/SetIdServer.js index 6c6b8faab2..398e578e8d 100644 --- a/src/components/views/settings/SetIdServer.js +++ b/src/components/views/settings/SetIdServer.js @@ -157,7 +157,7 @@ export default class SetIdServer extends React.Component { description:
{_t( - "Disconnect from the identity server ?", {}, + "Disconnect from the identity server ?", {}, {idserver: sub => {abbreviateUrl(this.state.currentClientIdServer)}}, )},
, diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 3d5ee588ef..e5ecc2bf19 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -543,14 +543,14 @@ "Not a valid Identity Server (status code %(code)s)": "Not a valid Identity Server (status code %(code)s)", "Could not connect to Identity Server": "Could not connect to Identity Server", "Checking server": "Checking server", - "Disconnect ID Server": "Disconnect ID Server", - "Disconnect from the ID Server ?": "Disconnect from the ID Server ?", + "Disconnect Identity Server": "Disconnect Identity Server", + "Disconnect from the identity server ?": "Disconnect from the identity server ?", "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.", + "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?",