forked from External/greenlight
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 comments
This commit is contained in:
committed by
Jesus Federico
parent
02b342b157
commit
4fc1714db8
@ -14,13 +14,24 @@
|
||||
%>
|
||||
|
||||
<div class="list-group list-group-transparent mb-0">
|
||||
<%= link_to admins_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "index"}" do %>
|
||||
<span class="icon mr-3"><i class="fas fa-users"></i></span><%= t("administrator.users.title") %>
|
||||
<% highest_role = current_user.highest_priority_role %>
|
||||
<% highest_role.name %>
|
||||
<% if highest_role.can_manage_users || highest_role.name == "super_admin" %>
|
||||
<%= link_to admins_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "index"}" do %>
|
||||
<span class="icon mr-3"><i class="fas fa-users"></i></span><%= t("administrator.users.title") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= link_to admin_site_settings_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "site_settings"}" do %>
|
||||
<span class="icon mr-4"><i class="fas fa-cogs"></i></span><%= t("administrator.site_settings.title") %>
|
||||
<% if highest_role.can_edit_site_settings || highest_role.name == "super_admin" %>
|
||||
<%= link_to admin_recordings_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "server_recordings"}" do %>
|
||||
<span class="icon mr-4"><i class="fas fa-video"></i></i></span><%= t("administrator.recordings.title") %>
|
||||
<% end %>
|
||||
<%= link_to admin_site_settings_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "site_settings"}" do %>
|
||||
<span class="icon mr-4"><i class="fas fa-cogs"></i></span><%= t("administrator.site_settings.title") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= link_to admin_recordings_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "server_recordings"}" do %>
|
||||
<span class="icon mr-4"><i class="fas fa-video"></i></i></span><%= t("administrator.recordings.title") %>
|
||||
<% if highest_role.can_edit_roles || highest_role.name == "super_admin" %>
|
||||
<%= link_to admin_roles_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "roles"}" do %>
|
||||
<span class="icon mr-4"><i class="fas fa-user-tag"></i></i></span><%= t("administrator.roles.title") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
94
app/views/admins/components/_roles.html.erb
Normal file
94
app/views/admins/components/_roles.html.erb
Normal file
@ -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 %>
|
||||
|
||||
<%= f.hidden_field :colour, id: "role-colour", value: role_colour(@selected_role) %>
|
||||
<div class="form-group">
|
||||
<label class="form-label"><%= t("administrator.roles.colour.title") %></label>
|
||||
<label class="form-label text-muted"><%= t("administrator.roles.colour.info") %></label>
|
||||
<div class="color-inputs">
|
||||
<div id="role-colorinput-regular" class="btn role-colour-picker" data-disabled="<%= edit_disabled %>" data-colour="<%= role_colour(@selected_role) %>">
|
||||
<%= t("administrator.site_settings.color.regular") %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
|
||||
<span class="ml-0 custom-switch-description"><%= t("administrator.roles.can_create_rooms")%></span>
|
||||
<%= f.check_box :can_create_rooms, class: "custom-switch-input", disabled: edit_disabled %>
|
||||
<span class="custom-switch-indicator float-right"></span>
|
||||
</label>
|
||||
<label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
|
||||
<span class="ml-0 custom-switch-description"><%= t("administrator.roles.promote_email")%></span>
|
||||
<%= f.check_box :send_promoted_email, class: "custom-switch-input", disabled: edit_disabled %>
|
||||
<span class="custom-switch-indicator float-right"></span>
|
||||
</label>
|
||||
<label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
|
||||
<span class="ml-0 custom-switch-description"><%= t("administrator.roles.demote_email")%></span>
|
||||
<%= f.check_box :send_demoted_email, class: "custom-switch-input", disabled: edit_disabled %>
|
||||
<span class="custom-switch-indicator float-right"></span>
|
||||
</label>
|
||||
<label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
|
||||
<span class="ml-0 custom-switch-description"><%= t("administrator.roles.edit_site_settings")%></span>
|
||||
<%= f.check_box :can_edit_site_settings, class: "custom-switch-input", disabled: edit_disabled %>
|
||||
<span class="custom-switch-indicator float-right"></span>
|
||||
</label>
|
||||
<label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
|
||||
<span class="ml-0 custom-switch-description"><%= t("administrator.roles.edit_roles")%></span>
|
||||
<%= f.check_box :can_edit_roles, class: "custom-switch-input", disabled: edit_disabled %>
|
||||
<span class="custom-switch-indicator float-right"></span>
|
||||
</label>
|
||||
<label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
|
||||
<span class="ml-0 custom-switch-description"><%= t("administrator.roles.manage_users")%></span>
|
||||
<%= f.check_box :can_manage_users, class: "custom-switch-input", disabled: edit_disabled %>
|
||||
<span class="custom-switch-indicator float-right"></span>
|
||||
</label>
|
||||
|
||||
<div class="mt-4">
|
||||
<%= f.submit t("update"), class: "btn btn-primary float-right ml-2 mb-2", disabled: edit_disabled %>
|
||||
<% if @selected_role.name != "user" && @selected_role.name != "admin" && !edit_disabled %>
|
||||
<%= link_to admin_delete_role_path(@selected_role.id), method: :delete, class: "float-right btn btn-danger" do %>
|
||||
<%= t("administrator.roles.delete") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "shared/modals/create_role_modal" %>
|
@ -28,7 +28,7 @@
|
||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
%>
|
||||
|
||||
<% if @role.present? %>
|
||||
<% unless @role.nil? %>
|
||||
<%= render "shared/components/admins_tags" %>
|
||||
<% end %>
|
||||
|
||||
@ -88,7 +88,7 @@
|
||||
<td><%= user.provider %></td>
|
||||
<td class="text-center">
|
||||
<% roles = user.roles().pluck(:name) %>
|
||||
<%= render "shared/components/admins_role", roles: roles %>
|
||||
<%= render "shared/components/admins_role", role: user.highest_priority_role %>
|
||||
</td>
|
||||
<td>
|
||||
<% if roles.include?("pending") %>
|
||||
@ -122,16 +122,6 @@
|
||||
<button class= "delete-user dropdown-item" data-toggle="modal" data-target="#deleteAccountModal">
|
||||
<i class="dropdown-icon fas fa-user-minus"></i> <%= t("administrator.users.settings.delete") %>
|
||||
</button>
|
||||
|
||||
<% if roles.include?("admin") %>
|
||||
<%= button_to admin_demote_path(user_uid: user.uid), class: "dropdown-item" do %>
|
||||
<i class="dropdown-icon fas fa-level-down-alt"></i> <%= t("administrator.users.settings.demote") %>
|
||||
<% end %>
|
||||
<% elsif roles.include?("user") %>
|
||||
<%= button_to admin_promote_path(user_uid: user.uid), class: "dropdown-item" do %>
|
||||
<i class="dropdown-icon fas fa-level-up-alt"></i> <%= t("administrator.users.settings.promote") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= button_to admin_ban_path(user_uid: user.uid), class: "dropdown-item" do %>
|
||||
<i class="dropdown-icon fas fa-lock"></i> <%= t("administrator.users.settings.ban") %>
|
||||
<% end %>
|
||||
|
27
app/views/admins/roles.html.erb
Normal file
27
app/views/admins/roles.html.erb
Normal file
@ -0,0 +1,27 @@
|
||||
<%
|
||||
# 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 pt-6">
|
||||
<%= render "shared/components/subtitle", subtitle: t("administrator.title"), search: false %>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-3 mb-4">
|
||||
<%= render "admins/components/menu_buttons" %>
|
||||
</div>
|
||||
<div class="col-lg-9">
|
||||
<%= render "admins/components/setting_view", setting_id: "roles", setting_title: t("administrator.roles.title"), search: false %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Reference in New Issue
Block a user