From 69b8d73687366d700a97f03a4e1e428ce1b1ac00 Mon Sep 17 00:00:00 2001 From: "Specht, David" Date: Fri, 25 Mar 2022 16:47:19 +0100 Subject: [PATCH] feat: clone rooms --- ts/Manager/App.tsx | 22 +++++++++++++++++++++- ts/Manager/RoomRow.tsx | 10 ++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ts/Manager/App.tsx b/ts/Manager/App.tsx index b7f32cc..a166048 100644 --- a/ts/Manager/App.tsx +++ b/ts/Manager/App.tsx @@ -43,7 +43,7 @@ const App: React.FC = () => { const [orderBy, setOrderBy] = useState('name'); const [sortOrder, setSortOrder] = useState(SortOrder.ASC); - const rows = rooms.sort(sortRooms(orderBy, sortOrder)).map(room => ); + const rows = rooms.sort(sortRooms(orderBy, sortOrder)).map(room => ); useEffect(() => { Promise.all([ @@ -121,6 +121,25 @@ const App: React.FC = () => { }); } + function cloneRoom(room: Room) { + + let access = Access.Public; + + const disabledRoomTypes = restriction?.roomTypes || []; + if (disabledRoomTypes.length > 0 && disabledRoomTypes.indexOf(access) > -1) { + access = Object.values(Access).filter(a => disabledRoomTypes.indexOf(a) < 0)[0] as Access; + } + + const maxParticipants = restriction?.maxParticipants || 0; + + return api.createRoom(room.name, access, maxParticipants).then(newRoom => { + room.uid = newRoom.uid; + room.id = newRoom.id; + setRooms(rooms.concat([room])); + updateRoom(room); + }); + } + const maxRooms = restriction?.maxRooms || 0; const quota = maxRooms < 0 ? t('bbb', 'unlimited') : rooms.filter(room => room.userId === OC.currentUser).length + ' / ' + maxRooms; @@ -151,6 +170,7 @@ const App: React.FC = () => { + diff --git a/ts/Manager/RoomRow.tsx b/ts/Manager/RoomRow.tsx index 40de45b..bc6808a 100644 --- a/ts/Manager/RoomRow.tsx +++ b/ts/Manager/RoomRow.tsx @@ -11,6 +11,7 @@ type Props = { restriction?: Restriction; updateRoom: (room: Room) => Promise; deleteRoom: (id: number) => void; + cloneRoom: (room: Room) => void; } type RecordingsNumberProps = { @@ -175,6 +176,10 @@ const RoomRow: React.FC = (props) => { return ; } + function cloneRow() { + props.cloneRoom({...props.room}); + } + const avatarUrl = OC.generateUrl('/avatar/' + encodeURIComponent(room.userId) + '/' + 24, { user: room.userId, size: 24, @@ -225,6 +230,11 @@ const RoomRow: React.FC = (props) => { + + +