GRN2-176: Create a role editor that allows admins to specify what permissions each role has (#709)
* Add roles editor * Add colour selection ability to roles * Add ability to assign roles to users in the UI * Remove rolify and replace it with our own custom roles implemenation * - Fix all existing roles functionality - Fix super admins * Fix bugs with new customers not have default roles * Add can't create room setting * Code improvements * Fix migration * Add tests for new methods * Translate reserved role names * Pull roles from saml/ldap * Fix rspec * Fix scrutinizer issues * Fix email promoted/demoted tests * Apply comments * Redirect directly to the main room * Add commentsv2
parent
02b342b157
commit
4fc1714db8
@ -0,0 +1,88 @@ |
||||
// BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
|
||||
//
|
||||
// Copyright (c) 2018 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.
|
||||
//
|
||||
// BigBlueButton 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 BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$(document).on('turbolinks:load', function(){ |
||||
var controller = $("body").data('controller'); |
||||
var action = $("body").data('action'); |
||||
if ((controller == "admins" && action == "edit_user") || (controller == "users" && action == "edit")) { |
||||
$(".setting-btn").click(function(data){ |
||||
var url = $("body").data("relative-root") |
||||
if (!url.endsWith("/")) { |
||||
url += "/" |
||||
} |
||||
url += "admins?setting=" + data.target.id |
||||
|
||||
window.location.href = url |
||||
}) |
||||
|
||||
// Clear the role when the user clicks the x
|
||||
$(".clear-role").click(clearRole) |
||||
|
||||
// When the user selects an item in the dropdown add the role to the user
|
||||
$("#role-select-dropdown").change(function(data){ |
||||
var dropdown = $("#role-select-dropdown"); |
||||
var select_role_id = dropdown.val(); |
||||
|
||||
if(select_role_id){ |
||||
// Disable the role in the dropdown
|
||||
var selected_role = dropdown.find('[value=\"' + select_role_id + '\"]'); |
||||
selected_role.prop("disabled", true) |
||||
|
||||
// Add the role tag
|
||||
var tag_container = $("#role-tag-container"); |
||||
tag_container.append("<span id=\"user-role-tag_" + select_role_id + "\" style=\"background-color:" + selected_role.data("colour") + ";\" class=\"tag\">" +
|
||||
selected_role.text() + "<a data-role-id=\"" + select_role_id + "\" class=\"tag-addon clear-role\"><i data-role-id=\"" + select_role_id + "\" class=\"fas fa-times\"></i></a></span>"); |
||||
|
||||
// Update the role ids input that gets submited on user update
|
||||
var role_ids = $("#user_role_ids").val() |
||||
role_ids += " " + select_role_id |
||||
$("#user_role_ids").val(role_ids) |
||||
|
||||
// Add the clear role function to the tag
|
||||
$("#user-role-tag_" + select_role_id).click(clearRole); |
||||
|
||||
// Reset the dropdown
|
||||
dropdown.val(null) |
||||
} |
||||
}) |
||||
} |
||||
}) |
||||
|
||||
// This function removes the specfied role from a user
|
||||
function clearRole(data){ |
||||
// Get the role id
|
||||
var role_id = $(data.target).data("role-id"); |
||||
var role_tag = $("#user-role-tag_" + role_id); |
||||
|
||||
// Remove the role tag
|
||||
$(role_tag).remove() |
||||
|
||||
// Update the role ids input
|
||||
var role_ids = $("#user_role_ids").val() |
||||
var parsed_ids = role_ids.split(' ') |
||||
|
||||
var index = parsed_ids.indexOf(role_id.toString()); |
||||
|
||||
if (index > -1) { |
||||
parsed_ids.splice(index, 1); |
||||
} |
||||
|
||||
$("#user_role_ids").val(parsed_ids.join(' ')) |
||||
|
||||
// Enable the role in the role select dropdown
|
||||
var selected_role = $("#role-select-dropdown").find('[value=\"' + role_id + '\"]'); |
||||
selected_role.prop("disabled", false) |
||||
} |
@ -0,0 +1,94 @@ |
||||
<% |
||||
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/. |
||||
# Copyright (c) 2018 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. |
||||
# |
||||
# BigBlueButton 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 BigBlueButton; if not, see <http://www.gnu.org/licenses/>. |
||||
%> |
||||
|
||||
<div class="container"> |
||||
<div class="row"> |
||||
<div class="col-lg-3 mb-4"> |
||||
<div class="list-group list-group-transparent mb-0"> |
||||
<div id="rolesSelect" data-url="<%= admin_roles_order_path %>"> |
||||
<% @roles.each do |role| %> |
||||
<%= link_to admin_roles_path(selected_role: role.id), |
||||
class: "#{"sort-disabled" if role.name == "user" || role.name == "admin" || role.priority <= current_user.highest_priority_role.priority } dropdown-item list-group-item list-group-item-action #{"active" if @selected_role.id == role.id}", |
||||
id: dom_id(role) do %> |
||||
<%= translated_role_name(role) %> |
||||
<% end %> |
||||
<% end %> |
||||
</div> |
||||
<%= link_to "#", id: "newRoleButton", class: "list-group-item list-group-item-action", "data-toggle" => "modal", "data-target" => '#createRoleModal' do %> |
||||
<span class="icon mr-4"><i class="fas fa-plus-circle"></i></span><%= t("administrator.roles.new_role") %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
<div class="col-lg-9 <%="form-disable" if edit_disabled %>"> |
||||
<%= form_for(@selected_role, url: admin_update_role_path(@selected_role.id), method: :post) do |f| %> |
||||
<%= f.label t('administrator.roles.name'), class: "form-label" %> |
||||
<%= f.text_field :name, class: 'form-control mb-3', value: translated_role_name(@selected_role), readonly: edit_disabled || @selected_role.name == "user" || @selected_role.name == "admin", required: true %> |
||||
|
||||