From 3ea1f51eb5842cbf592451828d1a2fb9ceedb9e6 Mon Sep 17 00:00:00 2001 From: Dirk Klimpel <5740567+dklimpel@users.noreply.github.com> Date: Sat, 8 May 2021 19:10:51 +0200 Subject: [PATCH] Add a new tab to rooms with forward extremities (#107) Add a new tab to rooms with forward extremities. --- src/App.js | 1 + src/components/rooms.js | 46 +++++++++++++++++++++++++++++++++++++ src/i18n/de.js | 13 +++++++++++ src/i18n/en.js | 13 +++++++++++ src/synapse/dataProvider.js | 16 +++++++++++++ 5 files changed, 89 insertions(+) diff --git a/src/App.js b/src/App.js index 54c05f8..018f18c 100644 --- a/src/App.js +++ b/src/App.js @@ -73,6 +73,7 @@ const App = () => ( + ); diff --git a/src/components/rooms.js b/src/components/rooms.js index 47f309b..d91db05 100644 --- a/src/components/rooms.js +++ b/src/components/rooms.js @@ -8,6 +8,7 @@ import { DeleteButton, Filter, List, + NumberField, Pagination, ReferenceField, ReferenceManyField, @@ -23,7 +24,9 @@ import { } from "react-admin"; import get from "lodash/get"; import PropTypes from "prop-types"; +import { makeStyles } from "@material-ui/core/styles"; import { Tooltip, Typography, Chip } from "@material-ui/core"; +import FastForwardIcon from "@material-ui/icons/FastForward"; import HttpsIcon from "@material-ui/icons/Https"; import NoEncryptionIcon from "@material-ui/icons/NoEncryption"; import PageviewIcon from "@material-ui/icons/Pageview"; @@ -38,6 +41,13 @@ import { RoomDirectorySaveButton, } from "./RoomDirectory"; +const useStyles = makeStyles(theme => ({ + helper_forward_extremities: { + fontFamily: "Roboto, Helvetica, Arial, sans-serif", + margin: "0.5em", + }, +})); + const RoomPagination = props => ( ); @@ -109,6 +119,7 @@ const RoomShowActions = ({ basePath, data, resource }) => { }; export const RoomShow = props => { + const classes = useStyles({ props }); const translate = useTranslate(); return ( } title={}> @@ -220,6 +231,7 @@ export const RoomShow = props => { ]} /> + } @@ -256,6 +268,40 @@ export const RoomShow = props => { + + } + path="forward_extremities" + > +
+ {translate("resources.rooms.helper.forward_extremities")} +
+ + + + + + + + +
); diff --git a/src/i18n/de.js b/src/i18n/de.js index d4b0982..e7de884 100644 --- a/src/i18n/de.js +++ b/src/i18n/de.js @@ -152,6 +152,10 @@ const de = { topic: "Thema", avatar: "Avatar", }, + helper: { + forward_extremities: + "Forward extremities are the leaf events at the end of a Directed acyclic graph (DAG) in a room, aka events that have no children. The more exist in a room, the more state resolution that Synapse needs to perform (hint: it's an expensive operation). While Synapse has code to prevent too many of these existing at one time in a room, bugs can sometimes make them crop up again. If a room has >10 forward extremities, it's worth checking which room is the culprit and potentially removing them using the SQL queries mentioned in #1760.", + }, enums: { join_rules: { public: "Öffentlich", @@ -295,6 +299,15 @@ const de = { media_length: "Größe der Dateien", }, }, + forward_extremities: { + name: "Vorderextremitäten", + fields: { + id: "Event-ID", + received_ts: "Zeitstempel", + depth: "Tiefe", + state_group: "Zustandsgruppe", + }, + }, room_state: { name: "Zustandsereignisse", fields: { diff --git a/src/i18n/en.js b/src/i18n/en.js index 4e8d825..6ea011a 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -150,6 +150,10 @@ const en = { topic: "Topic", avatar: "Avatar", }, + helper: { + forward_extremities: + "Forward extremities are the leaf events at the end of a Directed acyclic graph (DAG) in a room, aka events that have no children. The more exist in a room, the more state resolution that Synapse needs to perform (hint: it's an expensive operation). While Synapse has code to prevent too many of these existing at one time in a room, bugs can sometimes make them crop up again. If a room has >10 forward extremities, it's worth checking which room is the culprit and potentially removing them using the SQL queries mentioned in #1760.", + }, enums: { join_rules: { public: "Public", @@ -291,6 +295,15 @@ const en = { media_length: "Media length", }, }, + forward_extremities: { + name: "Forward Extremities", + fields: { + id: "Event ID", + received_ts: "Timestamp", + depth: "Depth", + state_group: "State group", + }, + }, room_state: { name: "State events", fields: { diff --git a/src/synapse/dataProvider.js b/src/synapse/dataProvider.js index c9e63fa..bbe06cc 100644 --- a/src/synapse/dataProvider.js +++ b/src/synapse/dataProvider.js @@ -208,6 +208,22 @@ const resourceMap = { return json.total; }, }, + forward_extremities: { + map: fe => ({ + ...fe, + id: fe.event_id, + }), + reference: id => ({ + endpoint: `/_synapse/admin/v1/rooms/${id}/forward_extremities`, + }), + data: "results", + total: json => { + return json.count; + }, + delete: params => ({ + endpoint: `/_synapse/admin/v1/rooms/${params.id}/forward_extremities`, + }), + }, room_directory: { path: "/_matrix/client/r0/publicRooms", map: rd => ({