From 2cdd41b61579c65252237184762cc02dafe7fc53 Mon Sep 17 00:00:00 2001 From: Dirk Klimpel <5740567+dklimpel@users.noreply.github.com> Date: Tue, 4 May 2021 13:57:41 +0200 Subject: [PATCH] Add a new tab to rooms with state events (#108) Co-authored-by: Michael Albert <37796947+awesome-michael@users.noreply.github.com> --- README.md | 2 +- src/App.js | 1 + src/components/rooms.js | 42 ++++++++++++++++++++++++++++++++++++- src/i18n/de.js | 11 +++++++++- src/i18n/en.js | 11 +++++++++- src/synapse/dataProvider.js | 13 ++++++++++++ 6 files changed, 76 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 05cd8ac..78112cc 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This project is built using [react-admin](https://marmelab.com/react-admin/). -It needs at least Synapse v1.23.0 for all functions to work as expected! +It needs at least Synapse v1.27.0 for all functions to work as expected! You get your server version with the request `/_synapse/admin/v1/server_version`. See also [Synapse version API](https://github.com/matrix-org/synapse/blob/develop/docs/admin_api/version_api.rst). diff --git a/src/App.js b/src/App.js index 2ab6161..be4452a 100644 --- a/src/App.js +++ b/src/App.js @@ -71,6 +71,7 @@ const App = () => ( + ); diff --git a/src/components/rooms.js b/src/components/rooms.js index 0c2c514..e89b786 100644 --- a/src/components/rooms.js +++ b/src/components/rooms.js @@ -3,6 +3,7 @@ import { connect } from "react-redux"; import { BooleanField, BulkDeleteButton, + DateField, Datagrid, DeleteButton, Filter, @@ -27,6 +28,7 @@ import PageviewIcon from "@material-ui/icons/Pageview"; import UserIcon from "@material-ui/icons/Group"; import ViewListIcon from "@material-ui/icons/ViewList"; import VisibilityIcon from "@material-ui/icons/Visibility"; +import EventIcon from "@material-ui/icons/Event"; import { RoomDirectoryBulkDeleteButton, RoomDirectoryBulkSaveButton, @@ -113,7 +115,9 @@ export const RoomShow = props => { - + + + { ]} /> + } + path="state" + > + + + + + + + + + + + ); diff --git a/src/i18n/de.js b/src/i18n/de.js index a1a57e3..a221ca4 100644 --- a/src/i18n/de.js +++ b/src/i18n/de.js @@ -139,7 +139,7 @@ export default { joined_members: "Mitglieder", joined_local_members: "Lokale Mitglieder", joined_local_devices: "Lokale Endgeräte", - state_events: "Ereignisse", + state_events: "Zustandsereignisse / Komplexität", version: "Version", is_encrypted: "Verschlüsselt", encryption: "Verschlüsselungs-Algorithmus", @@ -295,6 +295,15 @@ export default { media_length: "Größe der Dateien", }, }, + room_state: { + name: "Zustandsereignisse", + fields: { + type: "Typ", + content: "Inhalt", + origin_server_ts: "Sendezeit", + sender: "Absender", + }, + }, room_directory: { name: "Raumverzeichnis", fields: { diff --git a/src/i18n/en.js b/src/i18n/en.js index ec7f9b4..97573dc 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -137,7 +137,7 @@ export default { joined_members: "Members", joined_local_members: "Local members", joined_local_devices: "Local devices", - state_events: "State events", + state_events: "State events / Complexity", version: "Version", is_encrypted: "Encrypted", encryption: "Encryption", @@ -291,6 +291,15 @@ export default { media_length: "Media length", }, }, + room_state: { + name: "State events", + fields: { + type: "Type", + content: "Content", + origin_server_ts: "time of send", + sender: "Sender", + }, + }, room_directory: { name: "Room directory", fields: { diff --git a/src/synapse/dataProvider.js b/src/synapse/dataProvider.js index 245852c..b7cd5c2 100644 --- a/src/synapse/dataProvider.js +++ b/src/synapse/dataProvider.js @@ -117,6 +117,19 @@ const resourceMap = { return json.total; }, }, + room_state: { + map: rs => ({ + ...rs, + id: rs.event_id, + }), + reference: id => ({ + endpoint: `/_synapse/admin/v1/rooms/${id}/state`, + }), + data: "state", + total: json => { + return json.state.length; + }, + }, pushers: { map: p => ({ ...p,