From e8464042087c67a60a3d2eb8e4f4d5c89e4c8ad7 Mon Sep 17 00:00:00 2001 From: Sebastien Marinier Date: Wed, 15 May 2024 17:39:59 +0200 Subject: [PATCH] feat: manage view of rooms for moderators and users --- ts/Common/Api.ts | 1 + ts/Manager/RoomRow.tsx | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/ts/Common/Api.ts b/ts/Common/Api.ts index 6a2c278..cc684ad 100644 --- a/ts/Common/Api.ts +++ b/ts/Common/Api.ts @@ -39,6 +39,7 @@ export interface Room { everyoneIsModerator: boolean; requireModerator: boolean; shared: boolean; + permission: Permission; moderatorToken: string; listenOnly: boolean, mediaCheck: boolean, diff --git a/ts/Manager/RoomRow.tsx b/ts/Manager/RoomRow.tsx index bc6808a..8f2dd26 100644 --- a/ts/Manager/RoomRow.tsx +++ b/ts/Manager/RoomRow.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import { CopyToClipboard } from 'react-copy-to-clipboard'; -import { api, Recording, Room, Restriction, Access } from '../Common/Api'; +import { api, Recording, Room, Restriction, Access, Permission } from '../Common/Api'; import EditRoom from './EditRoom'; import RecordingRow from './RecordingRow'; import EditableValue from './EditableValue'; @@ -172,8 +172,11 @@ const RoomRow: React.FC = (props) => { return ; } - function edit(field: string, type: 'text' | 'number' = 'text', options?) { - return ; + function edit(field: string, type: 'text' | 'number' = 'text', canEdit: boolean = true, options?) { + return canEdit ? + + : + {room[field]}; } function cloneRow() { @@ -189,6 +192,8 @@ const RoomRow: React.FC = (props) => { const maxParticipantsLimit = props.restriction?.maxParticipants || -1; const minParticipantsLimit = (props.restriction?.maxParticipants || -1) < 1 ? 0 : 1; + const adminRoom = room.permission === null || room.permission === Permission.Admin; + return ( <> @@ -210,7 +215,7 @@ const RoomRow: React.FC = (props) => { - {edit('name')} + {edit('name', 'text', adminRoom)} {room.userId !== OC.currentUser && Avatar} @@ -220,25 +225,40 @@ const RoomRow: React.FC = (props) => { {accessToIcon(room.access)} - {edit('maxParticipants', 'number', {min: minParticipantsLimit, max: maxParticipantsLimit < 0 ? undefined : maxParticipantsLimit})} + {edit('maxParticipants', 'number', adminRoom, {min: minParticipantsLimit, max: maxParticipantsLimit < 0 ? undefined : maxParticipantsLimit})} + {adminRoom && updateRoom('record', event.target.checked)} /> - - - + } + {!adminRoom && + + + + } + + {adminRoom && + + } + + {adminRoom && + + } + + {adminRoom && + } {showRecordings &&