15 Commits
0.8.0 ... 0.8.1

Author SHA1 Message Date
Michael Albert
985673b161 Increment version
Change-Id: I149896f55be7840b240d92fed5880e3f5624b857
2021-05-25 15:03:15 +02:00
John Francis Sukamto
d72357f64f Update en.js (#144)
Suggested a UI name change for media size (assuming length is size in bytes)
2021-05-25 15:01:13 +02:00
Dirk Klimpel
e19c34324b Allow fixed homeserver (#142) 2021-05-18 12:39:53 +02:00
Dirk Klimpel
3ea1f51eb5 Add a new tab to rooms with forward extremities (#107)
Add a new tab to rooms with forward extremities.
2021-05-08 19:10:51 +02:00
Manuel Stahl
229518e456 Show room alias or room id in room list if room has no name
Change-Id: Iad769f31347566ccf0b8a978b31f5123553e9dbc
2021-05-05 20:24:15 +02:00
Dirk Klimpel
5a5a7143af Enable sorting of user list (#133)
New in Synapse 1.32.0
Fixes: #132, #136
2021-05-05 19:36:47 +02:00
Manuel Stahl
dda8ba5e85 Update nodejs version for travis
Change-Id: I7d44f5df7d4479efcb1d44f5ba23467effad147e
2021-05-05 19:31:50 +02:00
Manuel Stahl
5208198b76 Replace enzyme with testing-library/react
Enzyme is not compatible with react 17.

Change-Id: If9bca2c482bfe10a18d2ee2bc213dab966849b5b
2021-05-05 19:23:01 +02:00
Manuel Stahl
c8082a7198 Remove TestContext from App.test.js
The TestContext is only required for components that depend on react-admin,
but not for the Admin component itself.

Change-Id: I3e07cb6bfa592f1bf59ca282cdf1c2e6c922f619
2021-05-05 19:23:01 +02:00
Michael Albert
10831796e3 Add missing translation
Change-Id: Iab3203742498d2c6768b5885c0522ff8365b58f2
2021-05-05 09:41:05 +00:00
Michael Albert
5ee5288edf Fix some DOM errors
Change-Id: I22a108fd5ce6a344e629e4af0345a0221de44052
2021-05-05 09:40:48 +00:00
Manuel Stahl
a5528d9fe7 yarn: Upgrade packages
- eslint 7.25
- ra-language-german 3.13
- react-admin 3.15
- react-dom 17.0
- react-scripts 4.0

Change-Id: Iad982cf647470bc16194000519a72c401009c9fa
2021-05-04 18:42:05 +02:00
Manuel Stahl
e2fd934851 Allow base URL with path
Ignore and remove trailing slashes.
Fixes #134.

Change-Id: Iedf266e9a93e6939f7f66707fee59a2b56226216
2021-05-04 18:41:54 +02:00
Manuel Stahl
0bc1ce3226 Reuse device_id for synapse-admin on login
Change-Id: I47bbfd1e33ef8bffb618101ae233aeb093cf0ada
2021-05-04 17:10:49 +02:00
Manuel Stahl
41ce58bac8 Enable sorting in tab of users' media (#138) 2021-05-04 16:18:12 +02:00
18 changed files with 3331 additions and 2932 deletions

5
.env Normal file
View File

@@ -0,0 +1,5 @@
# This setting allows to fix the homeserver.
# If you set this setting, the user will not be able to select
# the server and have to use synapse-admin with this server.
#REACT_APP_SERVER=https://yourmatrixserver.example.com

View File

@@ -1,5 +1,5 @@
language: node_js
node_js:
- 13
- lts/*
cache: yarn

View File

@@ -4,7 +4,7 @@
This project is built using [react-admin](https://marmelab.com/react-admin/).
It needs at least Synapse v1.27.0 for all functions to work as expected!
It needs at least Synapse v1.32.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).
@@ -33,6 +33,11 @@ Steps for 1):
- download dependencies: `yarn install`
- start web server: `yarn start`
You can fix the homeserver, so that the user can no longer define it himself.
Either you define it at startup (e.g. `REACT_APP_SERVER=https://yourmatrixserver.example.com yarn start`)
or by editing it in the [.env](.env) file. See also the
[documentation](https://create-react-app.dev/docs/adding-custom-environment-variables/).
Steps for 2):
- run the Docker container from the public docker registry: `docker run -p 8080:80 awesometechnologies/synapse-admin` or use the (docker-compose.yml)[docker-compose.yml]: `docker-compose up -d`

View File

@@ -1,6 +1,6 @@
{
"name": "synapse-admin",
"version": "0.8.0",
"version": "0.8.1",
"description": "Admin GUI for the Matrix.org server Synapse",
"author": "Awesome Technologies Innovationslabor GmbH",
"license": "Apache-2.0",
@@ -11,26 +11,24 @@
},
"devDependencies": {
"@testing-library/jest-dom": "^5.1.1",
"@testing-library/react": "^10.0.2",
"@testing-library/user-event": "^12.0.11",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^13.1.8",
"eslint": "^7.25.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.1.2",
"jest-fetch-mock": "^3.0.3",
"prettier": "^2.0.0",
"ra-test": "^3.14.0"
"prettier": "^2.2.0",
"ra-test": "^3.15.0"
},
"dependencies": {
"papaparse": "^5.2.0",
"prop-types": "^15.7.2",
"ra-language-chinese": "^2.0.10",
"ra-language-german": "^2.1.2",
"ra-language-german": "^3.13.4",
"react": "^17.0.0",
"react-admin": "^3.14.0",
"react-dom": "^16.14.0",
"react-scripts": "^3.4.4"
"react-admin": "^3.15.0",
"react-dom": "^17.0.2",
"react-scripts": "^4.0.0"
},
"scripts": {
"start": "REACT_APP_VERSION=$(git describe --tags) react-scripts start",

View File

@@ -73,6 +73,7 @@ const App = () => (
<Resource name="joined_rooms" />
<Resource name="pushers" />
<Resource name="servernotices" />
<Resource name="forward_extremities" />
<Resource name="room_state" />
</Admin>
);

View File

@@ -1,14 +1,9 @@
import React from "react";
import { TestContext } from "ra-test";
import { shallow } from "enzyme";
import { render } from "@testing-library/react";
import App from "./App";
describe("App", () => {
it("renders", () => {
shallow(
<TestContext>
<App />
</TestContext>
);
render(<App />);
});
});

View File

@@ -82,6 +82,7 @@ const LoginPage = ({ theme }) => {
const setLocale = useSetLocale();
const translate = useTranslate();
const base_url = localStorage.getItem("base_url");
const cfg_base_url = process.env.REACT_APP_SERVER;
const renderInput = ({
meta: { touched, error } = {},
@@ -111,7 +112,9 @@ const LoginPage = ({ theme }) => {
if (!values.base_url.match(/^(http|https):\/\//)) {
errors.base_url = translate("synapseadmin.auth.protocol_error");
} else if (
!values.base_url.match(/^(http|https):\/\/[a-zA-Z0-9\-.]+(:\d{1,5})?$/)
!values.base_url.match(
/^(http|https):\/\/[a-zA-Z0-9\-.]+(:\d{1,5})?[^?&\s]*$/
)
) {
errors.base_url = translate("synapseadmin.auth.url_error");
}
@@ -147,7 +150,7 @@ const LoginPage = ({ theme }) => {
const [serverVersion, setServerVersion] = useState("");
const handleUsernameChange = _ => {
if (formData.base_url) return;
if (formData.base_url || cfg_base_url) return;
// check if username is a full qualified userId then set base_url accordially
const home_server = extractHomeServer(formData.username);
const wellKnownUrl = `https://${home_server}/.well-known/matrix/client`;
@@ -199,6 +202,7 @@ const LoginPage = ({ theme }) => {
label={translate("ra.auth.username")}
disabled={loading}
onBlur={handleUsernameChange}
resettable
fullWidth
/>
</div>
@@ -209,6 +213,7 @@ const LoginPage = ({ theme }) => {
label={translate("ra.auth.password")}
type="password"
disabled={loading}
resettable
fullWidth
/>
</div>
@@ -217,7 +222,8 @@ const LoginPage = ({ theme }) => {
name="base_url"
component={renderInput}
label={translate("synapseadmin.auth.base_url")}
disabled={loading}
disabled={cfg_base_url || loading}
resettable
fullWidth
/>
</div>
@@ -228,7 +234,7 @@ const LoginPage = ({ theme }) => {
return (
<Form
initialValues={{ base_url: base_url }}
initialValues={{ base_url: cfg_base_url || base_url }}
onSubmit={handleSubmit}
validate={validate}
render={({ handleSubmit }) => (

View File

@@ -1,11 +1,11 @@
import React from "react";
import { render } from "@testing-library/react";
import { TestContext } from "ra-test";
import { shallow } from "enzyme";
import LoginPage from "./LoginPage";
describe("LoginForm", () => {
it("renders", () => {
shallow(
render(
<TestContext>
<LoginPage />
</TestContext>

View File

@@ -171,7 +171,7 @@ const RoomDirectoryFilter = ({ ...props }) => {
);
};
export const FilterableRoomDirectoryList = ({ ...props }) => {
export const FilterableRoomDirectoryList = ({ dispatch, ...props }) => {
const classes = useStyles();
const translate = useTranslate();
const filter = props.roomDirectoryFilters;
@@ -242,7 +242,7 @@ export const FilterableRoomDirectoryList = ({ ...props }) => {
function mapStateToProps(state) {
return {
roomDirectoryFilters:
roomdirectoryfilters:
state.admin.resources.room_directory.list.params.displayedFilters,
};
}

View File

@@ -8,6 +8,7 @@ import {
DeleteButton,
Filter,
List,
NumberField,
Pagination,
ReferenceField,
ReferenceManyField,
@@ -18,10 +19,14 @@ import {
TabbedShowLayout,
TextField,
TopToolbar,
useRecordContext,
useTranslate,
} 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";
@@ -36,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 => (
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
);
@@ -107,6 +119,7 @@ const RoomShowActions = ({ basePath, data, resource }) => {
};
export const RoomShow = props => {
const classes = useStyles({ props });
const translate = useTranslate();
return (
<Show {...props} actions={<RoomShowActions />} title={<RoomTitle />}>
@@ -218,6 +231,7 @@ export const RoomShow = props => {
]}
/>
</Tab>
<Tab
label={translate("resources.room_state.name", { smart_count: 2 })}
icon={<EventIcon />}
@@ -254,6 +268,40 @@ export const RoomShow = props => {
</Datagrid>
</ReferenceManyField>
</Tab>
<Tab
label="resources.forward_extremities.name"
icon={<FastForwardIcon />}
path="forward_extremities"
>
<div className={classes.helper_forward_extremities}>
{translate("resources.rooms.helper.forward_extremities")}
</div>
<ReferenceManyField
reference="forward_extremities"
target="room_id"
addLabel={false}
>
<Datagrid style={{ width: "100%" }}>
<TextField source="id" sortable={false} />
<DateField
source="received_ts"
showTime
options={{
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
}}
sortable={false}
/>
<NumberField source="depth" sortable={false} />
<TextField source="state_group" sortable={false} />
</Datagrid>
</ReferenceManyField>
</Tab>
</TabbedShowLayout>
</Show>
);
@@ -305,8 +353,22 @@ const RoomFilter = ({ ...props }) => {
);
};
const FilterableRoomList = ({ ...props }) => {
const filter = props.roomFilters;
const RoomNameField = props => {
const { source } = props;
const record = useRecordContext(props);
return (
<span>{record[source] || record["canonical_alias"] || record["id"]}</span>
);
};
RoomNameField.propTypes = {
label: PropTypes.string,
record: PropTypes.object,
source: PropTypes.string.isRequired,
};
const FilterableRoomList = ({ roomFilters, dispatch, ...props }) => {
const filter = roomFilters;
const localMembersFilter =
filter && filter.joined_local_members ? true : false;
const stateEventsFilter = filter && filter.state_events ? true : false;
@@ -327,7 +389,7 @@ const FilterableRoomList = ({ ...props }) => {
sortBy="encryption"
label={<HttpsIcon />}
/>
<TextField source="name" />
<RoomNameField source="name" />
<TextField source="joined_members" />
{localMembersFilter && <TextField source="joined_local_members" />}
{stateEventsFilter && <TextField source="state_events" />}

View File

@@ -162,6 +162,7 @@ export const UserList = props => {
{...props}
filters={<UserFilter />}
filterDefaultValues={{ guests: true, deactivated: false }}
sort={{ field: "name", order: "ASC" }}
actions={<UserListActions maxResults={10000} />}
bulkActionButtons={<UserBulkActionButtons />}
pagination={<UserPagination />}
@@ -169,14 +170,14 @@ export const UserList = props => {
<Datagrid rowClick="edit">
<AvatarField
source="avatar_src"
sortable={false}
className={classes.small}
sortBy="avatar_url"
/>
<TextField source="id" sortable={false} />
<TextField source="displayname" sortable={false} />
<BooleanField source="is_guest" sortable={false} />
<BooleanField source="admin" sortable={false} />
<BooleanField source="deactivated" sortable={false} />
<TextField source="id" sortBy="name" />
<TextField source="displayname" />
<BooleanField source="is_guest" />
<BooleanField source="admin" />
<BooleanField source="deactivated" />
</Datagrid>
</List>
);
@@ -420,6 +421,7 @@ export const UserEdit = props => {
addLabel={false}
pagination={<UserPagination />}
perPage={50}
sort={{ field: "created_ts", order: "DESC" }}
>
<Datagrid style={{ width: "100%" }}>
<DateField
@@ -433,7 +435,6 @@ export const UserEdit = props => {
minute: "2-digit",
second: "2-digit",
}}
sortable={false}
/>
<DateField
source="last_access_ts"
@@ -446,14 +447,13 @@ export const UserEdit = props => {
minute: "2-digit",
second: "2-digit",
}}
sortable={false}
/>
<TextField source="media_id" sortable={false} />
<NumberField source="media_length" sortable={false} />
<TextField source="media_type" sortable={false} />
<TextField source="upload_name" sortable={false} />
<TextField source="quarantined_by" sortable={false} />
<BooleanField source="safe_from_quarantine" sortable={false} />
<TextField source="media_id" />
<NumberField source="media_length" />
<TextField source="media_type" />
<TextField source="upload_name" />
<TextField source="quarantined_by" />
<BooleanField source="safe_from_quarantine" />
<DeleteButton mutationMode="pessimistic" redirect={false} />
</Datagrid>
</ReferenceManyField>

View File

@@ -1,6 +1,6 @@
import germanMessages from "ra-language-german";
export default {
const de = {
...germanMessages,
synapseadmin: {
auth: {
@@ -152,6 +152,10 @@ export default {
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 @@ export default {
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: {
@@ -349,5 +362,10 @@ export default {
empty: "Keine Einträge vorhanden",
invite: "",
},
navigation: {
...germanMessages.ra.navigation,
skip_nav: "Zum Inhalt springen",
},
},
};
export default de;

View File

@@ -1,6 +1,6 @@
import englishMessages from "ra-language-english";
export default {
const en = {
...englishMessages,
synapseadmin: {
auth: {
@@ -150,6 +150,10 @@ export default {
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",
@@ -228,7 +232,7 @@ export default {
name: "Media",
fields: {
media_id: "Media ID",
media_length: "Lenght",
media_length: "File Size (in Bytes)",
media_type: "Type",
upload_name: "File name",
quarantined_by: "Quarantined by",
@@ -291,6 +295,15 @@ export default {
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: {
@@ -319,3 +332,4 @@ export default {
},
},
};
export default en;

View File

@@ -1,6 +1,6 @@
import chineseMessages from "ra-language-chinese";
export default {
const zh = {
...chineseMessages,
synapseadmin: {
auth: {
@@ -288,3 +288,4 @@ export default {
},
},
};
export default zh;

View File

@@ -1,6 +1,3 @@
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import fetchMock from "jest-fetch-mock";
configure({ adapter: new Adapter() });
fetchMock.enableMocks();

View File

@@ -3,6 +3,9 @@ import { fetchUtils } from "react-admin";
const authProvider = {
// called when the user attempts to log in
login: ({ base_url, username, password }) => {
// force homeserver for protection in case the form is manipulated
base_url = process.env.REACT_APP_SERVER || base_url;
console.log("login ");
const options = {
method: "POST",
@@ -10,6 +13,7 @@ const authProvider = {
type: "m.login.password",
user: username,
password: password,
device_id: localStorage.getItem("device_id"),
initial_device_display_name: "Synapse Admin",
}),
};
@@ -17,6 +21,7 @@ const authProvider = {
// use the base_url from login instead of the well_known entry from the
// server, since the admin might want to access the admin API via some
// private address
base_url = base_url.replace(/\/+$/g, "");
localStorage.setItem("base_url", base_url);
const decoded_base_url = window.decodeURIComponent(base_url);
@@ -48,7 +53,6 @@ const authProvider = {
if (typeof access_token === "string") {
fetchUtils.fetchJson(logout_api_url, options).then(({ json }) => {
localStorage.removeItem("access_token");
localStorage.removeItem("device_id");
});
}
return Promise.resolve();

View File

@@ -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 => ({
@@ -314,10 +330,13 @@ const dataProvider = {
getManyReference: (resource, params) => {
console.log("getManyReference " + resource);
const { page, perPage } = params.pagination;
const { field, order } = params.sort;
const from = (page - 1) * perPage;
const query = {
from: from,
limit: perPage,
order_by: field,
dir: getSearchOrder(order),
};
const homeserver = localStorage.getItem("base_url");

6028
yarn.lock

File diff suppressed because it is too large Load Diff