forked from bigbluebutton/greenlight
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 5884_hide_version_number
- Loading branch information
Showing
15 changed files
with
357 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 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/>. | ||
|
||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V1 | ||
class ServerTagsController < ApiController | ||
# GET /api/v1/server_tags/:friendly_id | ||
# Returns a list of all allowed tags&names for the room's owner | ||
def show | ||
tag_names = Rails.configuration.server_tag_names | ||
tag_roles = Rails.configuration.server_tag_roles | ||
return render_data data: {}, status: :ok if tag_names.blank? | ||
|
||
room = Room.find_by(friendly_id: params[:friendly_id]) | ||
return render_data data: {}, status: :ok if room.nil? | ||
|
||
allowed_tag_names = tag_names.reject { |tag, _| tag_roles.key?(tag) && tag_roles[tag].exclude?(room.user.role_id) } | ||
render_data data: allowed_tag_names, status: :ok | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
app/javascript/components/rooms/room/room_settings/ServerTagRow.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// 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 React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import PropTypes from 'prop-types'; | ||
import { | ||
Row, Col, Dropdown, ButtonGroup, ToggleButton, | ||
} from 'react-bootstrap'; | ||
import SimpleSelect from '../../../shared_components/utilities/SimpleSelect'; | ||
|
||
export default function ServerTagRow({ | ||
updateMutation: useUpdateAPI, currentTag, tagRequired, serverTags, description, | ||
}) { | ||
const updateAPI = useUpdateAPI(); | ||
const { t } = useTranslation(); | ||
|
||
function getDefaultTagName() { | ||
return t('room.settings.default_tag_name'); | ||
} | ||
|
||
function getTagName(tag) { | ||
if (tag in serverTags) { | ||
return serverTags[tag]; | ||
} | ||
return getDefaultTagName(); | ||
} | ||
|
||
const dropdownTags = Object.entries(serverTags).map(([tagString, tagName]) => ( | ||
( | ||
<Dropdown.Item | ||
key={tagString} | ||
value={tagName} | ||
onClick={() => updateAPI.mutate({ settingName: 'serverTag', settingValue: tagString })} | ||
> | ||
{tagName} | ||
</Dropdown.Item> | ||
) | ||
)); | ||
|
||
return ( | ||
<Row> | ||
<h6 className="text-brand">{description}</h6> | ||
<Col> | ||
<SimpleSelect defaultValue={getTagName(currentTag)} dropUp> | ||
{[ | ||
<Dropdown.Item | ||
key="" | ||
value={getDefaultTagName()} | ||
disabled={updateAPI.isLoading} | ||
onClick={() => updateAPI.mutate({ settingName: 'serverTag', settingValue: '' })} | ||
> | ||
{getDefaultTagName()} | ||
</Dropdown.Item>, | ||
].concat(dropdownTags)} | ||
</SimpleSelect> | ||
</Col> | ||
<Col> | ||
<ButtonGroup> | ||
<ToggleButton | ||
key="desired" | ||
id="desired" | ||
type="radio" | ||
variant="outline-success" | ||
name="radio" | ||
checked={tagRequired === false} | ||
disabled={updateAPI.isLoading} | ||
onChange={() => { | ||
updateAPI.mutate({ settingName: 'serverTagRequired', settingValue: false }); | ||
}} | ||
> | ||
{t('room.settings.server_tag_desired')} | ||
</ToggleButton> | ||
<ToggleButton | ||
key="required" | ||
id="required" | ||
type="radio" | ||
variant="outline-danger" | ||
name="radio" | ||
checked={tagRequired === true} | ||
disabled={updateAPI.isLoading} | ||
onChange={() => { | ||
updateAPI.mutate({ settingName: 'serverTagRequired', settingValue: true }); | ||
}} | ||
> | ||
{t('room.settings.server_tag_required')} | ||
</ToggleButton> | ||
</ButtonGroup> | ||
</Col> | ||
</Row> | ||
); | ||
} | ||
|
||
ServerTagRow.defaultProps = { | ||
currentTag: '', | ||
tagRequired: false, | ||
}; | ||
|
||
ServerTagRow.propTypes = { | ||
updateMutation: PropTypes.func.isRequired, | ||
currentTag: PropTypes.string, | ||
tagRequired: PropTypes.bool, | ||
serverTags: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types | ||
description: PropTypes.string.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// 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 useServerTags(friendlyId) { | ||
return useQuery( | ||
['getServerTags', friendlyId], | ||
() => axios.get(`/server_tags/${friendlyId}.json`).then((resp) => resp.data.data), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# 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/>. | ||
|
||
# frozen_string_literal: true | ||
|
||
class CreateServerTagsOption < ActiveRecord::Migration[7.0] | ||
def up | ||
MeetingOption.create!(name: 'serverTag', default_value: '') unless MeetingOption.exists?(name: 'serverTag') | ||
tag_option = MeetingOption.find_by!(name: 'serverTag') | ||
MeetingOption.create!(name: 'serverTagRequired', default_value: 'false') unless MeetingOption.exists?(name: 'serverTagRequired') | ||
tag_required_option = MeetingOption.find_by!(name: 'serverTagRequired') | ||
|
||
unless RoomsConfiguration.exists?(meeting_option: tag_option, provider: 'greenlight') | ||
RoomsConfiguration.create!(meeting_option: tag_option, value: 'optional', provider: 'greenlight') | ||
end | ||
unless RoomsConfiguration.exists?(meeting_option: tag_required_option, provider: 'greenlight') | ||
RoomsConfiguration.create!(meeting_option: tag_required_option, value: 'optional', provider: 'greenlight') | ||
end | ||
Tenant.all.each do |tenant| | ||
unless RoomsConfiguration.exists?(meeting_option: tag_option, provider: tenant.name) | ||
RoomsConfiguration.create!(meeting_option: tag_option, value: 'optional', provider: tenant.name) | ||
end | ||
unless RoomsConfiguration.exists?(meeting_option: tag_required_option, provider: tenant.name) | ||
RoomsConfiguration.create!(meeting_option: tag_required_option, value: 'optional', provider: tenant.name) | ||
end | ||
end | ||
|
||
if RoomMeetingOption.exists?(meeting_option: tag_option) || RoomMeetingOption.exists?(meeting_option: tag_required_option) | ||
# slow variant that works with existing tag options | ||
Room.find_each do |room| | ||
RoomMeetingOption.find_or_create_by!(room:, meeting_option: tag_option) | ||
unless RoomMeetingOption.exists?(room:, meeting_option: tag_required_option) | ||
RoomMeetingOption.create!(room:, meeting_option: tag_required_option, value: 'false') | ||
end | ||
end | ||
else | ||
# much faster variant without checks/validation | ||
Room.find_in_batches do |batch| | ||
tag_options_batch = batch.map { |room| { room_id: room.id, meeting_option_id: tag_option.id } } | ||
tag_required_options_batch = batch.map { |room| { room_id: room.id, meeting_option_id: tag_required_option.id, value: 'false' } } | ||
# rubocop:disable Rails/SkipsModelValidations | ||
RoomMeetingOption.insert_all!(tag_options_batch) | ||
RoomMeetingOption.insert_all!(tag_required_options_batch) | ||
# rubocop:enable Rails/SkipsModelValidations | ||
end | ||
end | ||
end | ||
|
||
def down | ||
tag_option = MeetingOption.find_by!(name: 'serverTag') | ||
RoomMeetingOption.destroy_by(meeting_option: tag_option) | ||
RoomsConfiguration.destroy_by(meeting_option: tag_option) | ||
tag_option.destroy | ||
|
||
tag_required_option = MeetingOption.find_by!(name: 'serverTagRequired') | ||
RoomMeetingOption.destroy_by(meeting_option: tag_required_option) | ||
RoomsConfiguration.destroy_by(meeting_option: tag_required_option) | ||
tag_required_option.destroy | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
DataMigrate::Data.define(version: 20240209155229) | ||
DataMigrate::Data.define(version: 20240423162700) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,4 @@ esbuild.context({ | |
}).catch((e) => { | ||
console.error('build failed:', e); | ||
process.exit(1) | ||
}) | ||
}) |
Oops, something went wrong.