Offer invitations in room creation
Turns the "Create Room" form into a tabbed form with tabs that mimic the room display. In the "Members" tab an AutocompleteArrayInput allows selecting multiple users by their displayname. The displayname is also what is displayed ìn the invitations list. Creating the room immediately sends out the invitations as well. Change-Id: I3915144114ffe4c629848363c9cb7917634d04d8
This commit is contained in:
parent
76fdc80e3e
commit
880223e5de
@ -1,15 +1,17 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import {
|
import {
|
||||||
BooleanField,
|
AutocompleteArrayInput,
|
||||||
BooleanInput,
|
BooleanInput,
|
||||||
Create,
|
Create,
|
||||||
Datagrid,
|
Datagrid,
|
||||||
|
FormTab,
|
||||||
List,
|
List,
|
||||||
Pagination,
|
Pagination,
|
||||||
ReferenceArrayField,
|
ReferenceArrayField,
|
||||||
|
ReferenceArrayInput,
|
||||||
Show,
|
Show,
|
||||||
SimpleForm,
|
|
||||||
Tab,
|
Tab,
|
||||||
|
TabbedForm,
|
||||||
TabbedShowLayout,
|
TabbedShowLayout,
|
||||||
TextField,
|
TextField,
|
||||||
TextInput,
|
TextInput,
|
||||||
@ -100,7 +102,8 @@ const validateHasAliasIfPublic = formdata => {
|
|||||||
|
|
||||||
export const RoomCreate = props => (
|
export const RoomCreate = props => (
|
||||||
<Create {...props}>
|
<Create {...props}>
|
||||||
<SimpleForm validate={validateHasAliasIfPublic}>
|
<TabbedForm validate={validateHasAliasIfPublic}>
|
||||||
|
<FormTab label="synapseadmin.rooms.details" icon={<ViewListIcon />}>
|
||||||
<TextInput
|
<TextInput
|
||||||
source="name"
|
source="name"
|
||||||
parse={removeLeadingWhitespace}
|
parse={removeLeadingWhitespace}
|
||||||
@ -113,7 +116,23 @@ export const RoomCreate = props => (
|
|||||||
placeholder="#"
|
placeholder="#"
|
||||||
/>
|
/>
|
||||||
<BooleanInput source="public" label="synapseadmin.rooms.make_public" />
|
<BooleanInput source="public" label="synapseadmin.rooms.make_public" />
|
||||||
</SimpleForm>
|
</FormTab>
|
||||||
|
<FormTab
|
||||||
|
label="resources.rooms.fields.invite_members"
|
||||||
|
icon={<UserIcon />}
|
||||||
|
>
|
||||||
|
<ReferenceArrayInput
|
||||||
|
reference="users"
|
||||||
|
source="invitees"
|
||||||
|
filterToQuery={searchText => ({ user_id: searchText })}
|
||||||
|
>
|
||||||
|
<AutocompleteArrayInput
|
||||||
|
optionText="displayname"
|
||||||
|
suggestionText="displayname"
|
||||||
|
/>
|
||||||
|
</ReferenceArrayInput>
|
||||||
|
</FormTab>
|
||||||
|
</TabbedForm>
|
||||||
</Create>
|
</Create>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -65,6 +65,8 @@ export default {
|
|||||||
name: "Name",
|
name: "Name",
|
||||||
canonical_alias: "Alias",
|
canonical_alias: "Alias",
|
||||||
joined_members: "Mitglieder",
|
joined_members: "Mitglieder",
|
||||||
|
invite_members: "Mitglieder einladen",
|
||||||
|
invitees: "Einladungen",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
connections: {
|
connections: {
|
||||||
|
@ -65,6 +65,9 @@ export default {
|
|||||||
name: "Name",
|
name: "Name",
|
||||||
canonical_alias: "Alias",
|
canonical_alias: "Alias",
|
||||||
joined_members: "Members",
|
joined_members: "Members",
|
||||||
|
invite_members: "Invite Members",
|
||||||
|
|
||||||
|
invitees: "Invitations",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
connections: {
|
connections: {
|
||||||
|
@ -23,6 +23,7 @@ const resourceMap = {
|
|||||||
is_guest: !!u.is_guest,
|
is_guest: !!u.is_guest,
|
||||||
admin: !!u.admin,
|
admin: !!u.admin,
|
||||||
deactivated: !!u.deactivated,
|
deactivated: !!u.deactivated,
|
||||||
|
displayname: u.display_name || u.displayname,
|
||||||
}),
|
}),
|
||||||
data: "users",
|
data: "users",
|
||||||
total: json => json.total,
|
total: json => json.total,
|
||||||
@ -40,16 +41,23 @@ const resourceMap = {
|
|||||||
}),
|
}),
|
||||||
data: "rooms",
|
data: "rooms",
|
||||||
total: json => json.total_rooms,
|
total: json => json.total_rooms,
|
||||||
create: params => ({
|
create: params => {
|
||||||
|
let invitees = params.data.invitees;
|
||||||
|
return {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
endpoint: "/_matrix/client/r0/createRoom",
|
endpoint: "/_matrix/client/r0/createRoom",
|
||||||
body: {
|
body: {
|
||||||
name: params.data.name,
|
name: params.data.name,
|
||||||
room_alias_name: params.data.canonical_alias,
|
room_alias_name: params.data.canonical_alias,
|
||||||
visibility: params.data.public ? "public" : "private",
|
visibility: params.data.public ? "public" : "private",
|
||||||
|
invite:
|
||||||
|
Array.isArray(invitees) && invitees.length > 0
|
||||||
|
? invitees
|
||||||
|
: undefined,
|
||||||
},
|
},
|
||||||
map: r => ({ id: r.room_id }),
|
map: r => ({ id: r.room_id }),
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
connections: {
|
connections: {
|
||||||
path: "/_synapse/admin/v1/whois",
|
path: "/_synapse/admin/v1/whois",
|
||||||
|
Loading…
Reference in New Issue
Block a user