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

Render section components

Oliver Günther594d91084cd9
diff --git a/modules/overviews/app/components/project_custom_fields/sections/show_component.html.erb b/modules/overviews/app/components/project_custom_fields/sections/show_component.html.erb
index f748b8e8b73..7279b183365 100644
--- a/modules/overviews/app/components/project_custom_fields/sections/show_component.html.erb
+++ b/modules/overviews/app/components/project_custom_fields/sections/show_component.html.erb
@@ -1,37 +1,33 @@
<%=
component_wrapper do
- flex_layout(border: :bottom, pb: 2, classes: 'op-project-custom-field-section-container', data: {
+ render(Primer::OpenProject::SidePanel::Section.new(
+ classes: 'op-project-custom-field-section-container',
test_selector: "project-custom-field-section-#{@project_custom_field_section.id}"
- }) do |details_container|
- details_container.with_row(mb: 2) 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)) { @project_custom_field_section.name }
- end
+ )) do |section|
+ section.with_title { @project_custom_field_section.name }
- heading.with_column do
- render(Primer::Beta::IconButton.new(
- icon: :pencil,
- tag: :a,
- href: project_custom_field_section_dialog_path(project_id: @project.id, section_id: @project_custom_field_section.id),
- data: {
- controller: 'async-dialog'
- },
- scheme: :invisible,
- button_icon: :pencil,
- test_selector: "project-custom-field-section-edit-button",
- aria: { label: I18n.t(:label_edit) },
- ))
- end if allowed_to_edit?
- end
+ if allowed_to_edit?
+ section.with_action_icon(
+ icon: :pencil,
+ tag: :a,
+ href: project_custom_field_section_dialog_path(project_id: @project.id, section_id: @project_custom_field_section.id),
+ data: {
+ controller: 'async-dialog'
+ },
+ test_selector: "project-custom-field-section-edit-button",
+ aria: { label: I18n.t(:label_edit) }
+ )
end
- @project_custom_fields.each do |project_custom_field|
- details_container.with_row(mb: 3) do
- render(ProjectCustomFields::Sections::ProjectCustomFields::ShowComponent.new(
- project_custom_field:,
- project_custom_field_values: get_eager_loaded_project_custom_field_values_for(project_custom_field.id)
- ))
+ flex_layout do |details_container|
+ @project_custom_fields.each_with_index do |project_custom_field, i|
+ margin = i == @project_custom_fields.size - 1 ? 0 : 3
+ details_container.with_row(mb: margin) do
+ render(ProjectCustomFields::Sections::ProjectCustomFields::ShowComponent.new(
+ project_custom_field:,
+ project_custom_field_values: get_eager_loaded_project_custom_field_values_for(project_custom_field.id)
+ ))
+ end
end
end
end
diff --git a/modules/overviews/app/components/project_custom_fields/sidebar_component.html.erb b/modules/overviews/app/components/project_custom_fields/side_panel_component.html.erb
similarity index 51%
rename from modules/overviews/app/components/project_custom_fields/sidebar_component.html.erb
rename to modules/overviews/app/components/project_custom_fields/side_panel_component.html.erb
index efdff6c6d02..8034ae1d826 100644
--- a/modules/overviews/app/components/project_custom_fields/sidebar_component.html.erb
+++ b/modules/overviews/app/components/project_custom_fields/side_panel_component.html.erb
@@ -1,15 +1,18 @@
<%=
component_wrapper do
if available_project_custom_fields_grouped_by_section.any?
- flex_layout(data: { test_selector: "project-custom-fields-sidebar-async-content" }) do |sections_container|
+ render(Primer::OpenProject::SidePanel.new(
+ spacious: true,
+ test_selector: "project-custom-fields-sidebar-async-content"
+ )) do |panel|
available_project_custom_fields_grouped_by_section.each do |project_custom_field_section, project_custom_fields|
- sections_container.with_row(mb: 3) do
- render(ProjectCustomFields::Sections::ShowComponent.new(
+ panel.with_section(
+ ProjectCustomFields::Sections::ShowComponent.new(
project: @project,
- project_custom_field_section: ,
+ project_custom_field_section:,
project_custom_fields: project_custom_fields
- ))
- end
+ )
+ )
end
end
end
diff --git a/modules/overviews/app/components/project_custom_fields/sidebar_component.rb b/modules/overviews/app/components/project_custom_fields/side_panel_component.rb
similarity index 97%
rename from modules/overviews/app/components/project_custom_fields/sidebar_component.rb
rename to modules/overviews/app/components/project_custom_fields/side_panel_component.rb
index 09a3159a88f..5111f29d7da 100644
--- a/modules/overviews/app/components/project_custom_fields/sidebar_component.rb
+++ b/modules/overviews/app/components/project_custom_fields/side_panel_component.rb
@@ -27,7 +27,7 @@
#++
module ProjectCustomFields
- class SidebarComponent < ApplicationComponent
+ class SidePanelComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable
diff --git a/modules/overviews/app/controllers/overviews/overviews_controller.rb b/modules/overviews/app/controllers/overviews/overviews_controller.rb
index e6c763a1c71..a34333c8563 100644
--- a/modules/overviews/app/controllers/overviews/overviews_controller.rb
+++ b/modules/overviews/app/controllers/overviews/overviews_controller.rb
@@ -76,7 +76,7 @@ module ::Overviews
def update_sidebar_component
update_via_turbo_stream(
- component: ProjectCustomFields::SidebarComponent.new(project: @project)
+ component: ProjectCustomFields::SidePanelComponent.new(project: @project)
)
end
end
diff --git a/modules/overviews/app/views/overviews/overviews/project_custom_fields_sidebar.html.erb b/modules/overviews/app/views/overviews/overviews/project_custom_fields_sidebar.html.erb
index 33deb6558c3..9118433d7e3 100644
--- a/modules/overviews/app/views/overviews/overviews/project_custom_fields_sidebar.html.erb
+++ b/modules/overviews/app/views/overviews/overviews/project_custom_fields_sidebar.html.erb
@@ -27,5 +27,5 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<%= content_tag("turbo-frame", id: "project-custom-fields-sidebar") do %>
- <%= render(ProjectCustomFields::SidebarComponent.new(project: @project)) %>
-<% end %>
\ No newline at end of file
+ <%= render(ProjectCustomFields::SidePanelComponent.new(project: @project)) %>
+<% end %>