From c029ddb99a71c5c1559160fd2d9b42acb5abc828 Mon Sep 17 00:00:00 2001 From: dklimpel <5740567+dklimpel@users.noreply.github.com> Date: Sat, 23 Jan 2021 18:31:43 +0100 Subject: [PATCH] Add a new tab to user page with room memberships The admin API for user's room memberships is new in synapse v1.21.0. --- src/App.js | 1 + src/components/users.js | 36 ++++++++++++++++++++++++++++++++++++ src/synapse/dataProvider.js | 12 ++++++++++++ 3 files changed, 49 insertions(+) diff --git a/src/App.js b/src/App.js index 5b784c4..e5f19e1 100644 --- a/src/App.js +++ b/src/App.js @@ -52,6 +52,7 @@ const App = () => ( + ); diff --git a/src/components/users.js b/src/components/users.js index 5f8caf8..6d9a37c 100644 --- a/src/components/users.js +++ b/src/components/users.js @@ -5,6 +5,7 @@ import ContactMailIcon from "@material-ui/icons/ContactMail"; import DevicesIcon from "@material-ui/icons/Devices"; import GetAppIcon from "@material-ui/icons/GetApp"; import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent"; +import ViewListIcon from "@material-ui/icons/ViewList"; import { ArrayInput, ArrayField, @@ -312,6 +313,7 @@ export const UserEdit = props => { /> + } @@ -330,6 +332,7 @@ export const UserEdit = props => { + } @@ -361,6 +364,7 @@ export const UserEdit = props => { + } @@ -400,6 +404,38 @@ export const UserEdit = props => { + + } + path="rooms" + > + + "/rooms/" + id + "/show"} + > + + + + + + + ); diff --git a/src/synapse/dataProvider.js b/src/synapse/dataProvider.js index 560bdb9..f1f0816 100644 --- a/src/synapse/dataProvider.js +++ b/src/synapse/dataProvider.js @@ -113,6 +113,18 @@ const resourceMap = { data: "members", total: json => json.members.length, }, + joined_rooms: { + map: jr => ({ + id: jr, + }), + reference: id => ({ + endpoint: `/_synapse/admin/v1/users/${id}/joined_rooms`, + }), + data: "joined_rooms", + total: json => { + return json.total; + }, + }, servernotices: { map: n => ({ id: n.event_id }), create: data => ({