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

Introduce PageHeader in Administration / Roles

Henriette Dargef7eccde66a96
diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb
index c7daac6c37d..6581a1910fb 100644
--- a/app/controllers/admin/settings_controller.rb
+++ b/app/controllers/admin/settings_controller.rb
@@ -81,6 +81,11 @@ module Admin
end
end
+ def breadcrumb_items
+ [{ href: admin_index_path, text: t("label_administration") }]
+ end
+ helper_method :breadcrumb_items
+
protected
def find_plugin
diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb
index 893c2686653..ecc09f416da 100644
--- a/app/controllers/roles_controller.rb
+++ b/app/controllers/roles_controller.rb
@@ -143,16 +143,8 @@ class RolesController < ApplicationController
Role.visible.ordered_by_builtin_and_position
end
- def default_breadcrumb
- if action_name == "index"
- t("label_role_plural")
- else
- ActionController::Base.helpers.link_to(t("label_role_plural"), roles_path)
- end
- end
-
def show_local_breadcrumb
- true
+ false
end
def new_params
diff --git a/app/views/roles/edit.html.erb b/app/views/roles/edit.html.erb
index 039cff632ad..97015ff71a9 100644
--- a/app/views/roles/edit.html.erb
+++ b/app/views/roles/edit.html.erb
@@ -29,8 +29,15 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title t(:label_administration), "#{t(:label_edit)} #{Role.model_name.human} #{@role.name}" %>
-<% local_assigns[:additional_breadcrumb] = @role.name %>
-<%= breadcrumb_toolbar @role.name %>
+<%=
+ render Primer::OpenProject::PageHeader.new do |header|
+ header.with_title { @role.name }
+ header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },
+ { href: admin_settings_users_path, text: t(:label_user_and_permission) },
+ { href: roles_path, text: t(:label_role_and_permissions) },
+ @role.name])
+ end
+%>
<%= labelled_tabular_form_for @role, :url => { :action => 'update' }, :html => {:id => 'role_form'}, :as => :role do |f| %>
<%= hidden_field_tag :id, @role.id %>
diff --git a/app/views/roles/index.html.erb b/app/views/roles/index.html.erb
index 26d4fe75c5a..2e03178fbcf 100644
--- a/app/views/roles/index.html.erb
+++ b/app/views/roles/index.html.erb
@@ -27,17 +27,28 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<% html_title t(:label_administration), t("label_role_plural") %>
-<%= toolbar title: Role.model_name.human(count: 2) do %>
- <li class="toolbar-item">
- <%= link_to({ action: 'new'},
- { class: 'button -primary',
- aria: {label: t(:label_role_new)},
- title: t(:label_role_new)}) do %>
- <%= op_icon('button--icon icon-add') %>
- <span class="button--text"><%= Role.model_name.human %></span>
- <% end %>
- </li>
-<% end %>
+
+<%=
+ render Primer::OpenProject::PageHeader.new do |header|
+ header.with_title { Role.model_name.human(count: 2) }
+ header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },
+ { href: admin_settings_users_path, text: t(:label_user_and_permission) },
+ t(:label_role_and_permissions)])
+ end
+%>
+
+<%=
+ render(Primer::OpenProject::SubHeader.new) do |subheader|
+ subheader.with_action_button(scheme: :primary,
+ aria: { label: I18n.t(:label_role_new) },
+ title: I18n.t(:label_role_new),
+ tag: :a,
+ href: new_role_path) do |button|
+ button.with_leading_visual_icon(icon: :plus)
+ Role.model_name.human
+ end
+ end
+%>
<div class="generic-table--container">
<div class="generic-table--results-container">
diff --git a/app/views/roles/new.html.erb b/app/views/roles/new.html.erb
index 8907c98bcdc..36309d96853 100644
--- a/app/views/roles/new.html.erb
+++ b/app/views/roles/new.html.erb
@@ -29,8 +29,15 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title t(:label_administration), t(:label_role_new) %>
-<% local_assigns[:additional_breadcrumb] = t(:label_role_new) %>
-<%= breadcrumb_toolbar t(:label_role_new) %>
+<%=
+ render Primer::OpenProject::PageHeader.new do |header|
+ header.with_title { I18n.t(:label_role_new) }
+ header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },
+ { href: admin_settings_users_path, text: t(:label_user_and_permission) },
+ { href: roles_path, text: t(:label_role_and_permissions) },
+ I18n.t(:label_role_new)])
+ end
+%>
<%= labelled_tabular_form_for @role, :url => { :action => 'create' }, :html => {:id => 'role_form'}, :as => :role do |f| %>
<%= render partial: 'form', locals: { f: f, role: @role, roles: @roles } %>
diff --git a/app/views/roles/report.html.erb b/app/views/roles/report.html.erb
index 0377d2cb95f..04a9452ba5a 100644
--- a/app/views/roles/report.html.erb
+++ b/app/views/roles/report.html.erb
@@ -26,8 +26,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>
-<%= breadcrumb_toolbar t(:label_permissions_report) %>
-<% local_assigns[:additional_breadcrumb] = t(:label_permissions_report) %>
+
+
+<%=
+ render Primer::OpenProject::PageHeader.new do |header|
+ header.with_title { I18n.t(:label_permissions_report) }
+ header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },
+ { href: admin_settings_users_path, text: t(:label_user_and_permission) },
+ t(:label_permissions_report)])
+ end
+%>
+
<% html_title t(:label_administration), t(:label_permissions_report) %>
<% (@calls || []).select(&:failure?).each do |call| %>
diff --git a/modules/avatars/app/controllers/avatars/avatar_controller.rb b/modules/avatars/app/controllers/avatars/avatar_controller.rb
index e76b67ea3b5..7ebb65ed004 100644
--- a/modules/avatars/app/controllers/avatars/avatar_controller.rb
+++ b/modules/avatars/app/controllers/avatars/avatar_controller.rb
@@ -15,6 +15,14 @@ module ::Avatars
head :not_found
end
+ def breadcrumb_items
+ [{ href: admin_index_path, text: t("label_administration") },
+ { href: admin_settings_users_path, text: t(:label_user_settings) },
+ @plugin.name]
+ end
+
+ helper_method :breadcrumb_items
+
private
def find_avatar