From 846170b3718a8748d57158b0b8842fc1a8b53493 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 3 Mar 2020 13:33:07 -0700 Subject: [PATCH 01/11] Revert "Fix downloading files in electron not being sent into browser" This reverts commit d89b8b51484c68c6fe0b1325b5d59ee809cc2196. --- src/components/views/elements/ImageView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/elements/ImageView.js b/src/components/views/elements/ImageView.js index f75b735043..e675e6b73f 100644 --- a/src/components/views/elements/ImageView.js +++ b/src/components/views/elements/ImageView.js @@ -216,7 +216,7 @@ export default class ImageView extends React.Component { { this.getName() } { eventMeta } - +
{ _t('Download this file') }
{ sizeRes } From 8234b4d656c9afce2c3211bddfbbd8ea9d6a3318 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 3 Mar 2020 23:11:29 -0700 Subject: [PATCH 02/11] Wire up 'create account' to the SSO button when SSO is used For https://github.com/vector-im/riot-web/issues/12362 --- src/components/structures/auth/Login.js | 31 ++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/components/structures/auth/Login.js b/src/components/structures/auth/Login.js index 24e4726416..0e3792baf5 100644 --- a/src/components/structures/auth/Login.js +++ b/src/components/structures/auth/Login.js @@ -120,8 +120,8 @@ export default createReactClass({ 'm.login.password': this._renderPasswordStep, // CAS and SSO are the same thing, modulo the url we link to - 'm.login.cas': () => this._renderSsoStep(this._loginLogic.getSsoLoginUrl("cas")), - 'm.login.sso': () => this._renderSsoStep(this._loginLogic.getSsoLoginUrl("sso")), + 'm.login.cas': () => this._renderSsoStep(this._getSsoUrl('m.login.cas')), + 'm.login.sso': () => this._renderSsoStep(this._getSsoUrl('m.login.sso')), }; this._initLoginLogic(); @@ -150,6 +150,18 @@ export default createReactClass({ return this.state.busy || this.props.busy; }, + _isSsoStep: function() { + return this._getCurrentFlowStep() === 'm.login.sso' || this._getCurrentFlowStep() === 'm.login.cas'; + }, + + _getSsoUrl: function(kind) { + if (kind === 'm.login.cas') { + return this._loginLogic.getSsoLoginUrl("cas") + } else { + return this._loginLogic.getSsoLoginUrl("sso"); + } + }, + onPasswordLogin: async function(username, phoneCountry, phoneNumber, password) { if (!this.state.serverIsAlive) { this.setState({busy: true}); @@ -344,6 +356,19 @@ export default createReactClass({ this.props.onRegisterClick(); }, + onTryRegisterClick: function(ev) { + if (this._isSsoStep()) { + // If we're showing SSO it means that registration is also probably disabled, + // so intercept the click and instead pretend the user clicked 'Sign in with SSO'. + ev.preventDefault(); + ev.stopPropagation(); + window.location = this._getSsoUrl(this._getCurrentFlowStep()); + } else { + // Don't intercept - just go through to the register page + this.onRegisterClick(ev); + } + }, + async onServerDetailsNextPhaseClick() { this.setState({ phase: PHASE_LOGIN, @@ -654,7 +679,7 @@ export default createReactClass({ { serverDeadSection } { this.renderServerComponent() } { this.renderLoginComponentForStep() } -
+ { _t('Create account') } From 04c54dc5a0444266707a1883ca5722734337be84 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 3 Mar 2020 23:19:36 -0700 Subject: [PATCH 03/11] Redirect registration requests to Login when the server supports SSO For https://github.com/vector-im/riot-web/issues/12362 --- .../structures/auth/Registration.js | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/components/structures/auth/Registration.js b/src/components/structures/auth/Registration.js index 8593a4b1e2..7c6a3ea56f 100644 --- a/src/components/structures/auth/Registration.js +++ b/src/components/structures/auth/Registration.js @@ -31,6 +31,8 @@ import classNames from "classnames"; import * as Lifecycle from '../../../Lifecycle'; import {MatrixClientPeg} from "../../../MatrixClientPeg"; import AuthPage from "../../views/auth/AuthPage"; +import Login from "../../../Login"; +import dis from "../../../dispatcher"; // Phases // Show controls to configure server details @@ -232,6 +234,13 @@ export default createReactClass({ serverRequiresIdServer, busy: false, }); + const showGenericError = (e) => { + this.setState({ + errorText: _t("Unable to query for supported registration methods."), + // add empty flows array to get rid of spinner + flows: [], + }); + }; try { await this._makeRegisterRequest({}); // This should never succeed since we specified an empty @@ -243,18 +252,32 @@ export default createReactClass({ flows: e.data.flows, }); } else if (e.httpStatus === 403 && e.errcode === "M_UNKNOWN") { - this.setState({ - errorText: _t("Registration has been disabled on this homeserver."), - // add empty flows array to get rid of spinner - flows: [], - }); + // At this point registration is pretty much disabled, but before we do that let's + // quickly check to see if the server supports SSO instead. If it does, we'll send + // the user off to the login page to figure their account out. + try { + const loginLogic = new Login(hsUrl, isUrl, null, { + defaultDeviceDisplayName: "riot login check", // We shouldn't ever be used + }); + const flows = await loginLogic.getFlows(); + const hasSsoFlow = flows.find(f => f.type === 'm.login.sso' || f.type === 'm.login.cas'); + if (hasSsoFlow) { + // Redirect to login page - server probably expects SSO only + dis.dispatch({action: 'start_login'}); + } else { + this.setState({ + errorText: _t("Registration has been disabled on this homeserver."), + // add empty flows array to get rid of spinner + flows: [], + }); + } + } catch (e) { + console.error("Failed to get login flows to check for SSO support", e); + showGenericError(e); + } } else { console.log("Unable to query for supported registration methods.", e); - this.setState({ - errorText: _t("Unable to query for supported registration methods."), - // add empty flows array to get rid of spinner - flows: [], - }); + showGenericError(e); } } }, From a12786c1711d2e61671b2b5b1769fd5a35530307 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 3 Mar 2020 23:23:12 -0700 Subject: [PATCH 04/11] 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 79b045dd34..67a43ae14f 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2004,8 +2004,8 @@ "Failed to fetch avatar URL": "Failed to fetch avatar URL", "Set a display name:": "Set a display name:", "Upload an avatar:": "Upload an avatar:", - "Registration has been disabled on this homeserver.": "Registration has been disabled on this homeserver.", "Unable to query for supported registration methods.": "Unable to query for supported registration methods.", + "Registration has been disabled on this homeserver.": "Registration has been disabled on this homeserver.", "This server does not support authentication with a phone number.": "This server does not support authentication with a phone number.", "Your new account (%(newAccountId)s) is registered, but you're already logged into a different account (%(loggedInUserId)s).": "Your new account (%(newAccountId)s) is registered, but you're already logged into a different account (%(loggedInUserId)s).", "Continue with previous account": "Continue with previous account", From 93c696f15e61ff75bceafaaf9cd841db45020961 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 3 Mar 2020 23:26:20 -0700 Subject: [PATCH 05/11] Appease the linter --- src/components/structures/auth/Login.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/auth/Login.js b/src/components/structures/auth/Login.js index 0e3792baf5..e04d311b62 100644 --- a/src/components/structures/auth/Login.js +++ b/src/components/structures/auth/Login.js @@ -156,7 +156,7 @@ export default createReactClass({ _getSsoUrl: function(kind) { if (kind === 'm.login.cas') { - return this._loginLogic.getSsoLoginUrl("cas") + return this._loginLogic.getSsoLoginUrl("cas"); } else { return this._loginLogic.getSsoLoginUrl("sso"); } From 91aa8d4a3afa1bb538b00891da8b4a2c9f35bb47 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 3 Mar 2020 15:42:22 +0100 Subject: [PATCH 06/11] use relative scrolling to compensate when changing height --- src/components/structures/ScrollPanel.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/structures/ScrollPanel.js b/src/components/structures/ScrollPanel.js index 5121dd3f9d..72d5330451 100644 --- a/src/components/structures/ScrollPanel.js +++ b/src/components/structures/ScrollPanel.js @@ -705,17 +705,15 @@ export default createReactClass({ // the currently filled piece of the timeline if (trackedNode) { const oldTop = trackedNode.offsetTop; - // changing the height might change the scrollTop - // if the new height is smaller than the scrollTop. - // We calculate the diff that needs to be applied - // ourselves, so be sure to measure the - // scrollTop before changing the height. - const preexistingScrollTop = sn.scrollTop; itemlist.style.height = `${newHeight}px`; const newTop = trackedNode.offsetTop; const topDiff = newTop - oldTop; - sn.scrollTop = preexistingScrollTop + topDiff; - debuglog("updateHeight to", {newHeight, topDiff, preexistingScrollTop}); + // important to scroll by a relative amount as + // reading scrollTop and then setting it might + // yield out of date values and cause a jump + // when setting it + sn.scrollBy(0, topDiff); + debuglog("updateHeight to", {newHeight, topDiff}); } } }, From 462c3411b296cbde217247ac5914c76528e24163 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 3 Mar 2020 15:42:44 +0100 Subject: [PATCH 07/11] add comment how offset from bottom is calculated --- src/components/structures/ScrollPanel.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/structures/ScrollPanel.js b/src/components/structures/ScrollPanel.js index 72d5330451..548dd70748 100644 --- a/src/components/structures/ScrollPanel.js +++ b/src/components/structures/ScrollPanel.js @@ -765,6 +765,7 @@ export default createReactClass({ }, _topFromBottom(node) { + // current capped height - distance from top = distance from bottom of container to top of tracked element return this._itemlist.current.clientHeight - node.offsetTop; }, From 070b43070205914430267e87aeab91aaf702d6db Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 3 Mar 2020 15:44:59 +0100 Subject: [PATCH 08/11] also use relative scrolling when eh ... doing relative scrolling --- src/components/structures/ScrollPanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/ScrollPanel.js b/src/components/structures/ScrollPanel.js index 548dd70748..b81b3ebede 100644 --- a/src/components/structures/ScrollPanel.js +++ b/src/components/structures/ScrollPanel.js @@ -523,7 +523,7 @@ export default createReactClass({ scrollRelative: function(mult) { const scrollNode = this._getScrollNode(); const delta = mult * scrollNode.clientHeight * 0.5; - scrollNode.scrollTop = scrollNode.scrollTop + delta; + scrollNode.scrollBy(0, delta); this._saveScrollState(); }, From fa79bc93cee5fea5a0cbe2a58b3c64c0c762d1fd Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 2 Mar 2020 17:48:38 +0000 Subject: [PATCH 09/11] Use bash for release script This fixes this repo to use bash for this script, matching the other repos. --- release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.sh b/release.sh index 3c28084bb7..1b99e870ac 100755 --- a/release.sh +++ b/release.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Script to perform a release of matrix-react-sdk. # From cdcf042f6b5ebb5c28614c0d8cf102b1fe0bf5bf Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Wed, 4 Mar 2020 11:30:35 +0000 Subject: [PATCH 10/11] Prepare changelog for v2.2.1 --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88d1895691..8d436ca690 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +Changes in [2.2.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v2.2.1) (2020-03-04) +=================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v2.2.0...v2.2.1) + + * Adjust scroll offset with relative scrolling + [\#4171](https://github.com/matrix-org/matrix-react-sdk/pull/4171) + * Disable registration flows on SSO servers + [\#4169](https://github.com/matrix-org/matrix-react-sdk/pull/4169) + Changes in [2.2.0](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v2.2.0) (2020-03-02) =================================================================================================== [Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v2.2.0-rc.1...v2.2.0) From ce879b95cfe27dc9282fc202ffb5eab091550d22 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Wed, 4 Mar 2020 11:30:35 +0000 Subject: [PATCH 11/11] v2.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f5bd9ec19f..a450cb60f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "2.2.0", + "version": "2.2.1", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": {