From 2fe7f6fe1c106e5254992f20876d791e3959ffae Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 29 Jan 2019 18:23:01 -0700 Subject: [PATCH 1/4] Implement the Advanced tab of new room settings --- .../views/dialogs/RoomSettingsDialog.js | 3 +- .../settings/tabs/AdvancedRoomSettingsTab.js | 107 ++++++++++++++++++ src/i18n/strings/en_EN.json | 13 ++- 3 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 src/components/views/settings/tabs/AdvancedRoomSettingsTab.js diff --git a/src/components/views/dialogs/RoomSettingsDialog.js b/src/components/views/dialogs/RoomSettingsDialog.js index 99e73fb2e02..07ff62b949f 100644 --- a/src/components/views/dialogs/RoomSettingsDialog.js +++ b/src/components/views/dialogs/RoomSettingsDialog.js @@ -18,6 +18,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import {Tab, TabbedView} from "../../structures/TabbedView"; import {_t, _td} from "../../../languageHandler"; +import AdvancedRoomSettingsTab from "../settings/tabs/AdvancedRoomSettingsTab"; import AccessibleButton from "../elements/AccessibleButton"; import dis from '../../../dispatcher'; import GeneralRoomSettingsTab from "../settings/tabs/GeneralRoomSettingsTab"; @@ -78,7 +79,7 @@ export default class RoomSettingsDialog extends React.Component { tabs.push(new Tab( _td("Advanced"), "mx_RoomSettingsDialog_warningIcon", -
Advanced Test
, + , )); tabs.push(new Tab( _td("Visit old settings"), diff --git a/src/components/views/settings/tabs/AdvancedRoomSettingsTab.js b/src/components/views/settings/tabs/AdvancedRoomSettingsTab.js new file mode 100644 index 00000000000..6fcd024d17e --- /dev/null +++ b/src/components/views/settings/tabs/AdvancedRoomSettingsTab.js @@ -0,0 +1,107 @@ +/* +Copyright 2019 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 PropTypes from 'prop-types'; +import {_t} from "../../../../languageHandler"; +import RoomProfileSettings from "../../room_settings/RoomProfileSettings"; +import MatrixClientPeg from "../../../../MatrixClientPeg"; +import sdk from "../../../../index"; +import AccessibleButton from "../../elements/AccessibleButton"; +import {MatrixClient} from "matrix-js-sdk"; +import dis from "../../../../dispatcher"; +import Modal from "../../../../Modal"; + +export default class AdvancedRoomSettingsTab extends React.Component { + static propTypes = { + roomId: PropTypes.string.isRequired, + }; + + constructor() { + super(); + + this.state = { + // This is eventually set to the value of room.getRecommendedVersion() + upgradeRecommendation: null, + }; + } + + componentWillMount(): void { + // we handle lack of this object gracefully later, so don't worry about it failing here. + MatrixClientPeg.get().getRoom(this.props.roomId).getRecommendedVersion().then((v) => { + this.setState({upgradeRecommendation: v}); + }); + } + + _upgradeRoom = (e) => { + const RoomUpgradeDialog = sdk.getComponent('dialogs.RoomUpgradeDialog'); + const room = MatrixClientPeg.get().getRoom(this.props.roomId); + Modal.createTrackedDialog('Upgrade Room Version', '', RoomUpgradeDialog, {room: room}); + }; + + _openDevtools = (e) => { + const DevtoolsDialog = sdk.getComponent('dialogs.DevtoolsDialog'); + Modal.createDialog(DevtoolsDialog, {roomId: this.props.roomId}); + }; + + render() { + const client = MatrixClientPeg.get(); + const room = client.getRoom(this.props.roomId); + + let unfederatableSection; + const createEvent = room.currentState.getStateEvents('m.room.create', ''); + if (createEvent && createEvent.getContent()['m.federate'] === false) { + unfederatableSection =
{_t('This room is not accessible by remote Matrix servers')}
; + } + + let roomUpgradeButton; + if (this.state.upgradeRecommendation && this.state.upgradeRecommendation.needsUpgrade) { + roomUpgradeButton = ( + + {_t("Upgrade room to version %(ver)s", {ver: this.state.upgradeRecommendation.version})} + + ); + } + + return ( +
+
{_t("Advanced")}
+
+ {_t("Room information")} +
+ {_t("Internal room ID:")}  + {this.props.roomId} +
+ {unfederatableSection} +
+
+ {_t("Room version")} +
+ {_t("Room version:")}  + {room.getVersion()} +
+ {roomUpgradeButton} +
+
+ {_t("Developer options")} + + {_t("Open Devtools")} + +
+
+ ); + } +} diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 296165de9f4..9a5df30260a 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -430,6 +430,15 @@ "Upload profile picture": "Upload profile picture", "Display Name": "Display Name", "Save": "Save", + "This room is not accessible by remote Matrix servers": "This room is not accessible by remote Matrix servers", + "Upgrade room to version %(ver)s": "Upgrade room to version %(ver)s", + "Advanced": "Advanced", + "Room information": "Room information", + "Internal room ID:": "Internal room ID:", + "Room version": "Room version", + "Room version:": "Room version:", + "Developer options": "Developer options", + "Open Devtools": "Open Devtools", "Flair": "Flair", "General": "General", "Room Addresses": "Room Addresses", @@ -466,7 +475,6 @@ "matrix-react-sdk version:": "matrix-react-sdk version:", "riot-web version:": "riot-web version:", "olm version:": "olm version:", - "Advanced": "Advanced", "Homeserver is": "Homeserver is", "Identity Server is": "Identity Server is", "Access Token:": "Access Token:", @@ -722,15 +730,12 @@ "Privileged Users": "Privileged Users", "Muted Users": "Muted Users", "Banned users": "Banned users", - "This room is not accessible by remote Matrix servers": "This room is not accessible by remote Matrix servers", "Favourite": "Favourite", "Tagged as: ": "Tagged as: ", "To link to a room it must have an address.": "To link to a room it must have an address.", "Guests cannot join this room even if explicitly invited.": "Guests cannot join this room even if explicitly invited.", "Click here to fix": "Click here to fix", "To send events of type , you must be a": "To send events of type , you must be a", - "Upgrade room to version %(ver)s": "Upgrade room to version %(ver)s", - "Open Devtools": "Open Devtools", "Who can access this room?": "Who can access this room?", "Only people who have been invited": "Only people who have been invited", "Anyone who knows the room's link, apart from guests": "Anyone who knows the room's link, apart from guests", From e7ed4c13f589033b0a6c4e85801acf12c936a608 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 29 Jan 2019 18:28:44 -0700 Subject: [PATCH 2/4] Appease the linter I should really just get something that does this for me prior to opening a PR --- src/components/views/settings/tabs/AdvancedRoomSettingsTab.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/views/settings/tabs/AdvancedRoomSettingsTab.js b/src/components/views/settings/tabs/AdvancedRoomSettingsTab.js index 6fcd024d17e..a0f24000a81 100644 --- a/src/components/views/settings/tabs/AdvancedRoomSettingsTab.js +++ b/src/components/views/settings/tabs/AdvancedRoomSettingsTab.js @@ -17,12 +17,9 @@ limitations under the License. import React from 'react'; import PropTypes from 'prop-types'; import {_t} from "../../../../languageHandler"; -import RoomProfileSettings from "../../room_settings/RoomProfileSettings"; import MatrixClientPeg from "../../../../MatrixClientPeg"; import sdk from "../../../../index"; import AccessibleButton from "../../elements/AccessibleButton"; -import {MatrixClient} from "matrix-js-sdk"; -import dis from "../../../../dispatcher"; import Modal from "../../../../Modal"; export default class AdvancedRoomSettingsTab extends React.Component { From b3bb3aff844ae46499bfc8669acea0e90e5362b7 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 29 Jan 2019 21:46:51 -0700 Subject: [PATCH 3/4] Remove spurious void --- src/components/views/settings/tabs/AdvancedRoomSettingsTab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/settings/tabs/AdvancedRoomSettingsTab.js b/src/components/views/settings/tabs/AdvancedRoomSettingsTab.js index a0f24000a81..9b996225161 100644 --- a/src/components/views/settings/tabs/AdvancedRoomSettingsTab.js +++ b/src/components/views/settings/tabs/AdvancedRoomSettingsTab.js @@ -36,7 +36,7 @@ export default class AdvancedRoomSettingsTab extends React.Component { }; } - componentWillMount(): void { + componentWillMount() { // we handle lack of this object gracefully later, so don't worry about it failing here. MatrixClientPeg.get().getRoom(this.props.roomId).getRecommendedVersion().then((v) => { this.setState({upgradeRecommendation: v}); From da95bf9c08d0fcb9113a427db8f02a1eb993fbd6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 29 Jan 2019 21:50:13 -0700 Subject: [PATCH 4/4] Regen i18n due to merge --- src/i18n/strings/en_EN.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ada60f94740..a0b37a61e1d 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -513,7 +513,6 @@ "Muted Users": "Muted Users", "Banned users": "Banned users", "To send events of type , you must be a": "To send events of type , you must be a", - "This room is not accessible by remote Matrix servers": "This room is not accessible by remote Matrix servers", "Roles & Permissions": "Roles & Permissions", "Permissions": "Permissions", "Unignore": "Unignore", @@ -739,8 +738,6 @@ "To link to a room it must have an address.": "To link to a room it must have an address.", "Guests cannot join this room even if explicitly invited.": "Guests cannot join this room even if explicitly invited.", "Click here to fix": "Click here to fix", - "Upgrade room to version %(ver)s": "Upgrade room to version %(ver)s", - "Open Devtools": "Open Devtools", "Who can access this room?": "Who can access this room?", "Only people who have been invited": "Only people who have been invited", "Anyone who knows the room's link, apart from guests": "Anyone who knows the room's link, apart from guests",