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 #2804 from matrix-org/devtools_serverlist
Browse files Browse the repository at this point in the history
Add View Servers in Room to Devtools
  • Loading branch information
turt2live committed May 10, 2019
2 parents 35435ed + cd5a460 commit 3161682
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
7 changes: 6 additions & 1 deletion res/css/views/dialogs/_DevtoolsDialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ limitations under the License.
margin: 10px 0;
}

.mx_DevTools_RoomStateExplorer_button, .mx_DevTools_RoomStateExplorer_query {
.mx_DevTools_ServersInRoomList_button {
/* Set the cursor back to default as `.mx_Dialog button` sets it to pointer */
cursor: default !important;
}

.mx_DevTools_RoomStateExplorer_button, .mx_DevTools_ServersInRoomList_button, .mx_DevTools_RoomStateExplorer_query {
margin-bottom: 10px;
width: 100%;
}
Expand Down
42 changes: 42 additions & 0 deletions src/components/views/dialogs/DevtoolsDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,53 @@ class AccountDataExplorer extends DevtoolsComponent {
}
}

class ServersInRoomList extends DevtoolsComponent {
static getLabel() { return _t('View Servers in Room'); }

static propTypes = {
onBack: PropTypes.func.isRequired,
};

constructor(props, context) {
super(props, context);

const room = MatrixClientPeg.get().getRoom(this.context.roomId);
const servers = new Set();
room.currentState.getStateEvents("m.room.member").forEach(ev => servers.add(ev.getSender().split(":")[1]));
this.servers = Array.from(servers).map(s =>
<button key={s} className="mx_DevTools_ServersInRoomList_button">
{ s }
</button>);

this.state = {
query: '',
};
}

onQuery = (query) => {
this.setState({ query });
}

render() {
return <div>
<div className="mx_Dialog_content">
<FilteredList query={this.state.query} onChange={this.onQuery}>
{ this.servers }
</FilteredList>
</div>
<div className="mx_Dialog_buttons">
<button onClick={this.props.onBack}>{ _t('Back') }</button>
</div>
</div>;
}
}

const Entries = [
SendCustomEvent,
RoomStateExplorer,
SendAccountData,
AccountDataExplorer,
ServersInRoomList,
];

export default class DevtoolsDialog extends React.Component {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@
"Filter results": "Filter results",
"Explore Room State": "Explore Room State",
"Explore Account Data": "Explore Account Data",
"View Servers in Room": "View Servers in Room",
"Toolbox": "Toolbox",
"Developer Tools": "Developer Tools",
"An error has occurred.": "An error has occurred.",
Expand Down

0 comments on commit 3161682

Please sign in to comment.