Compare commits

..

No commits in common. "e5bfcc8ec8df1b69bb52d3a909e5f62d3b74f63e" and "31bc8aeea1fa17ad8a42ec47e0f1f13779c92269" have entirely different histories.

11 changed files with 55 additions and 81 deletions

View File

@ -16,13 +16,11 @@ use OCP\AppFramework\Db\Entity;
* @method void setMaxRooms(int $number)
* @method void setMaxParticipants(int $number)
* @method void setAllowRecording(bool $allow)
* @method void setGroupName(string $groupName)
*/
class Restriction extends Entity implements JsonSerializable {
public const ALL_ID = '';
protected $groupId;
protected $groupName;
protected $maxRooms = -1;
protected $roomTypes = '[]';
protected $maxParticipants = -1;
@ -34,15 +32,10 @@ class Restriction extends Entity implements JsonSerializable {
$this->addType('allowRecording', 'boolean');
}
public function setGroupName(string $groupName) {
$this->groupName = $groupName;
}
public function jsonSerialize(): array {
return [
'id' => $this->id,
'groupId' => $this->groupId,
'groupName' => $this->groupName,
'maxRooms' => (int) $this->maxRooms,
'roomTypes' => \json_decode($this->roomTypes),
'maxParticipants' => (int) $this->maxParticipants,

View File

@ -19,9 +19,8 @@ class RestrictionMapper extends QBMapper {
public function find(int $id): Restriction {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('r.*', 'g.displayname as groupName')
->from($this->tableName, 'r')
->leftJoin('r', 'groups', 'g', $qb->expr()->eq('r.group_id', 'g.gid'))
$qb->select('*')
->from($this->tableName)
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
return $this->findEntity($qb);
@ -34,9 +33,8 @@ class RestrictionMapper extends QBMapper {
public function findByGroupId(string $groupId): Restriction {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('r.*', 'g.displayname as groupName')
->from($this->tableName, 'r')
->leftJoin('r', 'groups', 'g', $qb->expr()->eq('r.group_id', 'g.gid'))
$qb->select('*')
->from($this->tableName)
->where($qb->expr()->eq('group_id', $qb->createNamedParameter($groupId)));
return $this->findEntity($qb);
@ -48,9 +46,8 @@ class RestrictionMapper extends QBMapper {
public function findByGroupIds(array $groupIds): array {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('r.*', 'g.displayname as groupName')
->from($this->tableName, 'r')
->leftJoin('r', 'groups', 'g', $qb->expr()->eq('r.group_id', 'g.gid'))
$qb->select('*')
->from($this->tableName)
->where($qb->expr()->in('group_id', $qb->createNamedParameter($groupIds, IQueryBuilder::PARAM_STR_ARRAY)));
/** @var array<Restriction> */
@ -63,9 +60,8 @@ class RestrictionMapper extends QBMapper {
public function findAll(): array {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('r.*', 'g.displayname as groupName')
->from($this->tableName, 'r')
->leftJoin('r', 'groups', 'g', $qb->expr()->eq('r.group_id', 'g.gid'));
$qb->select('*')
->from($this->tableName);
/** @var array<Restriction> */
return $this->findEntities($qb);

View File

@ -55,13 +55,10 @@ class Permission {
}
public function isAllowedToCreateRoom(string $uid): bool {
$numberOfCreatedRooms = count($this->roomService->findAll($uid, [], []));
$restriction = $this->getRestriction($uid);
if ($restriction->getMaxRooms() < 0) {
return true;
}
$numberOfCreatedRooms = count($this->roomService->findByUserId($uid));
return $restriction->getMaxRooms() > $numberOfCreatedRooms;
return $restriction->getMaxRooms() < 0 || $restriction->getMaxRooms() > $numberOfCreatedRooms;
}
public function isUser(Room $room, ?string $uid): bool {

View File

@ -9,18 +9,13 @@ use OCA\BigBlueButton\Db\RestrictionMapper;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\IGroupManager;
class RestrictionService {
/** @var RestrictionMapper */
private $mapper;
/** @var IGroupManager */
private $groupManager;
public function __construct(RestrictionMapper $mapper, IGroupManager $groupManager) {
public function __construct(RestrictionMapper $mapper) {
$this->mapper = $mapper;
$this->groupManager = $groupManager;
}
public function findAll(): array {
@ -83,10 +78,6 @@ class RestrictionService {
$restriction = new Restriction();
$restriction->setGroupId($groupId);
$group = $this->groupManager->get($groupId);
if ($group) {
$restriction->setGroupName($group->getDisplayName());
}
return $this->mapper->insert($restriction);
}

View File

@ -109,7 +109,7 @@
"stylelint-config-recommended-scss": "^5.0.2",
"stylelint-scss": "^4.2.0",
"ts-loader": "^9.2.8",
"typescript": "^4.9.3",
"typescript": "^4.0.2",
"url-loader": "^4.0.0",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2",

View File

@ -83,8 +83,7 @@ class PermissionTest extends TestCase {
$this->roomService
->expects($this->once())
->method('findByUserId')
->with('foobar')
->method('findAll')
->willReturn([
$this->createRoom(1, 'foo'),
$this->createRoom(2, 'bar'),

View File

@ -8,19 +8,16 @@ use OCA\BigBlueButton\Db\Restriction;
use OCA\BigBlueButton\Db\RestrictionMapper;
use OCA\BigBlueButton\Db\Room;
use OCA\BigBlueButton\Service\RestrictionService;
use OCP\IGroupManager;
use PHPUnit\Framework\TestCase;
class RestrictionServiceTest extends TestCase {
protected $mapper;
protected $groupManager;
protected $service;
public function setUp(): void {
$this->mapper = $this->createMock(RestrictionMapper::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->service = new RestrictionService($this->mapper, $this->groupManager);
$this->service = new RestrictionService($this->mapper);
}
public function testFindByGroupIds() {

View File

@ -20,7 +20,6 @@ export enum Access {
export interface Restriction {
id: number;
groupId: string;
groupName: string;
maxRooms: number;
roomTypes: string[];
maxParticipants: number;

View File

@ -37,36 +37,6 @@
opacity: 0.6;
}
.bbb-qrcode-container {
display: block;
height: 34px;
width: 34px;
margin: 3px;
position: relative;
cursor: zoom-in;
canvas {
max-width: 100%;
max-height: 100%;
position: absolute;
top: 0;
right: 0;
}
input[type="checkbox"] {
display: none;
&:checked + canvas {
max-width: none;
max-height: none;
box-shadow: 0 0 10px;
box-shadow: 0 0 5px var(--color-box-shadow);
cursor: zoom-out;
border: 5px solid #fff;
}
}
}
#bbb-root, #bbb-app {
width: 100%;
background-color: var(--color-main-background);
@ -125,6 +95,10 @@ pre {
}
}
#bbb-react-root table tbody tr td {
border-bottom: 1px solid var(--color-border-dark);
}
#bbb-react-root,
#bbb-restrictions {
#bbb-warning,
@ -220,7 +194,6 @@ pre {
padding: 0 6px;
position: relative;
display: table-cell;
border-bottom: 1px solid var(--color-border-dark);
& > form {
margin: -10px;
@ -325,9 +298,39 @@ pre {
}
.bbb-simple-menu {
min-width: auto;
min-width: auto;
}
.bbb-input-container {
display: flex;
}
.bbb-qrcode-container {
display: block;
height: 34px;
width: 34px;
margin: 3px;
position: relative;
cursor: zoom-in;
canvas {
max-width: 100%;
max-height: 100%;
position: absolute;
top: 0;
right: 0;
}
input[type="checkbox"] {
display: none;
&:checked + canvas {
max-width: none;
max-height: none;
box-shadow: 0 0 10px;
box-shadow: 0 0 5px var(--color-box-shadow);
cursor: zoom-out;
border: 5px solid #fff;
}
}
}

View File

@ -146,8 +146,7 @@ const App: React.FC<Props> = () => {
}
const maxRooms = restriction?.maxRooms || 0;
const ownRoomsLength = rooms.filter(room => room.userId === OC.currentUser).length;
const quota = maxRooms < 0 ? t('bbb', 'unlimited') : ownRoomsLength + ' / ' + maxRooms;
const quota = maxRooms < 0 ? t('bbb', 'unlimited') : rooms.filter(room => room.userId === OC.currentUser).length + ' / ' + maxRooms;
return (
<div id="bbb-react-root"
@ -189,7 +188,7 @@ const App: React.FC<Props> = () => {
{!isLoaded && <span className="icon icon-loading-small icon-visible"></span>}
</td>
<td>
{(maxRooms > ownRoomsLength || maxRooms < 0) ?
{(maxRooms > rows.length || maxRooms < 0) ?
<NewRoomForm addRoom={addRoom} /> :
<p className="text-muted">{maxRooms === 0 ?
t('bbb', 'You are not permitted to create a room.') :

View File

@ -23,10 +23,10 @@ const RestrictionRoom: React.FC<Props> = (props) => {
function deleteRow(ev: MouseEvent) {
ev.preventDefault();
const groupName = restriction.groupName || restriction.groupId;
OC.dialogs.confirm(
t('bbb', 'Are you sure you want to delete the restrictions for group "{name}"? This operation cannot be undone.', { name: groupName }),
t('bbb', 'Delete restrictions for "{name}"?', { name: groupName}),
t('bbb', 'Are you sure you want to delete the restrictions for group "{name}"? This operation cannot be undone.', { name: restriction.groupId }),
t('bbb', 'Delete restrictions for "{name}"?', { name: restriction.groupId }),
confirmed => {
if (confirmed) {
props.deleteRestriction(restriction.id);
@ -42,7 +42,7 @@ const RestrictionRoom: React.FC<Props> = (props) => {
return (
<tr>
<td className="name">{restriction.groupName || restriction.groupId || t('bbb', 'All users')}</td>
<td className="name">{restriction.groupId || t('bbb', 'All users')}</td>
<td className="max-rooms bbb-shrink">
{edit('maxRooms', 'number')}
</td>