From b5d2fa769c047448f23be3d33a5deb5cbb496547 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 3 Aug 2018 14:54:52 +0100 Subject: [PATCH 1/3] Support MAU error on sync For https://github.com/vector-im/riot-web/issues/7091 --- res/css/views/globals/_MatrixToolbar.scss | 8 +++++++- res/themes/dark/css/_dark.scss | 1 + res/themes/light/css/_base.scss | 2 ++ src/components/structures/LoggedInView.js | 20 +++++++++++++++++++- src/i18n/strings/en_EN.json | 1 + 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/res/css/views/globals/_MatrixToolbar.scss b/res/css/views/globals/_MatrixToolbar.scss index be69b15f37..1109b9e264 100644 --- a/res/css/views/globals/_MatrixToolbar.scss +++ b/res/css/views/globals/_MatrixToolbar.scss @@ -28,6 +28,12 @@ limitations under the License. margin-top: -2px; } +.mx_MatrixToolbar_error { + padding-left: 16px; + padding-right: 8px; + background-color: $warning-bg-color; +} + .mx_MatrixToolbar_content { flex: 1; } @@ -59,4 +65,4 @@ limitations under the License. .mx_MatrixToolbar_changelog { white-space: pre; -} \ No newline at end of file +} diff --git a/res/themes/dark/css/_dark.scss b/res/themes/dark/css/_dark.scss index 31773ebd09..ad4630d668 100644 --- a/res/themes/dark/css/_dark.scss +++ b/res/themes/dark/css/_dark.scss @@ -19,6 +19,7 @@ $focus-brightness: 200%; // red warning colour $warning-color: #ff0064; +$warning-bg-color: #DF2A8B; // groups $info-plinth-bg-color: #454545; diff --git a/res/themes/light/css/_base.scss b/res/themes/light/css/_base.scss index 55c761e8d9..dedfeaeb2f 100644 --- a/res/themes/light/css/_base.scss +++ b/res/themes/light/css/_base.scss @@ -25,6 +25,8 @@ $focus-brightness: 125%; // red warning colour $warning-color: #ff0064; +// background colour for warnings +$warning-bg-color: #DF2A8B; $mention-user-pill-bg-color: #ff0064; $other-user-pill-bg-color: rgba(0, 0, 0, 0.1); diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index de35e41086..3273989630 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -98,6 +98,7 @@ const LoggedInView = React.createClass({ this._setStateFromSessionStore(); this._matrixClient.on("accountData", this.onAccountData); + this._matrixClient.on("sync", this.onSync); }, componentWillUnmount: function() { @@ -142,6 +143,20 @@ const LoggedInView = React.createClass({ } }, + onSync: function(syncState, oldSyncState, data) { + if (syncState === oldSyncState) return; + + if (syncState === 'ERROR') { + this.setState({ + syncErrorData: data, + }); + } else { + this.setState({ + syncErrorData: null, + }); + } + }, + _onKeyDown: function(ev) { /* // Remove this for now as ctrl+alt = alt-gr so this breaks keyboards which rely on alt-gr for numbers @@ -286,6 +301,7 @@ const LoggedInView = React.createClass({ const NewVersionBar = sdk.getComponent('globals.NewVersionBar'); const UpdateCheckBar = sdk.getComponent('globals.UpdateCheckBar'); const PasswordNagBar = sdk.getComponent('globals.PasswordNagBar'); + const ServerLimitBar = sdk.getComponent('globals.ServerLimitBar'); let page_element; let right_panel = ''; @@ -370,7 +386,9 @@ const LoggedInView = React.createClass({ let topBar; const isGuest = this.props.matrixClient.isGuest(); - if (this.props.showCookieBar && + if (this.state.syncErrorData && this.state.syncErrorData.error.errcode === 'M_MAU_LIMIT_EXCEEDED') { + topBar = ; + } else if (this.props.showCookieBar && this.props.config.piwik ) { const policyUrl = this.props.config.piwik.policyUrl || null; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8270f8b214..1605557a06 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -677,6 +677,7 @@ "A new version of Riot is available.": "A new version of Riot is available.", "To return to your account in future you need to set a password": "To return to your account in future you need to set a password", "Set Password": "Set Password", + "This homeserver has hit its Monthly Active User limit. Please contact your service administrator to continue using the service.": "This homeserver has hit its Monthly Active User limit. Please contact your service administrator to continue using the service.", "Error encountered (%(errorDetail)s).": "Error encountered (%(errorDetail)s).", "Checking for an update...": "Checking for an update...", "No update available.": "No update available.", From 9a2155f1ad6743eab5696e2a816a4953ab8f07a1 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 3 Aug 2018 16:03:27 +0100 Subject: [PATCH 2/3] Oops, add file to right branch --- .../views/globals/ServerLimitBar.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/components/views/globals/ServerLimitBar.js diff --git a/src/components/views/globals/ServerLimitBar.js b/src/components/views/globals/ServerLimitBar.js new file mode 100644 index 0000000000..b85de60953 --- /dev/null +++ b/src/components/views/globals/ServerLimitBar.js @@ -0,0 +1,32 @@ +/* +Copyright 2018 New Vector Ltd + +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 React from 'react'; +import sdk from '../../../index'; +import { _t } from '../../../languageHandler'; + +export default React.createClass({ + render: function() { + const toolbarClasses = "mx_MatrixToolbar mx_MatrixToolbar_error"; + return ( +
+
+ { _t("This homeserver has hit its Monthly Active User limit. Please contact your service administrator to continue using the service.") } +
+
+ ); + }, +}); From cd1874410193340f6afc81d45c280babe24c916e Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 3 Aug 2018 16:10:50 +0100 Subject: [PATCH 3/3] unused import --- src/components/views/globals/ServerLimitBar.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/views/globals/ServerLimitBar.js b/src/components/views/globals/ServerLimitBar.js index b85de60953..638e85634f 100644 --- a/src/components/views/globals/ServerLimitBar.js +++ b/src/components/views/globals/ServerLimitBar.js @@ -15,7 +15,6 @@ limitations under the License. */ import React from 'react'; -import sdk from '../../../index'; import { _t } from '../../../languageHandler'; export default React.createClass({