Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2908 from matrix-org/travis/upgrades/linkback
Browse files Browse the repository at this point in the history
Add a link in room settings to get at the tombstoned room if it exists
  • Loading branch information
turt2live authored Apr 12, 2019
2 parents 58ff5dc + ec01f6f commit e8d141f
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
4 changes: 4 additions & 0 deletions res/css/views/settings/tabs/_SettingsTab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/components/views/dialogs/RoomSettingsDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class RoomSettingsDialog extends React.Component {
tabs.push(new Tab(
_td("Advanced"),
"mx_RoomSettingsDialog_warningIcon",
<AdvancedRoomSettingsTab roomId={this.props.roomId} />,
<AdvancedRoomSettingsTab roomId={this.props.roomId} closeSettingsFn={this.props.onFinished} />,
));

return tabs;
Expand Down
39 changes: 39 additions & 0 deletions src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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", "");

const additionalStateChanges = {};
const createEvent = room.currentState.getStateEvents("m.room.create", "");
const 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,
});
});
}
Expand All @@ -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);
Expand Down Expand Up @@ -91,6 +117,18 @@ 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 = (
<AccessibleButton element='a' onClick={this._onOldRoomClicked}>
{_t("View older messages in %(roomName)s.", {roomName: name})}
</AccessibleButton>
);
}

return (
<div className="mx_SettingsTab">
<div className="mx_SettingsTab_heading">{_t("Advanced")}</div>
Expand All @@ -108,6 +146,7 @@ export default class AdvancedRoomSettingsTab extends React.Component {
<span>{_t("Room version:")}</span>&nbsp;
{room.getVersion()}
</div>
{oldRoomLink}
{roomUpgradeButton}
</div>
<div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'>
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +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 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",
Expand Down

0 comments on commit e8d141f

Please sign in to comment.