From a208b615f0efb66bf94726090f79664c7c6cb4c5 Mon Sep 17 00:00:00 2001 From: farhatahmad Date: Tue, 12 Dec 2023 16:52:50 -0500 Subject: [PATCH] Final work --- .../stylesheets/application.bootstrap.scss | 15 +++++++++ .../v1/admin/role_permissions_controller.rb | 2 +- .../api/v1/recordings_controller.rb | 8 +++-- .../admin/roles/forms/EditRoleForm.jsx | 31 +++++++++++++------ .../components/recordings/RecordingRow.jsx | 12 +++---- app/services/tenant_setup.rb | 6 +++- .../controllers/recordings_controller_spec.rb | 26 ++++++++++++++-- spec/factories/role_factory.rb | 2 ++ 8 files changed, 79 insertions(+), 23 deletions(-) diff --git a/app/assets/stylesheets/application.bootstrap.scss b/app/assets/stylesheets/application.bootstrap.scss index 9254303d88..57e48faba3 100644 --- a/app/assets/stylesheets/application.bootstrap.scss +++ b/app/assets/stylesheets/application.bootstrap.scss @@ -284,6 +284,21 @@ input.search-bar { } } +.custom-select { + .select-brand-control { + border-color: var(--brand-color) !important; + box-shadow: 0 0 0 1px var(--brand-color) !important; + } + + .select-brand-option { + background-color: whitesmoke; + color: var(--brand-color) !important; + &:active { + background-color: var(--brand-color-light) !important; + } + } +} + //Brand :root { --brand-color: ''; diff --git a/app/controllers/api/v1/admin/role_permissions_controller.rb b/app/controllers/api/v1/admin/role_permissions_controller.rb index b694807ca1..f1cf0f30ca 100644 --- a/app/controllers/api/v1/admin/role_permissions_controller.rb +++ b/app/controllers/api/v1/admin/role_permissions_controller.rb @@ -50,7 +50,7 @@ def update private def role_params - params.require(:role).permit(:role_id, :name, :value) + params.require(:role).permit(:role_id, :name, :value, value: []) end def create_default_room diff --git a/app/controllers/api/v1/recordings_controller.rb b/app/controllers/api/v1/recordings_controller.rb index f52cdf50db..2602753212 100644 --- a/app/controllers/api/v1/recordings_controller.rb +++ b/app/controllers/api/v1/recordings_controller.rb @@ -63,9 +63,13 @@ def destroy def update_visibility new_visibility = params[:visibility].to_s - new_visibility_params = visibility_params_of(new_visibility) + allowed_visibilities = JSON.parse(RolePermission.joins(:permission) + .find_by(role_id: current_user.role_id, permission: { name: 'AccessToVisibilities' }) + .value) + + return render_error status: :forbidden unless allowed_visibilities.include?(new_visibility) - return render_error status: :bad_request if new_visibility_params.nil? + new_visibility_params = visibility_params_of(new_visibility) bbb_api = BigBlueButtonApi.new(provider: current_provider) diff --git a/app/javascript/components/admin/roles/forms/EditRoleForm.jsx b/app/javascript/components/admin/roles/forms/EditRoleForm.jsx index f2ee3793d5..b80e15dcdb 100644 --- a/app/javascript/components/admin/roles/forms/EditRoleForm.jsx +++ b/app/javascript/components/admin/roles/forms/EditRoleForm.jsx @@ -18,6 +18,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Button, Stack } from 'react-bootstrap'; import { useTranslation } from 'react-i18next'; +import Select from 'react-select'; import Form from '../../../shared_components/forms/Form'; import FormControl from '../../../shared_components/forms/FormControl'; import useUpdateRole from '../../../../hooks/mutations/admin/roles/useUpdateRole'; @@ -31,7 +32,6 @@ import { useAuth } from '../../../../contexts/auth/AuthProvider'; import RolePermissionRowPlaceHolder from '../RolePermissionRowPlaceHolder'; import useEditRoleNameForm from '../../../../hooks/forms/admin/roles/useEditRoleNameForm'; import useEditRoleLimitForm from '../../../../hooks/forms/admin/roles/useEditRoleLimitForm'; -import Select from "react-select"; export default function EditRoleForm({ role }) { const { t } = useTranslation(); @@ -45,6 +45,14 @@ export default function EditRoleForm({ role }) { const { methods: methodsName, fields: fieldsName } = useEditRoleNameForm({ defaultValues: { name: role?.name } }); + const visibilityOptions = [ + { value: 'Published', label: 'Published' }, + { value: 'Unpublished', label: 'Unpublished' }, + { value: 'Protected', label: 'Protected' }, + { value: 'Public', label: 'Public' }, + { value: 'Public/Protected', label: 'Public/Protected' }, + ]; + const { methods: methodsLimit, fields: fieldsLimit, @@ -145,16 +153,19 @@ export default function EditRoleForm({ role }) {