mirror of
https://github.com/UA-Fediland/synapse-admin.git
synced 2024-11-09 16:24:51 +00:00
Add a user view
Change-Id: I29971f1eef2405cdaa786d4cad381e47d4a5c24c
This commit is contained in:
parent
a151a18b6e
commit
26cfa80bde
4 changed files with 143 additions and 1 deletions
10
src/App.js
10
src/App.js
|
@ -3,7 +3,9 @@ import { Admin, Resource, resolveBrowserLocale } from "react-admin";
|
||||||
import polyglotI18nProvider from "ra-i18n-polyglot";
|
import polyglotI18nProvider from "ra-i18n-polyglot";
|
||||||
import authProvider from "./synapse/authProvider";
|
import authProvider from "./synapse/authProvider";
|
||||||
import dataProvider from "./synapse/dataProvider";
|
import dataProvider from "./synapse/dataProvider";
|
||||||
|
import { UserList, UserCreate, UserEdit } from "./components/users";
|
||||||
import LoginPage from "./components/LoginPage";
|
import LoginPage from "./components/LoginPage";
|
||||||
|
import UserIcon from "@material-ui/icons/Group";
|
||||||
import germanMessages from "./i18n/de";
|
import germanMessages from "./i18n/de";
|
||||||
import englishMessages from "./i18n/en";
|
import englishMessages from "./i18n/en";
|
||||||
|
|
||||||
|
@ -24,7 +26,13 @@ const App = () => (
|
||||||
dataProvider={dataProvider}
|
dataProvider={dataProvider}
|
||||||
i18nProvider={i18nProvider}
|
i18nProvider={i18nProvider}
|
||||||
>
|
>
|
||||||
<Resource name="users" />
|
<Resource
|
||||||
|
name="users"
|
||||||
|
list={UserList}
|
||||||
|
create={UserCreate}
|
||||||
|
edit={UserEdit}
|
||||||
|
icon={UserIcon}
|
||||||
|
/>
|
||||||
</Admin>
|
</Admin>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
90
src/components/users.js
Normal file
90
src/components/users.js
Normal file
|
@ -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 => (
|
||||||
|
<Filter {...props}>
|
||||||
|
<BooleanInput source="guests" alwaysOn />
|
||||||
|
<BooleanInput
|
||||||
|
label="resources.users.fields.show_deactivated"
|
||||||
|
source="deactivated"
|
||||||
|
alwaysOn
|
||||||
|
/>
|
||||||
|
</Filter>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const UserList = props => (
|
||||||
|
<List
|
||||||
|
{...props}
|
||||||
|
filters={<UserFilter />}
|
||||||
|
filterDefaultValues={{ guests: true, deactivated: false }}
|
||||||
|
bulkActionButtons={false}
|
||||||
|
>
|
||||||
|
<Datagrid rowClick="edit">
|
||||||
|
<ReferenceField
|
||||||
|
source="Avatar"
|
||||||
|
reference="users"
|
||||||
|
link={false}
|
||||||
|
sortable={false}
|
||||||
|
>
|
||||||
|
<ImageField source="avatar_url" title="displayname" />
|
||||||
|
</ReferenceField>
|
||||||
|
<TextField source="id" />
|
||||||
|
{/* Hack since the users endpoint does not give displaynames in the list*/}
|
||||||
|
<ReferenceField
|
||||||
|
source="name"
|
||||||
|
reference="users"
|
||||||
|
link={false}
|
||||||
|
sortable={false}
|
||||||
|
>
|
||||||
|
<TextField source="displayname" />
|
||||||
|
</ReferenceField>
|
||||||
|
<BooleanField source="is_guest" sortable={false} />
|
||||||
|
<BooleanField source="admin" sortable={false} />
|
||||||
|
<BooleanField source="deactivated" sortable={false} />
|
||||||
|
</Datagrid>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
|
|
||||||
|
// https://matrix.org/docs/spec/appendices#user-identifiers
|
||||||
|
const validateUser = regex(
|
||||||
|
/^@[a-z0-9._=\-/]+:.*/,
|
||||||
|
"synapseadmin.users.invalid_user_id"
|
||||||
|
);
|
||||||
|
|
||||||
|
export const UserCreate = props => (
|
||||||
|
<Create {...props}>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput source="id" autoComplete="off" validate={validateUser} />
|
||||||
|
<TextInput source="displayname" />
|
||||||
|
<PasswordInput source="password" autoComplete="new-password" />
|
||||||
|
<BooleanInput source="admin" />
|
||||||
|
</SimpleForm>
|
||||||
|
</Create>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const UserEdit = props => (
|
||||||
|
<Edit {...props}>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput source="id" disabled />
|
||||||
|
<TextInput source="displayname" />
|
||||||
|
<PasswordInput source="password" autoComplete="new-password" />
|
||||||
|
<BooleanInput source="admin" />
|
||||||
|
<BooleanInput source="deactivated" />
|
||||||
|
</SimpleForm>
|
||||||
|
</Edit>
|
||||||
|
);
|
|
@ -7,5 +7,27 @@ export default {
|
||||||
homeserver: "Heimserver",
|
homeserver: "Heimserver",
|
||||||
welcome: "Willkommen bei Synapse-admin",
|
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",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,5 +7,27 @@ export default {
|
||||||
homeserver: "Homeserver",
|
homeserver: "Homeserver",
|
||||||
welcome: "Welcome to Synapse-admin",
|
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",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue