Skip to content

Commit 95c9d76

Browse files
authored
Add global override for tag_required room setting (hiding the UI buttons if used) (#5940)
* add basic backend support for globally configurable tag fallback mode * add support for global tag fallback mode option in javascript (i.e. hide corresponding room config when override is set) * handle tag fallback mode in meeting_starter + ensure consistent logic accross rails/js * final round of fixes and polish
1 parent b85c7b6 commit 95c9d76

File tree

8 files changed

+84
-34
lines changed

8 files changed

+84
-34
lines changed

app/controllers/api/v1/server_tags_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ def show
3232
allowed_tag_names = tag_names.reject { |tag, _| tag_roles.key?(tag) && tag_roles[tag].exclude?(room.user.role_id) }
3333
render_data data: allowed_tag_names, status: :ok
3434
end
35+
36+
# GET /api/v1/server_tags/fallback_mode.json
37+
# Returns global tag fallback mode (user config or global desired/required)
38+
def fallback_mode
39+
render_data data: Rails.configuration.server_tag_fallback_mode, status: :ok
40+
end
3541
end
3642
end
3743
end

app/javascript/components/rooms/room/room_settings/RoomSettings.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import UpdateRoomNameForm from './forms/UpdateRoomNameForm';
3434
import useRoom from '../../../../hooks/queries/rooms/useRoom';
3535
import UnshareRoom from './UnshareRoom';
3636
import useServerTags from '../../../../hooks/queries/rooms/useServerTags';
37+
import useServerTagsFallbackMode from '../../../../hooks/queries/rooms/useServerTagsFallbackMode';
3738
import ServerTagRow from './ServerTagRow';
3839

3940
export default function RoomSettings() {
@@ -44,6 +45,7 @@ export default function RoomSettings() {
4445
const { data: roomConfigs } = useRoomConfigs();
4546
const { data: room } = useRoom(friendlyId);
4647
const { data: serverTags } = useServerTags(friendlyId);
48+
const { data: serverTagsFallbackMode } = useServerTagsFallbackMode();
4749

4850
const updateMutationWrapper = () => useUpdateRoomSetting(friendlyId);
4951
const deleteMutationWrapper = (args) => useDeleteRoom({ friendlyId, ...args });
@@ -75,6 +77,7 @@ export default function RoomSettings() {
7577
currentTag={roomSetting?.data?.serverTag}
7678
tagRequired={roomSetting?.data?.serverTagRequired === 'true'}
7779
serverTags={serverTags}
80+
fallbackMode={serverTagsFallbackMode}
7881
description={t('room.settings.server_tag')}
7982
/>
8083
)}

app/javascript/components/rooms/room/room_settings/ServerTagRow.jsx

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
import SimpleSelect from '../../../shared_components/utilities/SimpleSelect';
2424

2525
export default function ServerTagRow({
26-
updateMutation: useUpdateAPI, currentTag, tagRequired, serverTags, description,
26+
updateMutation: useUpdateAPI, currentTag, tagRequired, serverTags, fallbackMode, description,
2727
}) {
2828
const updateAPI = useUpdateAPI();
2929
const { t } = useTranslation();
@@ -68,38 +68,40 @@ export default function ServerTagRow({
6868
].concat(dropdownTags)}
6969
</SimpleSelect>
7070
</Col>
71-
<Col>
72-
<ButtonGroup>
73-
<ToggleButton
74-
key="desired"
75-
id="desired"
76-
type="radio"
77-
variant="outline-success"
78-
name="radio"
79-
checked={tagRequired === false}
80-
disabled={updateAPI.isLoading}
81-
onChange={() => {
82-
updateAPI.mutate({ settingName: 'serverTagRequired', settingValue: false });
83-
}}
84-
>
85-
{t('room.settings.server_tag_desired')}
86-
</ToggleButton>
87-
<ToggleButton
88-
key="required"
89-
id="required"
90-
type="radio"
91-
variant="outline-danger"
92-
name="radio"
93-
checked={tagRequired === true}
94-
disabled={updateAPI.isLoading}
95-
onChange={() => {
96-
updateAPI.mutate({ settingName: 'serverTagRequired', settingValue: true });
97-
}}
98-
>
99-
{t('room.settings.server_tag_required')}
100-
</ToggleButton>
101-
</ButtonGroup>
102-
</Col>
71+
{(fallbackMode !== 'desired' && fallbackMode !== 'required') && (
72+
<Col>
73+
<ButtonGroup>
74+
<ToggleButton
75+
key="desired"
76+
id="desired"
77+
type="radio"
78+
variant="outline-success"
79+
name="radio"
80+
checked={tagRequired === false}
81+
disabled={updateAPI.isLoading}
82+
onChange={() => {
83+
updateAPI.mutate({ settingName: 'serverTagRequired', settingValue: false });
84+
}}
85+
>
86+
{t('room.settings.server_tag_desired')}
87+
</ToggleButton>
88+
<ToggleButton
89+
key="required"
90+
id="required"
91+
type="radio"
92+
variant="outline-danger"
93+
name="radio"
94+
checked={tagRequired === true}
95+
disabled={updateAPI.isLoading}
96+
onChange={() => {
97+
updateAPI.mutate({ settingName: 'serverTagRequired', settingValue: true });
98+
}}
99+
>
100+
{t('room.settings.server_tag_required')}
101+
</ToggleButton>
102+
</ButtonGroup>
103+
</Col>
104+
)}
103105
</Row>
104106
);
105107
}
@@ -114,5 +116,6 @@ ServerTagRow.propTypes = {
114116
currentTag: PropTypes.string,
115117
tagRequired: PropTypes.bool,
116118
serverTags: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
119+
fallbackMode: PropTypes.string.isRequired,
117120
description: PropTypes.string.isRequired,
118121
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
2+
//
3+
// Copyright (c) 2022 BigBlueButton Inc. and by respective authors (see below).
4+
//
5+
// This program is free software; you can redistribute it and/or modify it under the
6+
// terms of the GNU Lesser General Public License as published by the Free Software
7+
// Foundation; either version 3.0 of the License, or (at your option) any later
8+
// version.
9+
//
10+
// Greenlight is distributed in the hope that it will be useful, but WITHOUT ANY
11+
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12+
// PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Lesser General Public License along
15+
// with Greenlight; if not, see <http://www.gnu.org/licenses/>.
16+
17+
import { useQuery } from 'react-query';
18+
import axios from '../../../helpers/Axios';
19+
20+
export default function useServerTagsFallbackMode() {
21+
return useQuery(
22+
'getFallbackMode',
23+
() => axios.get('/server_tags/fallback_mode.json').then((resp) => resp.data.data),
24+
);
25+
}

app/services/meeting_starter.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ def handle_server_tag(meeting_options:)
8383
tag_roles = Rails.configuration.server_tag_roles
8484
tag = meeting_options.delete('serverTag')
8585
tag_required = meeting_options.delete('serverTagRequired')
86+
# handle override modes
87+
if Rails.configuration.server_tag_fallback_mode == 'required'
88+
tag_required = 'true'
89+
elsif Rails.configuration.server_tag_fallback_mode == 'desired'
90+
tag_required = 'false'
91+
end
8692

8793
if tag_names.key?(tag) && !(tag_roles.key?(tag) && tag_roles[tag].exclude?(@room.user.role_id))
8894
tag_param = tag_required == 'true' ? "#{tag}!" : tag

config/application.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class Application < Rails::Application
9393
config.i18n.enforce_available_locales = false
9494

9595
# Handle server tag config
96+
config.server_tag_fallback_mode = ENV.fetch('SERVER_TAG_FALLBACK_MODE', 'config')
9697
config.server_tag_names = ENV.fetch('SERVER_TAG_NAMES', '').split(',').to_h { |pair| pair.split(':') }
9798
config.server_tag_roles = ENV.fetch('SERVER_TAG_ROLES', '').split(',').to_h { |pair| pair.split(':') }
9899
config.server_tag_roles = config.server_tag_roles.transform_values! { |v| v.split('/') }

config/routes.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@
8585
resources :site_settings, only: :index
8686
resources :rooms_configurations, only: %i[index show], param: :name
8787
resources :locales, only: %i[index show], param: :name
88-
resources :server_tags, only: :show, param: :friendly_id
88+
resources :server_tags, only: :show, param: :friendly_id do
89+
collection do
90+
get '/fallback_mode', to: 'server_tags#fallback_mode'
91+
end
92+
end
8993

9094
namespace :admin do
9195
resources :users, only: %i[update] do

sample.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ LOG_LEVEL=info
109109
# If your Greenlight instance is connected to Scalelite or another Loadbalancer with enabled support for the 'meta_server-tag'
110110
# parameter on create calls, you can use the following variables to configure support for this feature via the Greenlight UI.
111111
# When this configuration is changed later, disallowed tags can be removed from the DB via `bundle exec rake server_tags_sync`
112+
# For more documentation on the feature, see here: https://github.com/blindsidenetworks/scalelite/blob/master/docs/tags-README.md
112113
# Example configuration (delimiters are , : and /):
113114
# SERVER_TAG_NAMES=tag1:Name 1,tag2:Name2 # defines available tags and their friendly names
114115
# SERVER_TAG_ROLES=tag2:xyz-123-321-aaaa-zyx/abc-321-123-zzzz-cba # allow tag only for given role ids (see role ids in DB)
116+
# SERVER_TAG_FALLBACK_MODE=required # fallback mode, may be 'desired'/'required' (as global overrides), otherwise room config applies

0 commit comments

Comments
 (0)