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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Introduce PageHeader in Administration / Users
Henriette Darge0fc94fa9e872
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rbindex 399fab97ab0..4e31de0aa5a 100644--- a/app/controllers/users_controller.rb+++ b/app/controllers/users_controller.rb@@ -282,16 +282,8 @@ class UsersController < ApplicationControllerprotected- def default_breadcrumb- if action_name == "index"- t("label_user_plural")- else- ActionController::Base.helpers.link_to(t("label_user_plural"), users_path)- end- end-def show_local_breadcrumb- can_manage_or_create_users? && action_name != "show"+ falseenddef build_user_update_paramsdiff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rbindex 9c79821c750..9e1eeaf10c2 100644--- a/app/helpers/users_helper.rb+++ b/app/helpers/users_helper.rb@@ -87,41 +87,51 @@ module UsersHelper# Create buttons to lock/unlock a user and reset failed loginsdef build_change_user_status_action(user)+ result = "".html_safe+ iterate_user_statusses(user) do |title, name|+ result << ((yield title, name) + " ".html_safe)+ end+ result+ end++ def iterate_user_statusses(user)status = user.status.to_symblocked = !!user.failed_too_many_recent_login_attempts?- result = "".html_safe(STATUS_CHANGE_ACTIONS[[status, blocked]] || []).each do |title, name|- result << ((yield I18n.t(title, scope: :user), name) + " ".html_safe)+ yield I18n.t(title, scope: :user), nameend- resultenddef change_user_status_icons{- "unlock" => "unlocked",- "activate" => "unlocked",- "lock" => "locked"+ "unlock" => "unlock",+ "activate" => "unlock",+ "lock" => "lock"}enddef change_user_status_buttons(user)build_change_user_status_action(user) do |title, name|- button_tag(class: "button", name:, type: "submit", title:) do- concat op_icon("button--icon icon-#{change_user_status_icons[name]}")- concat content_tag(:span, title, class: "button--text")+ Primer::Beta::Button.new(name:, type: :submit, title:) do |button|+ button.with_leading_visual_icon(icon: change_user_status_icons[name])+ titleendendenddef change_user_status_links(user)build_change_user_status_action(user) do |title, name|- link_to title,- change_status_user_path(user,- name.to_sym => "1",- back_url: request.fullpath),- method: :post,- class: "icon icon-#{change_user_status_icons[name]}"+ render Primer::Beta::Button.new(tag: :a,+ scheme: :link,+ title:,+ href: change_status_user_path(user,+ name.to_sym => "1",+ back_url: request.fullpath),+ method: :post) do |button|+ button.with_leading_visual_icon(icon: change_user_status_icons[name])+ title+ endendenddiff --git a/app/views/users/_toolbar.html.erb b/app/views/users/_toolbar.html.erbindex 1f6b49fad53..4d6dd0665a6 100644--- a/app/views/users/_toolbar.html.erb+++ b/app/views/users/_toolbar.html.erb@@ -26,42 +26,70 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.See COPYRIGHT and LICENSE files for more details.++#%>-<%= breadcrumb_toolbar(@user.name) do %>- <li class="toolbar-item">- <%= link_to user_path(@user), class: 'button' do %>- <%= op_icon('button--icon icon-user') %>- <span class="button--text"><%= t(:label_profile) %></span>- <% end %>- </li>- <% if current_user.allowed_globally?(:create_user) %>- <li class="toolbar-item hidden-for-tablet">- <%= form_for(@user,- url: { action: :resend_invitation },- method: :post) do |_form| %>- <button class="button" title="<%= t(:tooltip_resend_invitation) %>">- <%= op_icon('button--icon icon-mail1') %>- <span class="button--text"><%= t(:label_send_invitation) %></span>- </button>- <% end %>- </li>- <% end %>- <% if current_user.admin? %>- <% unless current_user.id == @user.id %>- <li class="toolbar-item">- <%= form_for @user,- :url => { :action => :change_status },- :method => :post do %>- <%= change_user_status_buttons(@user) %>- <% end %>- </li>- <% end %>- <% if Setting.users_deletable_by_admins? %>- <li class="toolbar-item">- <%= link_to deletion_info_user_path(@user), class: 'button' do %>- <%= op_icon('button--icon icon-delete') %>- <span class="button--text"><%= t(:button_delete) %></span>- <% end %>- </li>- <% end %>- <% end %>-<% end %>+<%=+ render(Primer::OpenProject::PageHeader.new) do |header|+ header.with_title { @user.name }+ header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },+ { href: admin_settings_users_path, text: t(:label_user_and_permission) },+ { href: users_path, text: t(:label_user_plural) },+ @user.name])++ header.with_action_button(tag: :a,+ mobile_icon: :person,+ mobile_label: t(:label_profile),+ size: :medium,+ href: user_path(@user),+ aria: { label: I18n.t(:label_profile) },+ title: I18n.t(:label_profile)) do |button|+ button.with_leading_visual_icon(icon: :person)+ t(:label_profile)+ end++ if current_user.allowed_globally?(:create_user)+ header.with_action_button(tag: :a,+ mobile_icon: :mail,+ mobile_label: t(:label_send_invitation),+ size: :medium,+ href: resend_invitation_user_path(@user),+ data: { method: :post },+ aria: { label: I18n.t(:label_send_invitation) },+ title: I18n.t(:tooltip_resend_invitation)) do |button|+ button.with_leading_visual_icon(icon: :mail)+ t(:label_send_invitation)+ end+ end++ if current_user.admin?+ unless current_user.id == @user.id+ iterate_user_statusses(@user) do |title, name|+ header.with_action_button(tag: :a,+ mobile_icon: change_user_status_icons[name],+ mobile_label: title,+ size: :medium,+ name: name,+ href: change_status_user_path(@user, { name => '' }),+ data: { method: :post },+ aria: { label: title },+ title: title) do |button|+ button.with_leading_visual_icon(icon: change_user_status_icons[name])+ title+ end+ end+ end++ if Setting.users_deletable_by_admins?+ header.with_action_button(tag: :a,+ scheme: :danger,+ mobile_icon: :trash,+ mobile_label: t(:button_delete),+ size: :medium,+ href: deletion_info_user_path(@user),+ aria: { label: I18n.t(:button_delete) },+ title: I18n.t(:button_delete)) do |button|+ button.with_leading_visual_icon(icon: :trash)+ t(:button_delete)+ end+ end+ end+ end+%>diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erbindex a89e6798772..37666bcc376 100644--- a/app/views/users/edit.html.erb+++ b/app/views/users/edit.html.erb@@ -30,7 +30,6 @@ See COPYRIGHT and LICENSE files for more details.<% html_title(t(:label_administration), "#{t(:label_edit)} #{User.model_name.human} #{h(@user.name)}") -%>-<% local_assigns[:additional_breadcrumb] = @user.name %><%= render partial: 'toolbar', locals: { new_user: false } %><%= render_extensible_tabs :user, user: @user %>diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erbindex 0e5b25f666b..1f771901ec0 100644--- a/app/views/users/index.html.erb+++ b/app/views/users/index.html.erb@@ -38,21 +38,38 @@ See COPYRIGHT and LICENSE files for more details.<% users_info = user_limit && content_tag(:div) do %><%= t(:label_enterprise_active_users, current: OpenProject::Enterprise.active_user_count, limit: user_limit) %> - <a href="<%= OpenProject::Enterprise.upgrade_path %>" class="display-inline button -tiny -primary" title="<%= t(:title_enterprise_upgrade) %>"><%= t(:button_upgrade) %></a>-<% end %>-<%= toolbar title: t(:label_user_plural), title_class: 'no-padding-bottom', subtitle: users_info do %>- <li class="toolbar-item">- <%= link_to new_user_path,- { class: 'button -primary',- aria: { label: t(:label_user_new) },- title: t(:label_user_new) } do %>- <%= op_icon('button--icon icon-add') %>- <span class="button--text"><%= t('activerecord.models.user') %></span>- <% end %>- </li>- <%= call_hook(:user_admin_action_menu) %>+ <%= render(Primer::Beta::Button.new(scheme: :primary,+ size: :small,+ tag: :a,+ href: OpenProject::Enterprise.upgrade_path,+ title: t(:title_enterprise_upgrade))) { t(:button_upgrade) } %><% end %>-<%= render Users::UserFilterComponent.new(params, groups: @groups, status: @status) %>+<%=+ render(Primer::OpenProject::PageHeader.new) do |header|+ header.with_title { t(:label_user_plural) }+ header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },+ { href: admin_settings_users_path, text: t(:label_user_and_permission) },+ t(:label_user_plural)])+ header.with_description { users_info } if user_limit+ end+%>++<%=+ render(Primer::OpenProject::SubHeader.new) do |subheader|+ subheader.with_action_button(scheme: :primary,+ aria: { label: I18n.t(:label_user_new) },+ title: I18n.t(:label_user_new),+ tag: :a,+ href: new_user_path) do |button|+ button.with_leading_visual_icon(icon: :plus)+ t('activerecord.models.user')+ end++ subheader.with_bottom_pane_component do+ render Users::UserFilterComponent.new(params, groups: @groups, status: @status)+ end+ end+%> <%= render Users::TableComponent.new(rows: @users, current_user: ) %>diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erbindex 09a6e9bba2e..8703e31406d 100644--- a/app/views/users/new.html.erb+++ b/app/views/users/new.html.erb@@ -28,9 +28,17 @@ See COPYRIGHT and LICENSE files for more details.++#%><% html_title t(:label_administration), t("label_user_new") %>-<% local_assigns[:additional_breadcrumb] = t(:label_user_new) %>-<%= toolbar title: t(:label_user_new) %>++<%=+ render(Primer::OpenProject::PageHeader.new) do |header|+ header.with_title { t(:label_user_new) }+ header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },+ { href: admin_settings_users_path, text: t(:label_user_and_permission) },+ { href: users_path, text: t(:label_user_plural) },+ t(:label_user_new)])+ end+%><%= error_messages_for @user %>diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erbindex 1dbf16cc1df..0ffe38b5f8a 100644--- a/app/views/users/show.html.erb+++ b/app/views/users/show.html.erb@@ -39,7 +39,7 @@ See COPYRIGHT and LICENSE files for more details.header.with_breadcrumbs([{ href: users_path, text: t(:label_user_plural) },- { href: user_path(@user), text: @user.name }+ @user.name])if current_user.allowed_globally?(:manage_user)@@ -57,7 +57,7 @@ See COPYRIGHT and LICENSE files for more details.if current_user.allowed_globally?(:create_user) && current_user != @userheader.with_action_button(tag: :a,- mobile_icon: :pencil,+ mobile_icon: :mail,mobile_label: t(:label_send_invitation),size: :medium,href: resend_invitation_user_path(@user),