Skip to content
Snippets Groups Projects
Unverified Commit de3c8661 authored by Mariam A's avatar Mariam A Committed by GitHub
Browse files

Hide recording tabs when recording is disabled by admin (#5263)

* Hide recording tabs when recording is disabled by admin

* test and PR fixes
parent cbb1e9b4
Branches
Tags release-3.0.5-beta1
No related merge requests found
......@@ -19,7 +19,7 @@
module Api
module V1
class RoomsConfigurationsController < ApiController
before_action only: %i[index] do
before_action only: %i[index show] do
ensure_authorized(%w[CreateRoom ManageSiteSettings ManageRoles ManageRooms], friendly_id: params[:friendly_id])
end
......@@ -33,6 +33,20 @@ module Api
render_data data: rooms_configs, status: :ok
end
# GET /api/v1/rooms_configurations/:name.json
# Fetches and returns the value of the passed in configuration
def show
config_value = RoomsConfiguration.joins(:meeting_option)
.find_by(
provider: current_provider,
meeting_option: { name: params[:name] }
).value
render_data data: config_value, status: :ok
rescue StandardError
return render_error status: :not_found unless config_value
end
end
end
end
......@@ -23,18 +23,25 @@ import RoomsList from './RoomsList';
import UserRecordings from '../recordings/UserRecordings';
import RecordingsCountTab from '../recordings/RecordingsCountTab';
import useRecordingsCount from '../../hooks/queries/recordings/useRecordingsCount';
import useRoomConfigValue from '../../hooks/queries/rooms/useRoomConfigValue';
export default function Rooms() {
const { data: recordingsCount } = useRecordingsCount();
const { t } = useTranslation();
const { data: recordValue } = useRoomConfigValue('record');
return (
<Tabs className="wide-white pt-5" defaultActiveKey="rooms" unmountOnExit>
<Tab className="background-whitesmoke" eventKey="rooms" title={t('room.rooms')}>
<RoomsList />
</Tab>
{ (recordValue !== 'false')
&& (
<Tab className="background-whitesmoke" eventKey="recordings" title={<RecordingsCountTab count={recordingsCount} />}>
<UserRecordings />
</Tab>
)}
</Tabs>
);
}
......@@ -25,6 +25,7 @@ import { useAuth } from '../../../contexts/auth/AuthProvider';
import useSiteSetting from '../../../hooks/queries/site_settings/useSiteSetting';
import RoomRecordings from '../../recordings/room_recordings/RoomRecordings';
import useRoom from '../../../hooks/queries/rooms/useRoom';
import useRoomConfigValue from '../../../hooks/queries/rooms/useRoomConfigValue';
export default function FeatureTabs() {
const { t } = useTranslation();
......@@ -33,8 +34,9 @@ export default function FeatureTabs() {
const { friendlyId } = useParams();
const { data: room } = useRoom(friendlyId);
const { isLoading: isRoomConfigLoading, data: recordValue } = useRoomConfigValue('record');
if (isLoading) {
if (isLoading || isRoomConfigLoading) {
return (
<div className="wide-white pt-4 pb-2 mx-0">
<Placeholder className="ps-0" animation="glow">
......@@ -47,11 +49,16 @@ export default function FeatureTabs() {
);
}
const showRecTabs = (recordValue !== 'false');
return (
<Tabs className="wide-white pt-4 mx-0" defaultActiveKey="recordings" unmountOnExit>
<Tabs className="wide-white pt-4 mx-0" defaultActiveKey={showRecTabs ? 'recordings' : 'presentation'} unmountOnExit>
{showRecTabs
&& (
<Tab className="background-whitesmoke" eventKey="recordings" title={t('recording.recordings')}>
<RoomRecordings />
</Tab>
)}
{settings?.PreuploadPresentation
&& (
<Tab className="background-whitesmoke" eventKey="presentation" title={t('room.presentation.presentation')}>
......
......@@ -38,7 +38,7 @@ export default function Presentation() {
onSubmit(files[0]);
};
if (!room.presentation_name) {
if (!room?.presentation_name) {
return (
<FilesDragAndDrop
onDrop={onDrop}
......
// BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
//
// Copyright (c) 2022 BigBlueButton Inc. and by respective authors (see below).
//
// This program is free software; you can redistribute it and/or modify it under the
// terms of the GNU Lesser General Public License as published by the Free Software
// Foundation; either version 3.0 of the License, or (at your option) any later
// version.
//
// Greenlight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along
// with Greenlight; if not, see <http://www.gnu.org/licenses/>.
import { useQuery } from 'react-query';
import axios from '../../../helpers/Axios';
export default function useRoomConfigValue(name) {
return useQuery(
['getRoomsConfigValue', name],
() => axios.get(`/rooms_configurations/${name}.json`).then((resp) => resp.data.data),
);
}
......@@ -83,7 +83,7 @@ Rails.application.routes.draw do
post '/activate', to: 'verify_account#activate', on: :collection
end
resources :site_settings, only: :index
resources :rooms_configurations, only: :index
resources :rooms_configurations, only: %i[index show], param: :name
resources :locales, only: %i[index show], param: :name
namespace :admin do
......
......@@ -46,4 +46,24 @@ RSpec.describe Api::V1::RoomsConfigurationsController, type: :controller do
expect(response).to have_http_status(:ok)
end
end
describe 'rooms_configurations#show' do
before do
create(:rooms_configuration, meeting_option: create(:meeting_option, name: 'record'), value: 'false')
end
it 'returns the correct configuration value' do
get :show, params: { name: 'record' }
expect(JSON.parse(response.body)['data']).to eq('false')
expect(response).to have_http_status(:ok)
end
it 'returns :not_found if the configuration :name passed does not exist' do
get :show, params: { name: 'nonexistent' }
expect(response).to have_http_status(:not_found)
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment