2020-08-27 17:21:34 +02:00
|
|
|
import React, { } from 'react';
|
|
|
|
import { Restriction } from '../Common/Api';
|
|
|
|
import EditableValue from '../Manager/EditableValue';
|
|
|
|
import EditableSelection from '../Common/EditableSelection';
|
|
|
|
import { AccessOptions } from '../Common/Translation';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
restriction: Restriction;
|
|
|
|
updateRestriction: (restriction: Restriction) => Promise<void>;
|
|
|
|
deleteRestriction: (id: number) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const RestrictionRoom: React.FC<Props> = (props) => {
|
|
|
|
const restriction = props.restriction;
|
|
|
|
|
|
|
|
function updateRestriction(key: string, value: string | boolean | number | string[]) {
|
|
|
|
return props.updateRestriction({
|
|
|
|
...props.restriction,
|
|
|
|
[key]: value,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteRow(ev: MouseEvent) {
|
|
|
|
ev.preventDefault();
|
2024-10-22 15:30:10 +02:00
|
|
|
const groupName = restriction.groupName || restriction.groupId;
|
2020-08-27 17:21:34 +02:00
|
|
|
OC.dialogs.confirm(
|
2024-10-22 15:30:10 +02:00
|
|
|
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}),
|
2020-08-27 17:21:34 +02:00
|
|
|
confirmed => {
|
|
|
|
if (confirmed) {
|
|
|
|
props.deleteRestriction(restriction.id);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function edit(field: string, type: 'text' | 'number' = 'text') {
|
|
|
|
return <EditableValue field={field} value={restriction[field]} setValue={updateRestriction} type={type} options={{min: -1}} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
2024-10-22 15:30:10 +02:00
|
|
|
<td className="name">{restriction.groupName || restriction.groupId || t('bbb', 'All users')}</td>
|
2020-08-27 17:21:34 +02:00
|
|
|
<td className="max-rooms bbb-shrink">
|
|
|
|
{edit('maxRooms', 'number')}
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2020-08-28 11:36:15 +02:00
|
|
|
<EditableSelection
|
|
|
|
field="roomTypes"
|
|
|
|
values={restriction.roomTypes}
|
|
|
|
options={AccessOptions}
|
|
|
|
setValue={updateRestriction}
|
|
|
|
invert={true}
|
|
|
|
placeholder={t('bbb', 'All')} />
|
2020-08-27 17:21:34 +02:00
|
|
|
</td>
|
|
|
|
|
|
|
|
<td className="max-participants bbb-shrink">
|
|
|
|
{edit('maxParticipants', 'number')}
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td className="record bbb-shrink">
|
|
|
|
<input
|
2024-08-15 15:42:55 +02:00
|
|
|
id={'bbb-record-' + restriction.id}
|
2020-08-27 17:21:34 +02:00
|
|
|
type="checkbox"
|
|
|
|
className="checkbox"
|
|
|
|
checked={restriction.allowRecording}
|
|
|
|
onChange={(event) => updateRestriction('allowRecording', event.target.checked)} />
|
2024-08-15 15:42:55 +02:00
|
|
|
<label htmlFor={'bbb-record-' + restriction.id}></label>
|
2020-08-27 17:21:34 +02:00
|
|
|
</td>
|
|
|
|
|
|
|
|
<td className="remove icon-col">
|
2021-03-09 09:37:08 +01:00
|
|
|
<button disabled={!restriction.groupId} className="action-item" onClick={deleteRow as any} title={t('bbb', 'Delete')}>
|
|
|
|
<span className="icon icon-delete icon-visible"></span>
|
|
|
|
</button>
|
2020-08-27 17:21:34 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default RestrictionRoom;
|