Add page to show room details

Change-Id: Iec4f402c4322d775cc14c567069a3295ad383b44
This commit is contained in:
Manuel Stahl 2020-04-21 14:51:40 +02:00
parent 662735a91f
commit 375649756f
5 changed files with 43 additions and 4 deletions

View File

@ -4,7 +4,7 @@ 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 { UserList, UserCreate, UserEdit } from "./components/users";
import { RoomList, RoomCreate } from "./components/rooms"; import { RoomList, RoomCreate, RoomShow } from "./components/rooms";
import LoginPage from "./components/LoginPage"; import LoginPage from "./components/LoginPage";
import UserIcon from "@material-ui/icons/Group"; import UserIcon from "@material-ui/icons/Group";
import { ViewListIcon as RoomIcon } from "@material-ui/icons/ViewList"; import { ViewListIcon as RoomIcon } from "@material-ui/icons/ViewList";
@ -44,6 +44,7 @@ const App = () => (
name="rooms" name="rooms"
list={RoomList} list={RoomList}
create={RoomCreate} create={RoomCreate}
show={RoomShow}
icon={RoomIcon} icon={RoomIcon}
/> />
<Resource name="connections" /> <Resource name="connections" />

View File

@ -1,14 +1,22 @@
import React from "react"; import React from "react";
import { import {
BooleanField,
BooleanInput, BooleanInput,
Create, Create,
Datagrid, Datagrid,
List, List,
Pagination, Pagination,
ReferenceArrayField,
Show,
SimpleForm, SimpleForm,
Tab,
TabbedShowLayout,
TextField, TextField,
TextInput, TextInput,
useTranslate,
} from "react-admin"; } from "react-admin";
import ViewListIcon from "@material-ui/icons/ViewList";
import UserIcon from "@material-ui/icons/Group";
const RoomPagination = props => ( const RoomPagination = props => (
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} /> <Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
@ -16,7 +24,7 @@ const RoomPagination = props => (
export const RoomList = props => ( export const RoomList = props => (
<List {...props} pagination={<RoomPagination />}> <List {...props} pagination={<RoomPagination />}>
<Datagrid> <Datagrid rowClick="show">
<TextField source="room_id" /> <TextField source="room_id" />
<TextField source="name" /> <TextField source="name" />
<TextField source="canonical_alias" /> <TextField source="canonical_alias" />
@ -108,3 +116,33 @@ export const RoomCreate = props => (
</SimpleForm> </SimpleForm>
</Create> </Create>
); );
const RoomTitle = ({ record }) => {
const translate = useTranslate();
return (
<span>
{translate("resources.rooms.name", 1)} {record ? `"${record.name}"` : ""}
</span>
);
};
export const RoomShow = props => (
<Show {...props} title={<RoomTitle />}>
<TabbedShowLayout>
<Tab label="synapseadmin.rooms.details" icon={<ViewListIcon />}>
<TextField source="id" disabled />
<TextField source="name" />
<TextField source="canonical_alias" />
<TextField source="join_rules" />
<TextField source="guest_access" />
</Tab>
<Tab label="resources.rooms.fields.joined_members" icon={<UserIcon />}>
<ReferenceArrayField reference="users" source="members">
<Datagrid>
<TextField source="id" />
<TextField source="displayname" />
</Datagrid>
</ReferenceArrayField>
</Tab>
</TabbedShowLayout>
</Show>
);

View File

@ -17,6 +17,7 @@ export default {
"Muss eine vollständige Matrix Benutzer-ID sein, z.B. @benutzer_id:homeserver", "Muss eine vollständige Matrix Benutzer-ID sein, z.B. @benutzer_id:homeserver",
}, },
rooms: { rooms: {
details: "Raumdetails",
room_name: "Raumname", room_name: "Raumname",
make_public: "Öffentlicher Raum", make_public: "Öffentlicher Raum",
room_name_required: "Muss angegeben werden", room_name_required: "Muss angegeben werden",

View File

@ -17,6 +17,7 @@ export default {
"Must be a fully qualified Matrix user-id, e.g. @user_id:homeserver", "Must be a fully qualified Matrix user-id, e.g. @user_id:homeserver",
}, },
rooms: { rooms: {
details: "Room Details",
room_name: "Room Name", room_name: "Room Name",
make_public: "Make room public", make_public: "Make room public",
room_name_required: "Must be provided", room_name_required: "Must be provided",

View File

@ -37,8 +37,6 @@ const resourceMap = {
map: r => ({ map: r => ({
...r, ...r,
id: r.room_id, id: r.room_id,
alias: r.canonical_alias,
members: r.joined_members,
}), }),
data: "rooms", data: "rooms",
total: json => json.total_rooms, total: json => json.total_rooms,