From 880223e5de6fe6eadd2a13ae7010f5290d9f7b62 Mon Sep 17 00:00:00 2001 From: Timo Paulssen Date: Tue, 28 Apr 2020 18:36:46 +0200 Subject: [PATCH] Offer invitations in room creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/components/rooms.js | 51 +++++++++++++++++++++++++------------ src/i18n/de.js | 2 ++ src/i18n/en.js | 3 +++ src/synapse/dataProvider.js | 28 ++++++++++++-------- 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/src/components/rooms.js b/src/components/rooms.js index 5e7606a..238cfdd 100644 --- a/src/components/rooms.js +++ b/src/components/rooms.js @@ -1,15 +1,17 @@ import React from "react"; import { - BooleanField, + AutocompleteArrayInput, BooleanInput, Create, Datagrid, + FormTab, List, Pagination, ReferenceArrayField, + ReferenceArrayInput, Show, - SimpleForm, Tab, + TabbedForm, TabbedShowLayout, TextField, TextInput, @@ -100,20 +102,37 @@ const validateHasAliasIfPublic = formdata => { export const RoomCreate = props => ( - - - replaceAllWhitespace(removeLeadingSigil(fv))} - validate={validateAlias} - placeholder="#" - /> - - + + }> + + replaceAllWhitespace(removeLeadingSigil(fv))} + validate={validateAlias} + placeholder="#" + /> + + + } + > + ({ user_id: searchText })} + > + + + + ); diff --git a/src/i18n/de.js b/src/i18n/de.js index f4a4c38..9d0dac5 100644 --- a/src/i18n/de.js +++ b/src/i18n/de.js @@ -65,6 +65,8 @@ export default { name: "Name", canonical_alias: "Alias", joined_members: "Mitglieder", + invite_members: "Mitglieder einladen", + invitees: "Einladungen", }, }, connections: { diff --git a/src/i18n/en.js b/src/i18n/en.js index f8cc133..137b181 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -65,6 +65,9 @@ export default { name: "Name", canonical_alias: "Alias", joined_members: "Members", + invite_members: "Invite Members", + + invitees: "Invitations", }, }, connections: { diff --git a/src/synapse/dataProvider.js b/src/synapse/dataProvider.js index 742214d..00d14be 100644 --- a/src/synapse/dataProvider.js +++ b/src/synapse/dataProvider.js @@ -23,6 +23,7 @@ const resourceMap = { is_guest: !!u.is_guest, admin: !!u.admin, deactivated: !!u.deactivated, + displayname: u.display_name || u.displayname, }), data: "users", total: json => json.total, @@ -40,16 +41,23 @@ const resourceMap = { }), data: "rooms", total: json => json.total_rooms, - create: params => ({ - method: "POST", - endpoint: "/_matrix/client/r0/createRoom", - body: { - name: params.data.name, - room_alias_name: params.data.canonical_alias, - visibility: params.data.public ? "public" : "private", - }, - map: r => ({ id: r.room_id }), - }), + create: params => { + let invitees = params.data.invitees; + return { + method: "POST", + endpoint: "/_matrix/client/r0/createRoom", + body: { + name: params.data.name, + room_alias_name: params.data.canonical_alias, + visibility: params.data.public ? "public" : "private", + invite: + Array.isArray(invitees) && invitees.length > 0 + ? invitees + : undefined, + }, + map: r => ({ id: r.room_id }), + }; + }, }, connections: { path: "/_synapse/admin/v1/whois",