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
This commit is contained in:
Travis Ralston 2019-04-10 15:00:02 -06:00
parent 6c8b93049d
commit 15e8ce7a7f
4 changed files with 53 additions and 1 deletions

View file

@ -72,3 +72,7 @@ limitations under the License.
// give them more visual distinction between the sections. // give them more visual distinction between the sections.
margin-top: 30px; margin-top: 30px;
} }
.mx_SettingsTab a {
color: $accent-color-alt;
}

View file

@ -52,7 +52,7 @@ export default class RoomSettingsDialog extends React.Component {
tabs.push(new Tab( tabs.push(new Tab(
_td("Advanced"), _td("Advanced"),
"mx_RoomSettingsDialog_warningIcon", "mx_RoomSettingsDialog_warningIcon",
<AdvancedRoomSettingsTab roomId={this.props.roomId} />, <AdvancedRoomSettingsTab roomId={this.props.roomId} closeSettingsFn={this.props.onFinished} />,
)); ));
return tabs; return tabs;

View file

@ -21,10 +21,12 @@ import MatrixClientPeg from "../../../../../MatrixClientPeg";
import sdk from "../../../../.."; import sdk from "../../../../..";
import AccessibleButton from "../../../elements/AccessibleButton"; import AccessibleButton from "../../../elements/AccessibleButton";
import Modal from "../../../../../Modal"; import Modal from "../../../../../Modal";
import dis from "../../../../../dispatcher";
export default class AdvancedRoomSettingsTab extends React.Component { export default class AdvancedRoomSettingsTab extends React.Component {
static propTypes = { static propTypes = {
roomId: PropTypes.string.isRequired, roomId: PropTypes.string.isRequired,
closeSettingsFn: PropTypes.func.isRequired,
}; };
constructor() { constructor() {
@ -41,9 +43,21 @@ export default class AdvancedRoomSettingsTab extends React.Component {
const room = MatrixClientPeg.get().getRoom(this.props.roomId); const room = MatrixClientPeg.get().getRoom(this.props.roomId);
room.getRecommendedVersion().then((v) => { room.getRecommendedVersion().then((v) => {
const tombstone = room.currentState.getStateEvents("m.room.tombstone", ""); 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({ this.setState({
upgraded: tombstone && tombstone.getContent().replacement_room, upgraded: tombstone && tombstone.getContent().replacement_room,
upgradeRecommendation: v, upgradeRecommendation: v,
...additionalStateChanges,
}); });
}); });
} }
@ -59,6 +73,18 @@ export default class AdvancedRoomSettingsTab extends React.Component {
Modal.createDialog(DevtoolsDialog, {roomId: this.props.roomId}); 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() { render() {
const client = MatrixClientPeg.get(); const client = MatrixClientPeg.get();
const room = client.getRoom(this.props.roomId); 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 = (
<div>
{_t(
"This is the upgraded version of another room. <a>Click here to visit the old room</a>.",
{}, {
'a': (sub) => {
return (
<AccessibleButton element='a' onClick={this._onOldRoomClicked}>
{sub}
</AccessibleButton>
);
},
},
)}
</div>
);
}
return ( return (
<div className="mx_SettingsTab"> <div className="mx_SettingsTab">
<div className="mx_SettingsTab_heading">{_t("Advanced")}</div> <div className="mx_SettingsTab_heading">{_t("Advanced")}</div>
@ -108,6 +154,7 @@ export default class AdvancedRoomSettingsTab extends React.Component {
<span>{_t("Room version:")}</span>&nbsp; <span>{_t("Room version:")}</span>&nbsp;
{room.getVersion()} {room.getVersion()}
</div> </div>
{oldRoomLink}
{roomUpgradeButton} {roomUpgradeButton}
</div> </div>
<div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'> <div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'>

View file

@ -599,6 +599,7 @@
"Voice & Video": "Voice & Video", "Voice & Video": "Voice & Video",
"This room is not accessible by remote Matrix servers": "This room is not accessible by remote Matrix servers", "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", "Upgrade this room to the recommended room version": "Upgrade this room to the recommended room version",
"This is the upgraded version of another room. <a>Click here to visit the old room</a>.": "This is the upgraded version of another room. <a>Click here to visit the old room</a>.",
"Room information": "Room information", "Room information": "Room information",
"Internal room ID:": "Internal room ID:", "Internal room ID:": "Internal room ID:",
"Room version": "Room version", "Room version": "Room version",