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

show users with avatar component in sidebar

Jonas Jabarie00030b52e3e
diff --git a/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb b/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb
index 42078c509cc..d71ff4e93ba 100644
--- a/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb
+++ b/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb
@@ -8,6 +8,7 @@
url: update_project_custom_values_path(project_id: @project.id, section_id: @project_custom_field_section.id),
) do |f|
component_collection do |collection|
+ # TODO: remove inline style
collection.with_component(Primer::Alpha::Dialog::Body.new(my: 3, style: "max-height: 500px;")) do
render(Projects::CustomFields::Form.new(f, project: @project, custom_field_section: @project_custom_field_section))
end
diff --git a/modules/overviews/app/components/project_custom_fields/sections/project_custom_fields/show_component.rb b/modules/overviews/app/components/project_custom_fields/sections/project_custom_fields/show_component.rb
index ac6ea253d1c..cdbf643354e 100644
--- a/modules/overviews/app/components/project_custom_fields/sections/project_custom_fields/show_component.rb
+++ b/modules/overviews/app/components/project_custom_fields/sections/project_custom_fields/show_component.rb
@@ -43,14 +43,21 @@ module ProjectCustomFields
private
+ def not_set?
+ @project_custom_field_values.empty? || @project_custom_field_values.all? { |cf_value| cf_value.value.blank? }
+ end
+
def render_value
- if @project_custom_field.field_format == "text"
+ case @project_custom_field.field_format
+ when "text"
render_rich_text
+ when "user"
+ render_user
else
render(Primer::Beta::Text.new) do
@project_custom_field_values&.map do |cf_value|
format_value(cf_value.value, @project_custom_field)
- end&.join(", ")&.html_safe
+ end&.join(", ")
end
end
end
@@ -71,22 +78,44 @@ module ProjectCustomFields
flex_layout do |rich_text_preview_container|
rich_text_preview_container.with_row do
render(Primer::Beta::Text.new) do
- format_value(@project_custom_field_values.first&.value&.truncate(truncation_length), @project_custom_field)
+ format_value(
+ @project_custom_field_values.first&.value&.truncate(truncation_length),
+ @project_custom_field
+ )
end
end
rich_text_preview_container.with_row do
- render(Primer::Alpha::Dialog.new(size: :medium_portrait, title: @project_custom_field.name)) do |d|
- d.with_show_button(scheme: :link) { "Expand" }
- d.with_body(style: "max-height: 500px;") do
- format_value(@project_custom_field_values.first&.value, @project_custom_field)
+ render_dialog
+ end
+ end
+ end
+
+ def render_dialog
+ render(Primer::Alpha::Dialog.new(size: :medium_portrait, title: @project_custom_field.name)) do |dialog|
+ dialog.with_show_button(scheme: :link) { "Expand" }
+ # TODO: remove inline style
+ dialog.with_body(style: "max-height: 500px;") do
+ format_value(@project_custom_field_values.first&.value, @project_custom_field)
+ end
+ end
+ end
+
+ def render_user
+ if @project_custom_field.multi_value?
+ flex_layout do |avatar_container|
+ @project_custom_field_values&.each do |cf_value|
+ avatar_container.with_row do
+ render_avatar(cf_value.typed_value)
end
end
end
+ else
+ render_avatar(@project_custom_field_values&.first&.typed_value)
end
end
- def not_set?
- @project_custom_field_values.empty? || @project_custom_field_values.all? { |cf_value| cf_value.value.blank? }
+ def render_avatar(user)
+ render(Users::AvatarComponent.new(user:, size: :mini))
end
end
end
diff --git a/spec/features/projects/project_custom_fields/overview_page/sidebar_spec.rb b/spec/features/projects/project_custom_fields/overview_page/sidebar_spec.rb
index 0682eb3412b..bfb559075ab 100644
--- a/spec/features/projects/project_custom_fields/overview_page/sidebar_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/sidebar_spec.rb
@@ -706,6 +706,7 @@ RSpec.describe 'Show project custom fields on project overview page', :js, :with
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(user_project_custom_field) do
expect(page).to have_text 'User field'
+ expect(page).to have_css('opce-principal')
expect(page).to have_text 'Member 1 In Project'
end
end
@@ -841,7 +842,9 @@ RSpec.describe 'Show project custom fields on project overview page', :js, :with
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(multi_user_project_custom_field) do
expect(page).to have_text 'Multi user field'
- expect(page).to have_text 'Member 1 In Project, Member 2 In Project'
+ expect(page).to have_css 'opce-principal', count: 2
+ expect(page).to have_text 'Member 1 In Project'
+ expect(page).to have_text 'Member 2 In Project'
end
end
end