From 15e8ce7a7f65a7f8e95b501e16b59dbe4b8f6d8b Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 10 Apr 2019 15:00:02 -0600 Subject: [PATCH 1/3] Add a link in room settings to get at the tombstoned room if it exists Fixes https://github.com/vector-im/riot-web/issues/8542 --- res/css/views/settings/tabs/_SettingsTab.scss | 4 ++ .../views/dialogs/RoomSettingsDialog.js | 2 +- .../tabs/room/AdvancedRoomSettingsTab.js | 47 +++++++++++++++++++ src/i18n/strings/en_EN.json | 1 + 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/res/css/views/settings/tabs/_SettingsTab.scss b/res/css/views/settings/tabs/_SettingsTab.scss index 88735f99b2..def28bfbd2 100644 --- a/res/css/views/settings/tabs/_SettingsTab.scss +++ b/res/css/views/settings/tabs/_SettingsTab.scss @@ -72,3 +72,7 @@ limitations under the License. // give them more visual distinction between the sections. margin-top: 30px; } + +.mx_SettingsTab a { + color: $accent-color-alt; +} \ No newline at end of file diff --git a/src/components/views/dialogs/RoomSettingsDialog.js b/src/components/views/dialogs/RoomSettingsDialog.js index 22b7857264..05ed262078 100644 --- a/src/components/views/dialogs/RoomSettingsDialog.js +++ b/src/components/views/dialogs/RoomSettingsDialog.js @@ -52,7 +52,7 @@ export default class RoomSettingsDialog extends React.Component { tabs.push(new Tab( _td("Advanced"), "mx_RoomSettingsDialog_warningIcon", - , + , )); return tabs; diff --git a/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js b/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js index 20c270fe29..183631ae7a 100644 --- a/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js +++ b/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js @@ -21,10 +21,12 @@ import MatrixClientPeg from "../../../../../MatrixClientPeg"; import sdk from "../../../../.."; import AccessibleButton from "../../../elements/AccessibleButton"; import Modal from "../../../../../Modal"; +import dis from "../../../../../dispatcher"; export default class AdvancedRoomSettingsTab extends React.Component { static propTypes = { roomId: PropTypes.string.isRequired, + closeSettingsFn: PropTypes.func.isRequired, }; constructor() { @@ -41,9 +43,21 @@ export default class AdvancedRoomSettingsTab extends React.Component { const room = MatrixClientPeg.get().getRoom(this.props.roomId); room.getRecommendedVersion().then((v) => { const tombstone = room.currentState.getStateEvents("m.room.tombstone", ""); + + let additionalStateChanges = {}; + const createEvent = room.currentState.getStateEvents("m.room.create", ""); + let predecessor = createEvent ? createEvent.getContent().predecessor : null; + if (predecessor && predecessor.room_id) { + additionalStateChanges['oldRoomId'] = predecessor.room_id; + additionalStateChanges['oldEventId'] = predecessor.event_id; + additionalStateChanges['hasPreviousRoom'] = true; + } + + this.setState({ upgraded: tombstone && tombstone.getContent().replacement_room, upgradeRecommendation: v, + ...additionalStateChanges, }); }); } @@ -59,6 +73,18 @@ export default class AdvancedRoomSettingsTab extends React.Component { Modal.createDialog(DevtoolsDialog, {roomId: this.props.roomId}); }; + _onOldRoomClicked = (e) => { + e.preventDefault(); + e.stopPropagation(); + + dis.dispatch({ + action: 'view_room', + room_id: this.state.oldRoomId, + event_id: this.state.oldEventId, + }); + this.props.closeSettingsFn(); + }; + render() { const client = MatrixClientPeg.get(); const room = client.getRoom(this.props.roomId); @@ -91,6 +117,26 @@ export default class AdvancedRoomSettingsTab extends React.Component { ); } + let oldRoomLink; + if (this.state.hasPreviousRoom) { + oldRoomLink = ( +
+ {_t( + "This is the upgraded version of another room. Click here to visit the old room.", + {}, { + 'a': (sub) => { + return ( + + {sub} + + ); + }, + }, + )} +
+ ); + } + return (
{_t("Advanced")}
@@ -108,6 +154,7 @@ export default class AdvancedRoomSettingsTab extends React.Component { {_t("Room version:")}  {room.getVersion()}
+ {oldRoomLink} {roomUpgradeButton}
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8e3f0d9f6e..c20ea08a91 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -599,6 +599,7 @@ "Voice & Video": "Voice & Video", "This room is not accessible by remote Matrix servers": "This room is not accessible by remote Matrix servers", "Upgrade this room to the recommended room version": "Upgrade this room to the recommended room version", + "This is the upgraded version of another room. Click here to visit the old room.": "This is the upgraded version of another room. Click here to visit the old room.", "Room information": "Room information", "Internal room ID:": "Internal room ID:", "Room version": "Room version", From 64423e1f7d8dbd905aace061f185c0b140d0b02e Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 10 Apr 2019 15:34:06 -0600 Subject: [PATCH 2/3] let -> const --- .../views/settings/tabs/room/AdvancedRoomSettingsTab.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js b/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js index 183631ae7a..b09274adfd 100644 --- a/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js +++ b/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js @@ -44,9 +44,9 @@ export default class AdvancedRoomSettingsTab extends React.Component { room.getRecommendedVersion().then((v) => { const tombstone = room.currentState.getStateEvents("m.room.tombstone", ""); - let additionalStateChanges = {}; + const additionalStateChanges = {}; const createEvent = room.currentState.getStateEvents("m.room.create", ""); - let predecessor = createEvent ? createEvent.getContent().predecessor : null; + const predecessor = createEvent ? createEvent.getContent().predecessor : null; if (predecessor && predecessor.room_id) { additionalStateChanges['oldRoomId'] = predecessor.room_id; additionalStateChanges['oldEventId'] = predecessor.event_id; From ec01f6ffb121b0cb88c55ac9f6390f6c28cebdba Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 11 Apr 2019 10:40:25 -0600 Subject: [PATCH 3/3] Change wording for old room link --- .../tabs/room/AdvancedRoomSettingsTab.js | 20 ++++++------------- src/i18n/strings/en_EN.json | 3 ++- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js b/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js index b09274adfd..101cd036e5 100644 --- a/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js +++ b/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js @@ -119,21 +119,13 @@ export default class AdvancedRoomSettingsTab extends React.Component { let oldRoomLink; if (this.state.hasPreviousRoom) { + let name = _t("this room"); + const room = MatrixClientPeg.get().getRoom(this.props.roomId); + if (room && room.name) name = room.name; oldRoomLink = ( -
- {_t( - "This is the upgraded version of another room. Click here to visit the old room.", - {}, { - 'a': (sub) => { - return ( - - {sub} - - ); - }, - }, - )} -
+ + {_t("View older messages in %(roomName)s.", {roomName: name})} + ); } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index c20ea08a91..6b9bc413a2 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -599,7 +599,8 @@ "Voice & Video": "Voice & Video", "This room is not accessible by remote Matrix servers": "This room is not accessible by remote Matrix servers", "Upgrade this room to the recommended room version": "Upgrade this room to the recommended room version", - "This is the upgraded version of another room. Click here to visit the old room.": "This is the upgraded version of another room. Click here to visit the old room.", + "this room": "this room", + "View older messages in %(roomName)s": "View older messages in %(roomName)s", "Room information": "Room information", "Internal room ID:": "Internal room ID:", "Room version": "Room version",