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

Align subheader button with widget edges

Alexander Brandon Colesfe704811d0de
diff --git a/frontend/src/global_styles/content/_grid.sass b/frontend/src/global_styles/content/_grid.sass
index 587c11948c8..c2376a2d804 100644
--- a/frontend/src/global_styles/content/_grid.sass
+++ b/frontend/src/global_styles/content/_grid.sass
@@ -192,3 +192,8 @@ $grid--widget-padding: 20px 20px 20px 20px
position: sticky
bottom: 0
margin-bottom: 0
+
+// Utility class for components that should match the grid's horizontal padding
+.grid-mx
+ margin-left: $grid--gap-width
+ margin-right: $grid--gap-width
diff --git a/modules/overviews/app/components/overviews/show_component.html.erb b/modules/overviews/app/components/overviews/show_component.html.erb
index bc3a104fb61..db242b9fd1f 100644
--- a/modules/overviews/app/components/overviews/show_component.html.erb
+++ b/modules/overviews/app/components/overviews/show_component.html.erb
@@ -51,7 +51,7 @@ See COPYRIGHT and LICENSE files for more details.
if allowed_to_manage?
concat(
- render(Primer::OpenProject::SubHeader.new) do |subheader|
+ render(Primer::OpenProject::SubHeader.new(classes: { "grid-mx": sidebar_enabled? })) do |subheader|
subheader.with_action_button(
scheme: :primary,
leading_icon: :plus,
diff --git a/modules/overviews/spec/components/overviews/show_component_spec.rb b/modules/overviews/spec/components/overviews/show_component_spec.rb
index b98e9688ddc..910f0bf4f50 100644
--- a/modules/overviews/spec/components/overviews/show_component_spec.rb
+++ b/modules/overviews/spec/components/overviews/show_component_spec.rb
@@ -97,6 +97,28 @@ RSpec.describe Overviews::ShowComponent, type: :component do
expect(button["data-action"]).to include "click->overview--add-widgets#addWidget"
end
end
+
+ context "when project has no attributes or life cycle" do
+ it "renders subheader with no margin" do
+ expect(rendered_component).to have_css ".SubHeader", class: "!grid-mx"
+ end
+ end
+
+ context "when project has life cycle and user has permissions to view" do
+ let(:project) { build(:project) }
+ let!(:project_phase) { create(:project_phase, project:) }
+
+ before do
+ mock_permissions_for(user) do |mock|
+ mock.allow_in_project(:manage_overview, project:)
+ mock.allow_in_project(:view_project_phases, project:)
+ end
+ end
+
+ it "renders subheader with horizontal margin matching widget gap" do
+ expect(rendered_component).to have_css ".SubHeader", class: "grid-mx"
+ end
+ end
end
context "when project has neither project attributes or life cycle" do