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

[#64471] Teach Status Component to render help text

Alexander Brandon Coles7a520e224272
diff --git a/app/components/projects/status_button_component.html.erb b/app/components/projects/status_button_component.html.erb
new file mode 100644
index 00000000000..88a5e178f35
--- /dev/null
+++ b/app/components/projects/status_button_component.html.erb
@@ -0,0 +1,29 @@
+<%=
+ component_wrapper do
+ flex_layout(align_items: :center) do |flex|
+ flex.with_column do
+ render(
+ OpPrimer::StatusButtonComponent.new(
+ current_status: build_item(@status),
+ items: build_items,
+ readonly: !edit_enabled?,
+ disabled: !edit_enabled?,
+ button_arguments: {
+ title: t("projects.status.button_edit"),
+ size: @size
+ }
+ )
+ )
+ end
+ flex.with_column(mr: 2) do
+ render(
+ OpenProject::Common::AttributeLabelComponent.new(
+ attribute: :status,
+ model: project,
+ current_user: user
+ )
+ )
+ end
+ end
+ end
+%>
diff --git a/app/components/projects/status_button_component.rb b/app/components/projects/status_button_component.rb
index dd7a9cc4d88..c2f64e25377 100644
--- a/app/components/projects/status_button_component.rb
+++ b/app/components/projects/status_button_component.rb
@@ -46,23 +46,6 @@ class Projects::StatusButtonComponent < ApplicationComponent
@status = find_status(project.status_code)
end
- def call
- component_wrapper do
- render(
- OpPrimer::StatusButtonComponent.new(
- current_status: build_item(@status),
- items: build_items,
- readonly: !edit_enabled?,
- disabled: !edit_enabled?,
- button_arguments: {
- title: t("projects.status.button_edit"),
- size: @size
- }
- )
- )
- end
- end
-
private
def edit_enabled?
diff --git a/spec/components/projects/status_button_component_spec.rb b/spec/components/projects/status_button_component_spec.rb
index c583a651b89..a74b7795dcc 100644
--- a/spec/components/projects/status_button_component_spec.rb
+++ b/spec/components/projects/status_button_component_spec.rb
@@ -69,6 +69,20 @@ RSpec.describe Projects::StatusButtonComponent, type: :component do
it "does not render a Primer ActionMenu" do
expect(subject).not_to have_element "action-menu"
end
+
+ context "without attribute help text" do
+ it "does not render help text" do
+ expect(subject).to have_no_element class: "op-attribute-help-text"
+ end
+ end
+
+ context "with attribute help text" do
+ let!(:help_text) { create(:project_help_text, attribute_name: :status) }
+
+ it "renders help text" do
+ expect(subject).to have_element class: "op-attribute-help-text"
+ end
+ end
end
context "when the user has project edit permissions" do
@@ -131,5 +145,19 @@ RSpec.describe Projects::StatusButtonComponent, type: :component do
end
end
end
+
+ context "without attribute help text" do
+ it "does not render help text" do
+ expect(subject).to have_no_element class: "op-attribute-help-text"
+ end
+ end
+
+ context "with attribute help text" do
+ let!(:help_text) { create(:project_help_text, attribute_name: :status) }
+
+ it "renders help text" do
+ expect(subject).to have_element class: "op-attribute-help-text"
+ end
+ end
end
end