Offer room creation form
A choice of public or private is offered, which maps to matrix' visibility parameter. A name can also be provided. Change-Id: I34d99acbc4624a9ed54ca6f6609573d5fc1049da
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
import React from "react";
|
||||
import { Datagrid, List, TextField, Pagination } from "react-admin";
|
||||
import {
|
||||
BooleanInput,
|
||||
Create,
|
||||
Datagrid,
|
||||
List,
|
||||
Pagination,
|
||||
SimpleForm,
|
||||
TextField,
|
||||
TextInput,
|
||||
} from "react-admin";
|
||||
|
||||
const RoomPagination = props => (
|
||||
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||
@@ -15,3 +24,27 @@ export const RoomList = props => (
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
|
||||
function generateRoomRecord() {
|
||||
return {
|
||||
room_name: "",
|
||||
public: true,
|
||||
}
|
||||
}
|
||||
|
||||
const validateDisplayName = fieldval => fieldval === undefined ? "synapseadmin.rooms.room_name_required" : fieldval.length === 0 ? "synapseadmin.rooms.room_name_required" : undefined;
|
||||
|
||||
const removeLeadingWhitespace = fieldVal => fieldVal === undefined ? undefined : fieldVal.trimStart();
|
||||
|
||||
export const RoomCreate = props => (
|
||||
<Create record={generateRoomRecord()} {...props}>
|
||||
<SimpleForm>
|
||||
<TextInput source="room_name"
|
||||
label="synapseadmin.rooms.room_name"
|
||||
parse={removeLeadingWhitespace}
|
||||
validate={validateDisplayName}/>
|
||||
<BooleanInput source="public"
|
||||
label="synapseadmin.rooms.make_public"/>
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user