This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 830
Disconnect from IS Button #3305
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
384f07a
Disconnect from IS button
dbkr ebc84b4
Merge remote-tracking branch 'origin/dbkr/change_is' into dbkr/disco_is
dbkr 115e4c0
Remove IS access token too
dbkr 0b51a5f
c+p fail
dbkr 0c4b29f
Merge remote-tracking branch 'origin/dbkr/change_is' into dbkr/disco_is
dbkr b694a56
i18n
dbkr 735c6d7
Merge remote-tracking branch 'origin/develop' into dbkr/disco_is
dbkr b0420c1
Prepopulate client default on disconnect
dbkr 0d56010
Kill smart quotes
dbkr 8549761
Spell out identity server
dbkr 3c3b530
Spell out identity server
dbkr be7956d
Spell out identity server
dbkr c74da12
i18n
dbkr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import {_t} from "../../../languageHandler"; | |
import sdk from '../../../index'; | ||
import MatrixClientPeg from "../../../MatrixClientPeg"; | ||
import SdkConfig from "../../../SdkConfig"; | ||
import Modal from '../../../Modal'; | ||
import dis from "../../../dispatcher"; | ||
|
||
/** | ||
|
@@ -149,7 +150,49 @@ export default class SetIdServer extends React.Component { | |
}); | ||
}; | ||
|
||
_onDisconnectClicked = () => { | ||
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); | ||
Modal.createTrackedDialog('Identity Server Disconnect Warning', '', QuestionDialog, { | ||
title: _t("Disconnect Identity Server"), | ||
description: | ||
<div> | ||
{_t( | ||
"Disconnect from the identity server <idserver />?", {}, | ||
{idserver: sub => <b>{abbreviateUrl(this.state.currentClientIdServer)}</b>}, | ||
)}, | ||
</div>, | ||
button: _t("Disconnect"), | ||
onFinished: (confirmed) => { | ||
if (confirmed) { | ||
this._disconnectIdServer(); | ||
} | ||
}, | ||
}); | ||
}; | ||
|
||
_disconnectIdServer = () => { | ||
MatrixClientPeg.get().setIdentityServerUrl(null); | ||
localStorage.removeItem("mx_is_access_token"); | ||
localStorage.removeItem("mx_is_url"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kinda wonder if these 3 things should happen in the Lifecycle? It feels a bit dirty to manipulate the settings here. This is probably fine though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, probably, but since it's currently only used here I'd probably argue for moving it into a function in lifecycle if we ever use it anywhere else. |
||
|
||
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: newFieldVal, | ||
}); | ||
}; | ||
|
||
render() { | ||
const AccessibleButton = sdk.getComponent('views.elements.AccessibleButton'); | ||
const Field = sdk.getComponent('elements.Field'); | ||
const idServerUrl = this.state.currentClientIdServer; | ||
let sectionTitle; | ||
let bodyText; | ||
|
@@ -170,8 +213,20 @@ export default class SetIdServer extends React.Component { | |
); | ||
} | ||
|
||
const AccessibleButton = sdk.getComponent('elements.AccessibleButton'); | ||
const Field = sdk.getComponent('elements.Field'); | ||
let discoSection; | ||
if (idServerUrl) { | ||
discoSection = <div> | ||
<span className="mx_SettingsTab_subsectionText">{_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.", | ||
)}</span> | ||
<AccessibleButton onClick={this._onDisconnectClicked} kind="danger"> | ||
{_t("Disconnect")} | ||
</AccessibleButton> | ||
</div>; | ||
} | ||
|
||
return ( | ||
<form className="mx_SettingsTab_section mx_SetIdServer" onSubmit={this._saveIdServer}> | ||
<span className="mx_SettingsTab_subheading"> | ||
|
@@ -187,9 +242,10 @@ export default class SetIdServer extends React.Component { | |
tooltipContent={this._getTooltip()} | ||
/> | ||
<AccessibleButton type="submit" kind="primary_sm" | ||
disabled={!this._idServerChangeEnabled()} | ||
onClick={this._saveIdServer} | ||
disabled={!this._idServerChangeEnabled()} | ||
>{_t("Change")}</AccessibleButton> | ||
{discoSection} | ||
</form> | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that this dialog is really adding that much, since it just confirms removing the server, and we're already making the first button appear dangerous... I wonder if @nadonomy has an opinion.
I think we do want some kind of step that warns about disconnecting the IS when there are 3PIDs currrently bound, as mentioned in the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying it with no confirmation felt very trigger-happy - I might even argue that for establishing the convention that any danger button has a confirmation.