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
[#55581] Users::HoverCardComponent
Tobias Dillmannfe106c3396a0
diff --git a/app/components/_index.sass b/app/components/_index.sassindex 45a89e33bc3..0941b751e3c 100644--- a/app/components/_index.sass+++ b/app/components/_index.sass@@ -18,3 +18,4 @@@import "op_primer/border_box_table_component"@import "work_packages/exports/modal_dialog_component"@import "work_package_relations_tab/index_component"+@import "users/hover_card_component"diff --git a/app/components/users/hover_card_component.html.erb b/app/components/users/hover_card_component.html.erbnew file mode 100644index 00000000000..c6387b50199--- /dev/null+++ b/app/components/users/hover_card_component.html.erb@@ -0,0 +1,31 @@+<%=+ if @user.present?+ grid_layout('op-user-hover-card', tag: :div) do |grid|+ grid.with_area(:avatar, tag: :div) do+ render(Users::AvatarComponent.new(user: @user, show_name: false, size: :large))+ end++ grid.with_area(:subject, tag: :div) do+ concat(render(Primer::Beta::Text.new(font_weight: :semibold)) { @user.name })+ end+ grid.with_area(:email, tag: :div) do+ concat(render(Primer::Beta::Text.new(color: :muted)) { @user.mail }) # TODO: only with permission+ end++ grid.with_area(:projects, tag: :div, font_size: :small, color: :muted) do+ concat(render(Primer::Beta::Octicon.new(icon: :people)))+ concat(render(Primer::Beta::Text.new) { "Member of ..., ... and 4 more" })+ end++ grid.with_area(:actions, tag: :div) do+ render(Primer::Beta::Button.new) { "Open Profile" }+ end+ end+ else+ render Primer::Beta::Blankslate.new(border: false, narrow: true) do |component|+ component.with_visual_icon(icon: "x-circle")+ # TODO: fix 404 string+ component.with_heading(tag: :h3).with_content(I18n.t("api_v3.errors.not_found.work_package"))+ end+ end+%>diff --git a/app/components/users/hover_card_component.rb b/app/components/users/hover_card_component.rbnew file mode 100644index 00000000000..6a7fd3fa024--- /dev/null+++ b/app/components/users/hover_card_component.rb@@ -0,0 +1,16 @@+# frozen_string_literal: true++class Users::HoverCardComponent < ApplicationComponent+ include OpPrimer::ComponentHelpers++ def initialize(id:)+ super++ @id = id+ @user = User.find(@id)+ end++ def show_email?+ false+ end+enddiff --git a/app/components/users/hover_card_component.sass b/app/components/users/hover_card_component.sassnew file mode 100644index 00000000000..6ef3b9a8c28--- /dev/null+++ b/app/components/users/hover_card_component.sass@@ -0,0 +1,6 @@+.op-user-hover-card+ display: grid+ grid-template-areas: "avatar avatar" "subject email" "projects projects" "actions actions"+ gap: 1rem++ overflow: hiddendiff --git a/app/controllers/users/hover_card_controller.rb b/app/controllers/users/hover_card_controller.rbnew file mode 100644index 00000000000..26276a25f37--- /dev/null+++ b/app/controllers/users/hover_card_controller.rb@@ -0,0 +1,35 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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.+#+++class Users::HoverCardController < ApplicationController+ before_action :authorize_global++ def show+ @id = params[:id]+ render layout: nil+ end+enddiff --git a/app/views/users/hover_card/show.html.erb b/app/views/users/hover_card/show.html.erbnew file mode 100644index 00000000000..5fd0177bb0e--- /dev/null+++ b/app/views/users/hover_card/show.html.erb@@ -0,0 +1,3 @@+<turbo-frame id="op-hover-card-body">+ <%= render Users::HoverCardComponent.new(id: @id) %>+</turbo-frame>diff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rbindex 87f571f46a9..6b2866657ea 100644--- a/config/initializers/permissions.rb+++ b/config/initializers/permissions.rb@@ -71,6 +71,12 @@ Rails.application.reloader.to_prepare dorequire: :loggedin,contract_actions: { users: %i[read update] }+ map.permission :view_user_hover_card,+ {+ "users/hover_card": %i[show]+ },+ permissible_on: :global+map.permission :manage_placeholder_user,{placeholder_users: %i[index show new create edit update deletion_info destroy],diff --git a/config/routes.rb b/config/routes.rbindex 158ed8a6a29..38c278f2cde 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -642,6 +642,7 @@ Rails.application.routes.draw doresources :memberships, controller: "users/memberships", only: %i[update create destroy]member do+ get "/hover_card" => "users/hover_card#show"get "/edit(/:tab)" => "users#edit", as: "edit"get "/change_status/:change_action" => "users#change_status_info", as: "change_status_info"post :change_statusdiff --git a/modules/avatars/app/helpers/avatar_helper.rb b/modules/avatars/app/helpers/avatar_helper.rbindex 57dc78fcd72..47922fd4d11 100644--- a/modules/avatars/app/helpers/avatar_helper.rb+++ b/modules/avatars/app/helpers/avatar_helper.rb@@ -108,7 +108,8 @@ module AvatarHelperhideName: tag_options[:hide_name],nameClasses: tag_options[:name_classes],title: tag_options.fetch(:title, ""),- hover_card_url: "work_packages/14/hover_card"+ # TODO: use path helper+ hover_card_url: "users/#{user.id}/hover_card"}end