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

Primerize

Oliver Günther121d1b73bb49
diff --git a/app/components/op_primer/expandable_list_component.html.erb b/app/components/op_primer/expandable_list_component.html.erb
new file mode 100644
index 00000000000..d404045d160
--- /dev/null
+++ b/app/components/op_primer/expandable_list_component.html.erb
@@ -0,0 +1,39 @@
+<%=
+ component_wrapper(data: wrapper_data_attributes) do
+ if elements.count == 0
+ render(Primer::Beta::Text.new(color: :subtle)) { t("label_meeting_no_items") }
+ elsif elements.count <= @cutoff_limit
+ flex_layout do |list|
+ elements.each do |item|
+ list.with_row(mt: 1) { item.to_s }
+ end
+ end
+ elsif elements.count > @cutoff_limit
+ flex_layout do |list|
+ elements.take(@cutoff_limit).each do |item|
+ list.with_row(mt: 1) { item.to_s }
+ end
+
+ list.with_row do
+ flex_layout do |flex|
+ flex.with_row(display: :none, data: { 'expandable-list-target': "hiddenElements" }) do
+ flex_layout do |hidden_user_list|
+ elements[@cutoff_limit..].each do |item|
+ hidden_user_list.with_row(mt: 1) { item.to_s }
+ end
+ end
+ end
+ flex.with_row(mt: 1) do
+ render(Primer::Beta::Button.new(
+ scheme: :link,
+ data: { 'expandable-list-target': "showHideButton",
+ action: 'click->expandable-list#showhiddenElements keydown.enter->expandable-list#showhiddenElements'
+ }
+ )) { I18n.t('label_show_hide_n_items', count: elements.count - @cutoff_limit) }
+ end
+ end
+ end
+ end
+ end
+ end
+%>
diff --git a/app/components/op_primer/expandable_list_component.rb b/app/components/op_primer/expandable_list_component.rb
new file mode 100644
index 00000000000..9378b0b479a
--- /dev/null
+++ b/app/components/op_primer/expandable_list_component.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+#
+module OpPrimer
+ class ExpandableListComponent < Primer::Component
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ CUTOFF_LIMIT = 10
+
+ renders_many :elements
+
+ def initialize(cutoff_limit: CUTOFF_LIMIT, **system_arguments)
+ super()
+
+ @system_arguments = deny_tag_argument(**system_arguments)
+ @cutoff_limit = cutoff_limit
+ end
+
+ def wrapper_data_attributes
+ {
+ controller: "expandable-list",
+ "application-target": "dynamic"
+ }
+ end
+ end
+end
diff --git a/app/components/users/profile/activities_component.html.erb b/app/components/users/profile/activities_component.html.erb
new file mode 100644
index 00000000000..446e7a7c0c5
--- /dev/null
+++ b/app/components/users/profile/activities_component.html.erb
@@ -0,0 +1,14 @@
+<% unless @events.empty? %>
+ <h3>
+ <%= link_to t(:label_activity), controller: '/activities', action: 'index', id: nil, user_id: @user, from: @events.first.event_datetime %>
+ </h3>
+ <p>
+ <%= t(:label_reported_work_packages) %>: <%= @user.reported_work_package_count %>
+ </p>
+ <%= render(Activities::DaysComponent.new(events: @events, display_user: false, header_tag: 'h4', activity_page: @activity_page)) %>
+ <%= helpers.other_formats_links do |f| %>
+ <%= f.link_to 'Atom', url: { controller: '/activities', action: 'index', id: nil, user_id: @user, key: User.current.rss_key } %>
+ <% end %>
+<% end %>
+
+<%= helpers.call_hook(:view_account_right_bottom, user: @user) %>
diff --git a/app/components/users/profile/activities_component.rb b/app/components/users/profile/activities_component.rb
new file mode 100644
index 00000000000..ab498f7fe80
--- /dev/null
+++ b/app/components/users/profile/activities_component.rb
@@ -0,0 +1,44 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module Users
+ module Profile
+ class ActivitiesComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(user:)
+ super()
+
+ @user = user
+ @events = Activities::Fetcher.new(User.current, author: @user).events(limit: 10)
+ end
+ end
+ end
+end
diff --git a/app/components/users/profile/attributes_component.html.erb b/app/components/users/profile/attributes_component.html.erb
new file mode 100644
index 00000000000..4f6fe6e83d6
--- /dev/null
+++ b/app/components/users/profile/attributes_component.html.erb
@@ -0,0 +1,37 @@
+<%=
+ component_wrapper do
+ flex_layout(mt: 3) do |details_container|
+ details_container.with_row do
+ flex_layout(align_items: :center, justify_content: :space_between) do |heading|
+ heading.with_column(flex: 1) do
+ render(Primer::Beta::Heading.new(tag: :h4)) { t(:label_information) }
+ end
+
+ if User.current.admin?
+ heading.with_column do
+ render(Primer::Beta::Link.new(
+ href: edit_user_path(@user),
+ scheme: :secondary
+ )) { t(:label_manage) }
+ end
+ end
+ end
+ end
+
+ details_container.with_row(mt: 2) do
+ if @user.pref.can_expose_mail?
+ concat "#{User.human_attribute_name(:mail)}: "
+ concat mail_to(escape_javascript(@user.mail), nil, encode: 'javascript')
+ end
+ end
+
+ @user.visible_custom_field_values.each do |custom_value|
+ if custom_value.value.present?
+ details_container.with_row do
+ "#{custom_value.custom_field.name}: #{custom_value.formatted_value}"
+ end
+ end
+ end
+ end
+ end
+%>
diff --git a/app/components/users/profile/attributes_component.rb b/app/components/users/profile/attributes_component.rb
new file mode 100644
index 00000000000..cc22932e683
--- /dev/null
+++ b/app/components/users/profile/attributes_component.rb
@@ -0,0 +1,51 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module Users
+ module Profile
+ class AttributesComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(user:)
+ super()
+
+ @user = user
+ end
+
+ def render?
+ visible_user_information?
+ end
+
+ def visible_user_information?
+ @user.pref.can_expose_mail? || @user.visible_custom_field_values.any? { _1.value.present? }
+ end
+ end
+ end
+end
diff --git a/app/components/users/profile/groups_component.html.erb b/app/components/users/profile/groups_component.html.erb
new file mode 100644
index 00000000000..41937ba22be
--- /dev/null
+++ b/app/components/users/profile/groups_component.html.erb
@@ -0,0 +1,32 @@
+<%=
+ component_wrapper do
+ flex_layout(mt: 3) do |details_container|
+ details_container.with_row do
+ flex_layout(align_items: :center, justify_content: :space_between) do |heading|
+ heading.with_column(flex: 1) do
+ render(Primer::Beta::Heading.new(tag: :h4)) { t(:label_group_plural) }
+ end
+
+ if User.current.admin?
+ heading.with_column do
+ render(Primer::Beta::Link.new(
+ href: edit_user_path(@user, tab: :groups),
+ scheme: :secondary
+ )) { t(:label_manage) }
+ end
+ end
+ end
+ end
+
+ details_container.with_row(mt: 2) do
+ render(OpPrimer::ExpandableListComponent.new(cutoff_limit: 5)) do |list|
+ @groups.each do |group|
+ list.with_element do
+ helpers.avatar(group, size: :mini, hide_name: false)
+ end
+ end
+ end
+ end
+ end
+ end
+%>
diff --git a/app/components/users/profile/groups_component.rb b/app/components/users/profile/groups_component.rb
new file mode 100644
index 00000000000..e5795b62007
--- /dev/null
+++ b/app/components/users/profile/groups_component.rb
@@ -0,0 +1,48 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module Users
+ module Profile
+ class GroupsComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(user:)
+ super()
+
+ @user = user
+ @groups = user.groups.visible.order(lastname: :asc)
+ end
+
+ def render?
+ @groups.any?
+ end
+ end
+ end
+end
diff --git a/app/components/users/profile/projects_component.html.erb b/app/components/users/profile/projects_component.html.erb
new file mode 100644
index 00000000000..98f33e47df6
--- /dev/null
+++ b/app/components/users/profile/projects_component.html.erb
@@ -0,0 +1,36 @@
+<%=
+ component_wrapper do
+ flex_layout(mt: 3) do |details_container|
+ details_container.with_row do
+ flex_layout(align_items: :center, justify_content: :space_between) do |heading|
+ heading.with_column(flex: 1) do
+ render(Primer::Beta::Heading.new(tag: :h4)) { t(:label_project_plural) }
+ end
+
+ if User.current.admin?
+ heading.with_column do
+ render(Primer::Beta::Link.new(
+ href: edit_user_path(@user, tab: :memberships),
+ scheme: :secondary
+ )) { t(:label_manage) }
+ end
+ end
+ end
+ end
+
+ details_container.with_row(mt: 2) do
+ render(OpPrimer::ExpandableListComponent.new(cutoff_limit: 5)) do |list|
+ @memberships.each do |membership|
+ list.with_element do
+ concat helpers.link_to_project(membership.project)
+
+ roles = membership.roles.sort.collect(&:to_s).join(', ')
+ date = helpers.format_date(membership.created_at)
+ concat render(Primer::Beta::Text.new(ml: 1, color: :subtle, font_size: :small)) { "(#{roles}, #{date})" }
+ end
+ end
+ end
+ end
+ end
+ end
+%>
diff --git a/app/components/users/profile/projects_component.rb b/app/components/users/profile/projects_component.rb
new file mode 100644
index 00000000000..e8292945be6
--- /dev/null
+++ b/app/components/users/profile/projects_component.rb
@@ -0,0 +1,57 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module Users
+ module Profile
+ class ProjectsComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(user:)
+ super()
+
+ @user = user
+ # show projects based on current user visibility.
+ # But don't simply concatenate the .visible scope to the memberships
+ # as .memberships has an include and an order which for whatever reason
+ # also gets applied to the Project.allowed_to parts concatenated by a UNION
+ # and an order inside a UNION is not allowed in postgres.
+ @memberships = @user.memberships
+ .where.not(project_id: nil)
+ .where(id: Member.visible(User.current))
+ .order("projects.created_at DESC")
+
+ end
+
+ def render?
+ @memberships.any?
+ end
+ end
+ end
+end
diff --git a/app/components/users/profile/sidebar_component.html.erb b/app/components/users/profile/sidebar_component.html.erb
new file mode 100644
index 00000000000..50298f772d0
--- /dev/null
+++ b/app/components/users/profile/sidebar_component.html.erb
@@ -0,0 +1,15 @@
+<%=
+ component_wrapper do
+ render(Primer::OpenProject::BorderGrid.new(spacious: true)) do |border_grid|
+ [
+ Users::Profile::AttributesComponent.new(user: @user),
+ Users::Profile::GroupsComponent.new(user: @user),
+ Users::Profile::ProjectsComponent.new(user: @user)
+ ].each do |component|
+ if component.render?
+ border_grid.with_row { render(component) }
+ end
+ end
+ end
+ end
+%>
diff --git a/app/components/users/profile/sidebar_component.rb b/app/components/users/profile/sidebar_component.rb
new file mode 100644
index 00000000000..b0509e70ded
--- /dev/null
+++ b/app/components/users/profile/sidebar_component.rb
@@ -0,0 +1,43 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module Users
+ module Profile
+ class SidebarComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(user:)
+ super()
+
+ @user = user
+ end
+ end
+ end
+end
diff --git a/app/components/users/profile_component.html.erb b/app/components/users/profile_component.html.erb
new file mode 100644
index 00000000000..5d5336dbb70
--- /dev/null
+++ b/app/components/users/profile_component.html.erb
@@ -0,0 +1,19 @@
+<%=
+ render(Primer::Alpha::Layout.new(stacking_breakpoint: :md)) do |content|
+ content.with_main do
+ flex_layout do |profile|
+ profile.with_row do
+ render(Users::Profile::ActivitiesComponent.new(user: @user))
+ end
+
+ profile.with_row do
+ helpers.call_hook(:view_account_left_bottom, user: @user)
+ end
+ end
+ end
+
+ content.with_sidebar(row_placement: :start, col_placement: :end) do
+ render(Users::Profile::SidebarComponent.new(user: @user))
+ end
+ end
+%>
diff --git a/app/components/users/profile_component.rb b/app/components/users/profile_component.rb
new file mode 100644
index 00000000000..b6ec7b6d3db
--- /dev/null
+++ b/app/components/users/profile_component.rb
@@ -0,0 +1,40 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module Users
+ class ProfileComponent < ApplicationComponent
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(user:, **)
+ super(**)
+
+ @user = user
+ end
+ end
+end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 175dbc14d50..9ebdb348a2e 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -68,19 +68,7 @@ class UsersController < ApplicationController
end
def show
- # show projects based on current user visibility.
- # But don't simply concatenate the .visible scope to the memberships
- # as .memberships has an include and an order which for whatever reason
- # also gets applied to the Project.allowed_to parts concatenated by a UNION
- # and an order inside a UNION is not allowed in postgres.
- @memberships = @user.memberships
- .where.not(project_id: nil)
- .where(id: Member.visible(current_user))
-
- @groups = @user.groups.visible
-
if can_show_user?
- @events = events
render layout: (can_manage_or_create_users? ? "admin" : "no_menu")
else
render_404
@@ -242,18 +230,13 @@ class UsersController < ApplicationController
return true if can_manage_or_create_users?
return true if @user == User.current
- (@user.active? || @user.registered?) \
- && (@memberships.present? || events.present?)
+ @user.active? || @user.registered?
end
def can_manage_or_create_users?
current_user.allowed_globally?(:manage_user) || current_user.allowed_globally?(:create_user)
end
- def events
- @events ||= Activities::Fetcher.new(User.current, author: @user).events(limit: 10)
- end
-
def find_user
if params[:id] == User::CURRENT_USER_LOGIN_ALIAS || params[:id].nil?
require_login || return
@@ -314,7 +297,7 @@ class UsersController < ApplicationController
end
def show_local_breadcrumb
- can_manage_or_create_users?
+ can_manage_or_create_users? && action_name != "show"
end
def build_user_update_params
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 786242f9bc8..9c79821c750 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -125,10 +125,6 @@ module UsersHelper
end
end
- def visible_user_information?(user)
- user.pref.can_expose_mail? || user.visible_custom_field_values.any? { _1.value.present? }
- end
-
def user_name(user)
user ? user.name : I18n.t("user.deleted")
end
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index a90c6d7217f..1c8b7d36de3 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -27,89 +27,48 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<% content_for :header_tags do %>
+ <%= auto_discovery_link_tag(:atom, controller: '/activities', action: 'index', user_id: @user, format: :atom, key: User.current.rss_key) %>
<%= call_hook :users_show_head %>
<% end %>
-<% local_assigns[:additional_breadcrumb] = @user.name %>
-<% html_title t(:label_user_plural) -%>
-<%= breadcrumb_toolbar do %>
- <% if User.current.allowed_globally?(:manage_user) %>
- <li class="toolbar-item">
- <%= link_to edit_user_path(@user), class: 'button', accesskey: accesskey(:edit) do %>
- <%= op_icon('button--icon icon-edit') %>
- <span class="button--text"><%= t(:button_edit) %></span>
- <% end %>
- </li>
- <% end %>
- <% if User.current.allowed_globally?(:create_user) %>
- <li class="toolbar-item hidden-for-tablet">
- <%= form_for(@user, html: { class: 'toolbar-item' },
- 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 %>
-<% end %>
-<div class="grid-block grid-block_double-column">
- <div class="grid-content">
- <%= call_hook :view_account_left_top, user: @user %>
- <% if visible_user_information?(@user) %>
- <ul>
- <% if @user.pref.can_expose_mail? %>
- <li><%= User.human_attribute_name(:mail) %>: <%= mail_to(h(escape_javascript(@user.mail)), nil, encode: 'javascript') %></li>
- <% end %>
- <% @user.visible_custom_field_values.each do |custom_value| %>
- <% if custom_value.value.present? %>
- <li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
- <% end %>
- <% end %>
- </ul>
- <% end %>
- <%= call_hook :view_account_left_middle, user: @user %>
- <% unless @groups.empty? %>
- <h3><%=t(:label_group_plural)%></h3>
- <ul>
- <% @groups.each do |group| %>
- <li>
- <%= link_to_group(group) %>
- </li>
- <% end %>
- </ul>
- <% end %>
- <% unless @memberships.empty? %>
- <h3><%=t(:label_project_plural)%></h3>
- <ul>
- <% for membership in @memberships %>
- <li>
- <%= link_to_project(membership.project) %>
- (<%=h membership.roles.sort.collect(&:to_s).join(', ') %>, <%= format_date(membership.created_at) %>)
- </li>
- <% end %>
- </ul>
- <% end %>
- <%= call_hook :view_account_left_bottom, user: @user %>
- </div>
- <div class="grid-content">
- <% unless @events.empty? %>
- <h3>
- <%= link_to t(:label_activity), controller: '/activities', action: 'index', id: nil, user_id: @user, from: @events.first.event_datetime %>
- </h3>
- <p>
- <%=t(:label_reported_work_packages)%>: <%= @user.reported_work_package_count %>
- </p>
- <%= render(Activities::DaysComponent.new(events: @events, display_user: false, header_tag: 'h4', activity_page: @activity_page)) %>
- <%= other_formats_links do |f| %>
- <%= f.link_to 'Atom', url: {controller: '/activities', action: 'index', id: nil, user_id: @user, key: User.current.rss_key} %>
- <% end %>
- <% content_for :header_tags do %>
- <%= auto_discovery_link_tag(:atom, controller: '/activities', action: 'index', user_id: @user, format: :atom, key: User.current.rss_key) %>
- <% end %>
- <% end %>
- <%= call_hook :view_account_right_bottom, user: @user %>
- </div>
-</div>
-<% html_title h(@user.name) %>
+<% html_title h(@user.name), t(:label_user_plural) -%>
+
+<%=
+ render(Primer::OpenProject::PageHeader.new) do |header|
+ header.with_title { "#{avatar @user} #{h(@user.name)}".html_safe }
+ header.with_breadcrumbs(
+ [
+ { href: users_path, text: t(:label_user_plural) },
+ { href: user_path(@user), text: @user.name }
+ ])
+
+ if current_user.allowed_globally?(:manage_user)
+ header.with_action_button(tag: :a,
+ mobile_icon: :pencil,
+ mobile_label: t(:button_edit),
+ size: :medium,
+ href: edit_user_path(@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
+
+ if current_user.allowed_globally?(:create_user)
+ header.with_action_button(tag: :a,
+ mobile_icon: :pencil,
+ 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
+ end
+%>
+
+<%= render Users::ProfileComponent.new(user: @user) %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 913f6970303..d1d1056b3e6 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2140,6 +2140,7 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}
label_invite_user: "Invite user"
label_share: "Share"
label_show_hide: "Show/hide"
+ label_show_hide_n_items: "Show/hide %{count} items"
label_show_all_registered_users: "Show all registered users"
label_journal: "Journal"
label_journal_diff: "Description Comparison"
@@ -2177,6 +2178,7 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}
label_custom_touch_icon: "Custom touch icon"
label_logout: "Sign out"
label_main_menu: "Side Menu"
+ label_manage: "Manage"
label_manage_groups: "Manage groups"
label_managed_repositories_vendor: "Managed %{vendor} repositories"
label_max_size: "Maximum size"
diff --git a/frontend/src/stimulus/controllers/dynamic/meetings-sidebar-participants.controller.ts b/frontend/src/stimulus/controllers/dynamic/expandable-list.controller.ts
similarity index 73%
rename from frontend/src/stimulus/controllers/dynamic/meetings-sidebar-participants.controller.ts
rename to frontend/src/stimulus/controllers/dynamic/expandable-list.controller.ts
index 061508d40e8..cf7bde87452 100644
--- a/frontend/src/stimulus/controllers/dynamic/meetings-sidebar-participants.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/expandable-list.controller.ts
@@ -30,16 +30,15 @@
import { Controller } from '@hotwired/stimulus';
-export default class MeetingsSidebarParticipantsController extends Controller {
- static targets = ['showHideButton', 'hiddenParticipants'];
- declare readonly showHideButtonTarget:HTMLInputElement;
- declare readonly hiddenParticipantsTarget:HTMLElement;
+export default class ExxpandableListController extends Controller {
+ static targets = ['showHideButton', 'hiddenElements'];
+ declare readonly hiddenElementsTarget:HTMLElement;
- showHiddenParticipants():void {
- if (this.hiddenParticipantsTarget.classList.contains('d-none')) {
- this.hiddenParticipantsTarget.classList.remove('d-none');
+ showhiddenElements():void {
+ if (this.hiddenElementsTarget.classList.contains('d-none')) {
+ this.hiddenElementsTarget.classList.remove('d-none');
} else {
- this.hiddenParticipantsTarget.classList.add('d-none');
+ this.hiddenElementsTarget.classList.add('d-none');
}
}
}
diff --git a/lookbook/previews/op_primer/expandable_list_component_preview.rb b/lookbook/previews/op_primer/expandable_list_component_preview.rb
new file mode 100644
index 00000000000..5489bcd7014
--- /dev/null
+++ b/lookbook/previews/op_primer/expandable_list_component_preview.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module OpPrimer
+ # @logical_path OpenProject/Primer
+ class ExpandableListComponentPreview < Lookbook::Preview
+ # Renders an expandable list with a given number of elements
+ # @param cutoff_limit number The cutoff limit for the number of elements to render
+ def default(cutoff_limit: 5)
+ render_with_template(locals: { cutoff_limit:, elements: ("a".."z").to_a })
+ end
+
+ # Renders a turbo-stream tag with given action and target
+ # @param cutoff_limit number The cutoff limit for the number of elements to render
+ def primer(cutoff_limit: 5)
+ render_with_template(locals: { cutoff_limit:, elements: ("a".."z").to_a })
+ end
+ end
+end
diff --git a/lookbook/previews/op_primer/expandable_list_component_preview/default.html.erb b/lookbook/previews/op_primer/expandable_list_component_preview/default.html.erb
new file mode 100644
index 00000000000..0cd4fedea49
--- /dev/null
+++ b/lookbook/previews/op_primer/expandable_list_component_preview/default.html.erb
@@ -0,0 +1,7 @@
+<%=
+ render(OpPrimer::ExpandableListComponent.new(cutoff_limit:)) do |list|
+ elements.each do |item|
+ list.with_element { item }
+ end
+ end
+%>
diff --git a/lookbook/previews/op_primer/expandable_list_component_preview/primer.html.erb b/lookbook/previews/op_primer/expandable_list_component_preview/primer.html.erb
new file mode 100644
index 00000000000..38559cf9c17
--- /dev/null
+++ b/lookbook/previews/op_primer/expandable_list_component_preview/primer.html.erb
@@ -0,0 +1,12 @@
+<%=
+ render(OpPrimer::ExpandableListComponent.new(cutoff_limit:)) do |list|
+ elements.each do |item|
+ list.with_element do
+ render(Primer::BaseComponent.new(tag: :span)) do
+ concat render(Primer::Beta::Octicon.new(icon: :person))
+ concat item
+ end
+ end
+ end
+ end
+%>
diff --git a/modules/meeting/app/components/meetings/sidebar/participants_component.html.erb b/modules/meeting/app/components/meetings/sidebar/participants_component.html.erb
index cd083d2738e..1d947e4ce4e 100644
--- a/modules/meeting/app/components/meetings/sidebar/participants_component.html.erb
+++ b/modules/meeting/app/components/meetings/sidebar/participants_component.html.erb
@@ -32,45 +32,9 @@
end
participants_container.with_row(mt: 2) do
- if count == 0
- render(Primer::Beta::Text.new(color: :subtle)) { t("label_meeting_no_participants") }
- elsif count <= MAX_SHOWN_PARTICIPANTS
- flex_layout do |list|
- @meeting.invited_or_attended_participants.sort.each do |participant|
- list.with_row(mt: 1) do
- render_participant(participant)
- end
- end
- end
- elsif count > MAX_SHOWN_PARTICIPANTS
- flex_layout do |list|
- @meeting.invited_or_attended_participants.sort.take(MAX_SHOWN_PARTICIPANTS).each do |participant|
- list.with_row(mt: 1) do
- render_participant(participant)
- end
- end
-
- list.with_row do
- flex_layout do |flex|
- flex.with_row(display: :none, data: { 'meetings-sidebar-participants-target': "hiddenParticipants" }) do
- flex_layout do |hidden_user_list|
- @meeting.invited_or_attended_participants.sort[MAX_SHOWN_PARTICIPANTS..].each do |participant|
- hidden_user_list.with_row(mt: 1) do
- render_participant(participant)
- end
- end
- end
- end
- flex.with_row(mt: 1) do
- render (Primer::Beta::Button.new(
- scheme: :link,
- data: { 'meetings-sidebar-participants-target': "showHideButton",
- action: 'click->meetings-sidebar-participants#showHiddenParticipants keydown.enter->meetings-sidebar-participants#showHiddenParticipants'
- }
- )) { I18n.t('label_meeting_show_hide_participants', count: @meeting.invited_or_attended_participants.count - MAX_SHOWN_PARTICIPANTS) }
- end
- end
- end
+ render(OpPrimer::ExpandableListComponent.new(cutoff_limit: 5)) do |list|
+ elements.each do |item|
+ list.with_element { render_participant(item) }
end
end
end
diff --git a/modules/meeting/app/components/meetings/sidebar/participants_component.rb b/modules/meeting/app/components/meetings/sidebar/participants_component.rb
index 0d2c2b7dabe..f9c4d6cefbf 100644
--- a/modules/meeting/app/components/meetings/sidebar/participants_component.rb
+++ b/modules/meeting/app/components/meetings/sidebar/participants_component.rb
@@ -36,7 +36,7 @@ module Meetings
def wrapper_data_attributes
{
- controller: "meetings-sidebar-participants",
+ controller: "expandable-list",
"application-target": "dynamic"
}
end
@@ -47,10 +47,12 @@ module Meetings
@meeting = meeting
end
- private
+ def elements
+ @elements ||= @meeting.invited_or_attended_participants.sort
+ end
def count
- @count ||= @meeting.invited_or_attended_participants.count
+ @count ||= elements.count
end
def render_participant(participant)
diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb
index 4bc5fa21771..690e85208ba 100644
--- a/spec/features/users/show_spec.rb
+++ b/spec/features/users/show_spec.rb
@@ -64,7 +64,7 @@ RSpec.describe "index users", :js, :with_cuprite do
it "does not show the group" do
visit user_path(user)
- expect(page).not_to have_text group.name
+ expect(page).to have_no_text group.name
end
end
end