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,20 +102,37 @@ const validateHasAliasIfPublic = formdata => {
|
|||||||
|
|
||||||
export const RoomCreate = props => (
|
export const RoomCreate = props => (
|
||||||
<Create {...props}>
|
<Create {...props}>
|
||||||
<SimpleForm validate={validateHasAliasIfPublic}>
|
<TabbedForm validate={validateHasAliasIfPublic}>
|
||||||
<TextInput
|
<FormTab label="synapseadmin.rooms.details" icon={<ViewListIcon />}>
|
||||||
source="name"
|
<TextInput
|
||||||
parse={removeLeadingWhitespace}
|
source="name"
|
||||||
validate={validateDisplayName}
|
parse={removeLeadingWhitespace}
|
||||||
/>
|
validate={validateDisplayName}
|
||||||
<TextInput
|
/>
|
||||||
source="canonical_alias"
|
<TextInput
|
||||||
parse={fv => replaceAllWhitespace(removeLeadingSigil(fv))}
|
source="canonical_alias"
|
||||||
validate={validateAlias}
|
parse={fv => replaceAllWhitespace(removeLeadingSigil(fv))}
|
||||||
placeholder="#"
|
validate={validateAlias}
|
||||||
/>
|
placeholder="#"
|
||||||
<BooleanInput source="public" label="synapseadmin.rooms.make_public" />
|
/>
|
||||||
</SimpleForm>
|
<BooleanInput source="public" label="synapseadmin.rooms.make_public" />
|
||||||
|
</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 => {
|
||||||
method: "POST",
|
let invitees = params.data.invitees;
|
||||||
endpoint: "/_matrix/client/r0/createRoom",
|
return {
|
||||||
body: {
|
method: "POST",
|
||||||
name: params.data.name,
|
endpoint: "/_matrix/client/r0/createRoom",
|
||||||
room_alias_name: params.data.canonical_alias,
|
body: {
|
||||||
visibility: params.data.public ? "public" : "private",
|
name: params.data.name,
|
||||||
},
|
room_alias_name: params.data.canonical_alias,
|
||||||
map: r => ({ id: r.room_id }),
|
visibility: params.data.public ? "public" : "private",
|
||||||
}),
|
invite:
|
||||||
|
Array.isArray(invitees) && invitees.length > 0
|
||||||
|
? invitees
|
||||||
|
: undefined,
|
||||||
|
},
|
||||||
|
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