forked from External/greenlight
use rails action_name & controller_name methods (#2666)
Co-authored-by: Ahmad Farhat <ahmad.af.farhat@gmail.com>
This commit is contained in:
parent
5eea14a780
commit
81c9e7db10
|
@ -58,18 +58,11 @@ module ApplicationHelper
|
||||||
# Returns 'active' if the current page is the users home page (used to style header)
|
# Returns 'active' if the current page is the users home page (used to style header)
|
||||||
def active_home
|
def active_home
|
||||||
home_actions = %w[show cant_create_rooms]
|
home_actions = %w[show cant_create_rooms]
|
||||||
return "active" if params[:controller] == "admins" && params[:action] == "index" && current_user.has_role?(:super_admin)
|
return "active" if controller_name == "admins" && action_name == "index" && current_user.has_role?(:super_admin)
|
||||||
return "active" if params[:controller] == "rooms" && home_actions.include?(params[:action])
|
return "active" if controller_name == "rooms" && home_actions.include?(action_name)
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the action method of the current page
|
|
||||||
def active_page
|
|
||||||
route = Rails.application.routes.recognize_path(request.env['PATH_INFO'])
|
|
||||||
|
|
||||||
route[:action]
|
|
||||||
end
|
|
||||||
|
|
||||||
def role_colour(role)
|
def role_colour(role)
|
||||||
role.colour || Rails.configuration.primary_color_default
|
role.colour || Rails.configuration.primary_color_default
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,28 +17,28 @@
|
||||||
<% highest_role = current_user.role %>
|
<% highest_role = current_user.role %>
|
||||||
<% highest_role.name %>
|
<% highest_role.name %>
|
||||||
<% if highest_role.get_permission("can_manage_users") || highest_role.name == "super_admin" %>
|
<% if highest_role.get_permission("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 %>
|
<%= link_to admins_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if action_name == "index"}" do %>
|
||||||
<span class="icon nav-icon"><i class="fas fa-users"></i></span><%= t("administrator.users.title") %>
|
<span class="icon nav-icon"><i class="fas fa-users"></i></span><%= t("administrator.users.title") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if highest_role.get_permission("can_manage_rooms_recordings") || highest_role.name == "super_admin" %>
|
<% if highest_role.get_permission("can_manage_rooms_recordings") || highest_role.name == "super_admin" %>
|
||||||
<%= link_to admin_rooms_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "server_rooms"}" do %>
|
<%= link_to admin_rooms_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if action_name == "server_rooms"}" do %>
|
||||||
<span class="icon nav-icon"><i class="fas fa-binoculars"></i></span><%= t("administrator.rooms.title") %>
|
<span class="icon nav-icon"><i class="fas fa-binoculars"></i></span><%= t("administrator.rooms.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 %>
|
<%= link_to admin_recordings_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if action_name == "server_recordings"}" do %>
|
||||||
<span class="icon nav-icon"><i class="fas fa-video"></i></span><%= t("administrator.recordings.title") %>
|
<span class="icon nav-icon"><i class="fas fa-video"></i></span><%= t("administrator.recordings.title") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if highest_role.get_permission("can_edit_site_settings") || highest_role.name == "super_admin" %>
|
<% if highest_role.get_permission("can_edit_site_settings") || highest_role.name == "super_admin" %>
|
||||||
<%= link_to admin_site_settings_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "site_settings"}" do %>
|
<%= link_to admin_site_settings_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if action_name == "site_settings"}" do %>
|
||||||
<span class="icon nav-icon"><i class="fas fa-cogs"></i></span><%= t("administrator.site_settings.title") %>
|
<span class="icon nav-icon"><i class="fas fa-cogs"></i></span><%= t("administrator.site_settings.title") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to admin_room_configuration_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "room_configuration"}" do %>
|
<%= link_to admin_room_configuration_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if action_name == "room_configuration"}" do %>
|
||||||
<span class="icon nav-icon"><i class="fas fa-sliders-h"></i></span><%= t("administrator.room_configuration.title") %>
|
<span class="icon nav-icon"><i class="fas fa-sliders-h"></i></span><%= t("administrator.room_configuration.title") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if highest_role.get_permission("can_edit_roles") || highest_role.name == "super_admin" %>
|
<% if highest_role.get_permission("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 %>
|
<%= link_to admin_roles_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if action_name == "roles"}" do %>
|
||||||
<span class="icon nav-icon"><i class="fas fa-user-tag"></i></span><%= t("administrator.roles.title") %>
|
<span class="icon nav-icon"><i class="fas fa-user-tag"></i></span><%= t("administrator.roles.title") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="app-background" data-controller="<%= params[:controller] %>" data-action="<%= params[:action] %>" data-relative-root="<%= Rails.configuration.relative_url_root || "/" %>">
|
<body class="app-background" data-controller="<%= controller_name %>" data-action="<%= action_name %>" data-relative-root="<%= Rails.configuration.relative_url_root || "/" %>">
|
||||||
<%= render "shared/header" %>
|
<%= render "shared/header" %>
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if current_user.role.get_permission("can_create_rooms") && !current_user.has_role?(:super_admin) && !hide_recording_tables %>
|
<% if current_user.role.get_permission("can_create_rooms") && !current_user.has_role?(:super_admin) && !hide_recording_tables %>
|
||||||
<% all_rec_page = params[:controller] == "users" && params[:action] == "recordings" ? "active" : "" %>
|
<% all_rec_page = controller_name == "users" && action_name == "recordings" ? "active" : "" %>
|
||||||
<%= link_to get_user_recordings_path(current_user), class: "px-3 mx-1 mt-1 header-nav #{all_rec_page}" do %>
|
<%= link_to get_user_recordings_path(current_user), class: "px-3 mx-1 mt-1 header-nav #{all_rec_page}" do %>
|
||||||
<i class="fas fa-video pr-1"></i><span class="d-none d-sm-inline-block"><%= t("header.all_recordings") %></span>
|
<i class="fas fa-video pr-1"></i><span class="d-none d-sm-inline-block"><%= t("header.all_recordings") %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -14,15 +14,15 @@
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<div class="list-group list-group-transparent mb-0">
|
<div class="list-group list-group-transparent mb-0">
|
||||||
<%= link_to edit_user_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "edit"}" do %>
|
<%= link_to edit_user_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if action_name == "edit"}" do %>
|
||||||
<span class="icon mr-3"><i class="fas fa-user"></i></span><%= t("settings.account.title") %>
|
<span class="icon mr-3"><i class="fas fa-user"></i></span><%= t("settings.account.title") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if current_user.greenlight_account? %>
|
<% if current_user.greenlight_account? %>
|
||||||
<%= link_to change_password_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "change_password"}" do %>
|
<%= link_to change_password_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if action_name == "change_password"}" do %>
|
||||||
<span class="icon mr-3"><i class="fas fa-key"></i></span><%= t("settings.password.title") %>
|
<span class="icon mr-3"><i class="fas fa-key"></i></span><%= t("settings.password.title") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to delete_account_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "delete_account"}" do %>
|
<%= link_to delete_account_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if action_name == "delete_account"}" do %>
|
||||||
<span class="icon mr-3"><i class="fas fa-trash-alt"></i></span><%= t("settings.delete.title") %>
|
<span class="icon mr-3"><i class="fas fa-trash-alt"></i></span><%= t("settings.delete.title") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
Loading…
Reference in New Issue