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

Commit 3161682

Browse files
authored
Merge pull request #2804 from matrix-org/devtools_serverlist
Add View Servers in Room to Devtools
2 parents 35435ed + cd5a460 commit 3161682

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

res/css/views/dialogs/_DevtoolsDialog.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ limitations under the License.
1818
margin: 10px 0;
1919
}
2020

21-
.mx_DevTools_RoomStateExplorer_button, .mx_DevTools_RoomStateExplorer_query {
21+
.mx_DevTools_ServersInRoomList_button {
22+
/* Set the cursor back to default as `.mx_Dialog button` sets it to pointer */
23+
cursor: default !important;
24+
}
25+
26+
.mx_DevTools_RoomStateExplorer_button, .mx_DevTools_ServersInRoomList_button, .mx_DevTools_RoomStateExplorer_query {
2227
margin-bottom: 10px;
2328
width: 100%;
2429
}

src/components/views/dialogs/DevtoolsDialog.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,53 @@ class AccountDataExplorer extends DevtoolsComponent {
551551
}
552552
}
553553

554+
class ServersInRoomList extends DevtoolsComponent {
555+
static getLabel() { return _t('View Servers in Room'); }
556+
557+
static propTypes = {
558+
onBack: PropTypes.func.isRequired,
559+
};
560+
561+
constructor(props, context) {
562+
super(props, context);
563+
564+
const room = MatrixClientPeg.get().getRoom(this.context.roomId);
565+
const servers = new Set();
566+
room.currentState.getStateEvents("m.room.member").forEach(ev => servers.add(ev.getSender().split(":")[1]));
567+
this.servers = Array.from(servers).map(s =>
568+
<button key={s} className="mx_DevTools_ServersInRoomList_button">
569+
{ s }
570+
</button>);
571+
572+
this.state = {
573+
query: '',
574+
};
575+
}
576+
577+
onQuery = (query) => {
578+
this.setState({ query });
579+
}
580+
581+
render() {
582+
return <div>
583+
<div className="mx_Dialog_content">
584+
<FilteredList query={this.state.query} onChange={this.onQuery}>
585+
{ this.servers }
586+
</FilteredList>
587+
</div>
588+
<div className="mx_Dialog_buttons">
589+
<button onClick={this.props.onBack}>{ _t('Back') }</button>
590+
</div>
591+
</div>;
592+
}
593+
}
594+
554595
const Entries = [
555596
SendCustomEvent,
556597
RoomStateExplorer,
557598
SendAccountData,
558599
AccountDataExplorer,
600+
ServersInRoomList,
559601
];
560602

561603
export default class DevtoolsDialog extends React.Component {

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,7 @@
11331133
"Filter results": "Filter results",
11341134
"Explore Room State": "Explore Room State",
11351135
"Explore Account Data": "Explore Account Data",
1136+
"View Servers in Room": "View Servers in Room",
11361137
"Toolbox": "Toolbox",
11371138
"Developer Tools": "Developer Tools",
11381139
"An error has occurred.": "An error has occurred.",

0 commit comments

Comments
 (0)