From 26cfa80bde430464e0415ef9467734c5479db41f Mon Sep 17 00:00:00 2001 From: Manuel Stahl Date: Fri, 7 Feb 2020 17:44:48 +0100 Subject: [PATCH] Add a user view Change-Id: I29971f1eef2405cdaa786d4cad381e47d4a5c24c --- src/App.js | 10 ++++- src/components/users.js | 90 +++++++++++++++++++++++++++++++++++++++++ src/i18n/de.js | 22 ++++++++++ src/i18n/en.js | 22 ++++++++++ 4 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 src/components/users.js diff --git a/src/App.js b/src/App.js index 68b8f2d..70b7f7b 100644 --- a/src/App.js +++ b/src/App.js @@ -3,7 +3,9 @@ import { Admin, Resource, resolveBrowserLocale } from "react-admin"; import polyglotI18nProvider from "ra-i18n-polyglot"; import authProvider from "./synapse/authProvider"; import dataProvider from "./synapse/dataProvider"; +import { UserList, UserCreate, UserEdit } from "./components/users"; import LoginPage from "./components/LoginPage"; +import UserIcon from "@material-ui/icons/Group"; import germanMessages from "./i18n/de"; import englishMessages from "./i18n/en"; @@ -24,7 +26,13 @@ const App = () => ( dataProvider={dataProvider} i18nProvider={i18nProvider} > - + ); diff --git a/src/components/users.js b/src/components/users.js new file mode 100644 index 0000000..068b59e --- /dev/null +++ b/src/components/users.js @@ -0,0 +1,90 @@ +import React from "react"; +import { + Datagrid, + Create, + Edit, + List, + Filter, + SimpleForm, + BooleanField, + BooleanInput, + ImageField, + PasswordInput, + TextField, + TextInput, + ReferenceField, + regex, +} from "react-admin"; + +const UserFilter = props => ( + + + + +); + +export const UserList = props => ( + } + filterDefaultValues={{ guests: true, deactivated: false }} + bulkActionButtons={false} + > + + + + + + {/* Hack since the users endpoint does not give displaynames in the list*/} + + + + + + + + +); + +// https://matrix.org/docs/spec/appendices#user-identifiers +const validateUser = regex( + /^@[a-z0-9._=\-/]+:.*/, + "synapseadmin.users.invalid_user_id" +); + +export const UserCreate = props => ( + + + + + + + + +); + +export const UserEdit = props => ( + + + + + + + + + +); diff --git a/src/i18n/de.js b/src/i18n/de.js index 7ba3c22..6536802 100644 --- a/src/i18n/de.js +++ b/src/i18n/de.js @@ -7,5 +7,27 @@ export default { homeserver: "Heimserver", welcome: "Willkommen bei Synapse-admin", }, + users: { + invalid_user_id: + "Muss eine vollständige Matrix Benutzer-ID sein, z.B. @benutzer_id:homeserver", + }, + }, + resources: { + users: { + name: "Benutzer", + fields: { + avatar: "Avatar", + id: "Benutzer-ID", + name: "Name", + is_guest: "Gast", + admin: "Admin", + deactivated: "Deaktiviert", + guests: "Zeige Gäste", + show_deactivated: "Zeige deaktivierte Benutzer", + user_id: "Suche Benutzer", + displayname: "Anzeigename", + password: "Passwort", + }, + }, }, }; diff --git a/src/i18n/en.js b/src/i18n/en.js index 187af84..16adfd7 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -7,5 +7,27 @@ export default { homeserver: "Homeserver", welcome: "Welcome to Synapse-admin", }, + users: { + invalid_user_id: + "Must be a fully qualified Matrix user-id, e.g. @user_id:homeserver", + }, + }, + resources: { + users: { + name: "User |||| Users", + fields: { + avatar: "Avatar", + id: "User-ID", + name: "Name", + is_guest: "Guest", + admin: "Admin", + deactivated: "Deactivated", + guests: "Show guests", + show_deactivated: "Show deactivated users", + user_id: "Search user", + displayname: "Displayname", + password: "Password", + }, + }, }, };