Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add breadcrumb toolbar to the show page and render in Admin Layout when possible

Klaus Zanders0cd2152b310f
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index c29f484e9d1..3cc6597e7e4 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -72,7 +72,7 @@ class UsersController < ApplicationController
if can_show_user?
@events = events
- render layout: 'no_menu'
+ render layout: (can_manage_or_create_users? ? 'admin' : 'no_menu')
else
render_404
end
@@ -232,14 +232,18 @@ class UsersController < ApplicationController
private
def can_show_user?
- return true if current_user.allowed_to_globally?(:manage_user)
- return true if current_user.allowed_to_globally?(:create_user)
+ return true if can_manage_or_create_users?
return true if @user == User.current
(@user.active? || @user.registered?) \
&& (@memberships.present? || events.present?)
end
+ def can_manage_or_create_users?
+ current_user.allowed_to_globally?(:manage_user) ||
+ current_user.allowed_to_globally?(:create_user)
+ end
+
def events
@events ||= Activities::Fetcher.new(User.current, author: @user).events(limit: 10)
end
@@ -304,7 +308,7 @@ class UsersController < ApplicationController
end
def show_local_breadcrumb
- action_name != 'show'
+ true
end
def build_user_update_params
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index fd95abc092d..19d1534ff20 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -29,8 +29,9 @@ See COPYRIGHT and LICENSE files for more details.
<% content_for :header_tags do %>
<%= call_hook :users_show_head %>
<% end %>
+<% local_assigns[:additional_breadcrumb] = @user.name %>
<% html_title t(:label_administration), t(:label_user_plural) -%>
-<%= toolbar title: "#{avatar @user} #{h(@user.name)}".html_safe do %>
+<%= breadcrumb_toolbar "#{avatar @user} #{h(@user.name)}".html_safe do %>
<% if User.current.allowed_to_globally?(:manage_user) %>
<li class="toolbar-item">
<%= link_to edit_user_path(@user), class: 'button', accesskey: accesskey(:edit) do %>