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 component in Administration -> user settings -> Placeholder users

Henriette Darge4f941dfda091
diff --git a/app/controllers/placeholder_users_controller.rb b/app/controllers/placeholder_users_controller.rb
index 9936ed29032..e60daf4047f 100644
--- a/app/controllers/placeholder_users_controller.rb
+++ b/app/controllers/placeholder_users_controller.rb
@@ -158,16 +158,7 @@ class PlaceholderUsersController < ApplicationController
end
end
- def default_breadcrumb
- if action_name == "index"
- t("label_placeholder_user_plural")
- else
- ActionController::Base.helpers.link_to(t("label_placeholder_user_plural"),
- placeholder_users_path)
- end
- end
-
def show_local_breadcrumb
- action_name != "show"
+ false
end
end
diff --git a/app/helpers/tabs_helper.rb b/app/helpers/tabs_helper.rb
index 46a130caca4..64370492b4d 100644
--- a/app/helpers/tabs_helper.rb
+++ b/app/helpers/tabs_helper.rb
@@ -41,12 +41,6 @@ module TabsHelper
tabs.detect { |t| t[:name] == params[:tab] } || tabs.first
end
- # Render tabs from the ui/extensible tabs manager
- def render_extensible_tabs(key, params = {})
- tabs = tabs_for_key(key, params)
- render_tabs(tabs)
- end
-
def tabs_for_key(key, params = {})
::OpenProject::Ui::ExtensibleTabs.enabled_tabs(key, params.reverse_merge(current_user:)).map do |tab|
path = tab[:path].respond_to?(:call) ? instance_exec(params, &tab[:path]) : tab[:path]
diff --git a/app/views/placeholder_users/_toolbar.html.erb b/app/views/placeholder_users/_toolbar.html.erb
index 47de2c2c7ae..d969dec61a2 100644
--- a/app/views/placeholder_users/_toolbar.html.erb
+++ b/app/views/placeholder_users/_toolbar.html.erb
@@ -26,14 +26,51 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>
-<%= breadcrumb_toolbar(@placeholder_user.new_record? ? t(:label_placeholder_user_new) : @placeholder_user.name) do %>
- <% unless @placeholder_user.new_record? %>
- <li class="toolbar-item">
- <%= link_to placeholder_user_path(@placeholder_user), class: 'button' do %>
- <%= op_icon('button--icon icon-user') %>
- <span class="button--text"><%= t(:label_profile) %></span>
- <% end %>
- </li>
- <%= render partial: 'placeholder_users/toolbar_delete' %>
- <% end %>
-<% end %>
+<% title = @placeholder_user.new_record? ? t(:label_placeholder_user_new) : @placeholder_user.name %>
+<% deletable = can_delete_placeholder_user?(@placeholder_user) %>
+
+<%=
+ render(Primer::OpenProject::PageHeader.new) do |header|
+ header.with_title { title }
+ header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },
+ { href: admin_settings_users_path, text: t(:label_user_and_permission) },
+ { href: placeholder_users_path, text: t(:label_placeholder_user_plural) },
+ title])
+
+ unless @placeholder_user.new_record?
+ header.with_action_button(tag: :a,
+ mobile_icon: :person,
+ mobile_label: t(:label_profile),
+ size: :medium,
+ href: placeholder_user_path(@placeholder_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
+
+ header.with_action_button(tag: :a,
+ scheme: :danger,
+ mobile_icon: :trash,
+ mobile_label: t(:button_delete),
+ size: :medium,
+ disabled: !deletable,
+ href: deletable ? deletion_info_placeholder_user_path(@placeholder_user) : "#",
+ aria: { label: I18n.t(:button_delete) },
+ title: deletable ?
+ I18n.t(:button_delete) :
+ I18n.t("placeholder_users.right_to_manage_members_missing")) do |button|
+ button.with_leading_visual_icon(icon: :trash)
+ t(:button_delete)
+ end
+ end
+
+ header.with_tab_nav(label: nil) do |tab_nav|
+ tabs.each do |tab|
+ tab_nav.with_tab(selected: selected_tab(tabs) == tab, href: tab[:path]) do |t|
+ t.with_text { I18n.t("js.#{tab[:label]}") }
+ end
+ end
+ end if tabs.present?
+ end
+%>
diff --git a/app/views/placeholder_users/edit.html.erb b/app/views/placeholder_users/edit.html.erb
index ebd3833c0ba..6ddccd074d6 100644
--- a/app/views/placeholder_users/edit.html.erb
+++ b/app/views/placeholder_users/edit.html.erb
@@ -30,7 +30,12 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title(t(:label_administration), "#{t(:label_edit)} #{PlaceholderUser.model_name.human} #{h(@placeholder_user.name)}") -%>
-<% local_assigns[:additional_breadcrumb] = @placeholder_user.name %>
-<%= render partial: 'toolbar', locals: { new_user: false, :@placeholder_user => @placeholder_user } %>
+<% tabs = tabs_for_key(:placeholder_user, placeholder_user: @placeholder_user) %>
+<% selected_tab = selected_tab(tabs) %>
-<%= render_extensible_tabs :placeholder_user, placeholder_user: @placeholder_user %>
+<%= render partial: 'toolbar', locals: { tabs: tabs } %>
+
+<%= content_tag 'div',
+ render(partial: selected_tab[:partial], locals: { tab: selected_tab } ),
+ id: "tab-content-#{selected_tab[:name]}",
+ class: 'tab-content' %>
diff --git a/app/views/placeholder_users/index.html.erb b/app/views/placeholder_users/index.html.erb
index 541b8a89ab7..0b65abf905a 100644
--- a/app/views/placeholder_users/index.html.erb
+++ b/app/views/placeholder_users/index.html.erb
@@ -29,28 +29,33 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title t(:label_administration), t(:label_placeholder_user_plural) -%>
<% has_ee = EnterpriseToken.allows_to?(:placeholder_users) %>
-
<% if has_ee %>
- <%= toolbar title: t(:label_placeholder_user_plural), title_class: 'no-padding-bottom' do %>
- <li class="toolbar-item">
- <%= link_to new_placeholder_user_path,
- { class: 'button -primary',
- aria: { label: t(:label_placeholder_user_new) },
- title: t(:label_placeholder_user_new) } do %>
- <%= op_icon('button--icon icon-add') %>
- <span class="button--text"><%= t('activerecord.models.placeholder_user') %></span>
- <% end %>
- </li>
-
- <%= call_hook(:placeholder_user_admin_action_menu) %>
- <% end %>
+ <%=
+ render(Primer::OpenProject::PageHeader.new) do |header|
+ header.with_title { t(:label_placeholder_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_placeholder_user_plural)])
+ end
+ %>
-<% end %>
+ <%=
+ render(Primer::OpenProject::SubHeader.new) do |subheader|
+ subheader.with_action_button(scheme: :primary,
+ aria: { label: I18n.t(:label_placeholder_user_new) },
+ title: I18n.t(:label_placeholder_user_new),
+ tag: :a,
+ href: new_placeholder_user_path) do |button|
+ button.with_leading_visual_icon(icon: :plus)
+ t('activerecord.models.placeholder_user')
+ end
+ subheader.with_bottom_pane_component do
+ render PlaceholderUsers::PlaceholderUserFilterComponent.new(params)
+ end
+ end
+ %>
-<% if has_ee %>
- <%= render PlaceholderUsers::PlaceholderUserFilterComponent.new(params) %>
- &nbsp;
<%= render PlaceholderUsers::TableComponent.new(rows: @placeholder_users) %>
<% else %>
<%= render template: 'common/upsale',
diff --git a/app/views/placeholder_users/new.html.erb b/app/views/placeholder_users/new.html.erb
index b8f1a4e4dff..821ea8f7c47 100644
--- a/app/views/placeholder_users/new.html.erb
+++ b/app/views/placeholder_users/new.html.erb
@@ -29,8 +29,9 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title t(:label_administration), t("label_placeholder_user_new") %>
<% local_assigns[:additional_breadcrumb] = t(:label_placeholder_user_new) %>
-<%= render partial: 'toolbar', locals: { new_user: true,
- :@placeholder_user => @placeholder_user } %>
+
+<%= render partial: 'toolbar', locals: { tabs: nil } %>
+
<%= labelled_tabular_form_for @placeholder_user,
url: { action: "create" },
html: { class: nil, autocomplete: 'off' },
diff --git a/app/views/placeholder_users/show.html.erb b/app/views/placeholder_users/show.html.erb
index a0f1cad7969..5fc19af8b28 100644
--- a/app/views/placeholder_users/show.html.erb
+++ b/app/views/placeholder_users/show.html.erb
@@ -31,17 +31,47 @@ See COPYRIGHT and LICENSE files for more details.
<%= call_hook :placeholder_users_show_head %>
<% end %>
<% html_title t(:label_administration), t(:label_placeholder_user_plural) -%>
-<%= toolbar title: "#{avatar @placeholder_user} #{h(@placeholder_user.name)}".html_safe do %>
- <% if current_user.allowed_globally?(:manage_placeholder_user) %>
- <li class="toolbar-item">
- <%= link_to edit_placeholder_user_path(@placeholder_user), class: 'button', accesskey: accesskey(:edit) do %>
- <%= op_icon('button--icon icon-edit') %>
- <span class="button--text"><%= t(:button_edit) %></span>
- <% end %>
- </li>
- <%= render partial: 'placeholder_users/toolbar_delete' %>
- <% end %>
-<% end %>
+
+<% deletable = can_delete_placeholder_user?(@placeholder_user) %>
+<%=
+ render(Primer::OpenProject::PageHeader.new) do |header|
+ header.with_title { "#{avatar @placeholder_user} #{h(@placeholder_user.name)}".html_safe }
+ header.with_breadcrumbs(
+ [
+ { href: placeholder_user_path, text: t(:label_placeholder_user_plural) },
+ @placeholder_user.name
+ ])
+
+ if current_user.allowed_globally?(:manage_placeholder_user)
+ header.with_action_button(tag: :a,
+ mobile_icon: :pencil,
+ mobile_label: t(:button_edit),
+ size: :medium,
+ accesskey: accesskey(:edit),
+ href: edit_placeholder_user_path(@placeholder_user),
+ aria: { label: I18n.t(:button_edit) },
+ title: I18n.t(:button_edit)) do |button|
+ button.with_leading_visual_icon(icon: :pencil)
+ t(:button_edit)
+ end
+ end
+
+ header.with_action_button(tag: :a,
+ scheme: :danger,
+ mobile_icon: :trash,
+ mobile_label: t(:button_delete),
+ size: :medium,
+ disabled: !deletable,
+ href: deletable ? deletion_info_placeholder_user_path(@placeholder_user) : "#",
+ aria: { label: I18n.t(:button_delete) },
+ title: deletable ?
+ I18n.t(:button_delete) :
+ I18n.t("placeholder_users.right_to_manage_members_missing")) do |button|
+ button.with_leading_visual_icon(icon: :trash)
+ t(:button_delete)
+ end
+ end
+%>
<div class="grid-block grid-block_double-column">
<div class="grid-content">
diff --git a/spec/helpers/tabs_helper_spec.rb b/spec/helpers/tabs_helper_spec.rb
index 72bca4a238d..9a27e0b89d9 100644
--- a/spec/helpers/tabs_helper_spec.rb
+++ b/spec/helpers/tabs_helper_spec.rb
@@ -45,16 +45,11 @@ RSpec.describe TabsHelper do
label: :label_avatar }
end
- describe "render_extensible_tabs" do
+ describe "tabs_for_key" do
let(:current_user) { build(:user) }
let(:user) { build(:user, id: 2) }
before do
- allow_any_instance_of(TabsHelper)
- .to receive(:render_tabs)
- .with([expected_tab])
- .and_return [expected_tab]
-
allow(OpenProject::Ui::ExtensibleTabs)
.to receive(:enabled_tabs)
.with(:user, a_hash_including(user:, current_user:))
@@ -62,7 +57,7 @@ RSpec.describe TabsHelper do
end
it "returns an evaluated path" do
- tabs = render_extensible_tabs(:user, user:)
+ tabs = tabs_for_key(:user, user:)
expect(response).to have_http_status :ok
expect(tabs).to eq([expected_tab])
end