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
Define additional_label slot in AttributeHelpTextComponent
Alexander Brandon Coles259721f14dd3
diff --git a/app/components/open_project/common/attribute_help_text_component.html.erb b/app/components/open_project/common/attribute_help_text_component.html.erbindex f8d11778925..da8ef6ce857 100644--- a/app/components/open_project/common/attribute_help_text_component.html.erb+++ b/app/components/open_project/common/attribute_help_text_component.html.erb@@ -1,6 +1,9 @@-<%=- render Primer::Beta::Link.new(**@system_arguments) do- render Primer::Beta::Octicon.new(:question, size: :xsmall)- end-%>+<%= render Primer::Beta::Link.new(**@system_arguments) do |link| %>+ <% if additional_label? %>+ <% link.with_trailing_visual_icon(icon: :question, size: :xsmall) %>+ <%= additional_label %>+ <% else %>+ <%= render Primer::Beta::Octicon.new(:question, size: :xsmall) %>+ <% end %>+<% end %><%= render @tooltip %>diff --git a/app/components/open_project/common/attribute_help_text_component.rb b/app/components/open_project/common/attribute_help_text_component.rbindex e77160b11c3..39ca919b119 100644--- a/app/components/open_project/common/attribute_help_text_component.rb+++ b/app/components/open_project/common/attribute_help_text_component.rb@@ -31,6 +31,10 @@module OpenProjectmodule Commonclass AttributeHelpTextComponent < ApplicationComponent+ renders_one :additional_label, lambda { |**system_arguments|+ Primer::Beta::Text.new(**system_arguments)+ }+def initialize(help_text:, **system_arguments) # rubocop:disable Metrics/AbcSizesuper()diff --git a/spec/components/open_project/common/attribute_help_text_component_spec.rb b/spec/components/open_project/common/attribute_help_text_component_spec.rbindex a33014b3d3f..438c0a4c5ca 100644--- a/spec/components/open_project/common/attribute_help_text_component_spec.rb+++ b/spec/components/open_project/common/attribute_help_text_component_spec.rb@@ -33,8 +33,10 @@ require "rails_helper"RSpec.describe OpenProject::Common::AttributeHelpTextComponent, type: :component doinclude Rails.application.routes.url_helpers+ let(:block) { nil }+subject do- render_inline(described_class.new(help_text:))+ render_inline(described_class.new(help_text:), &block)pageend@@ -77,6 +79,31 @@ RSpec.describe OpenProject::Common::AttributeHelpTextComponent, type: :componentexpect(subject).to have_no_css ".Link-content"endend++ context "with an additional label" do+ let(:block) do+ proc do |help_text|+ help_text.with_additional_label_content "Normal Help Text Link"+ end+ end++ it "renders additional label content" do+ expect(subject).to have_css ".Link-content", text: "Normal Help Text Link"+ end+ end++ context "with an additional styled label" do+ let(:block) do+ proc do |help_text|+ help_text.with_additional_label(font_weight: :bold) { "Bold Help Text Link" }+ end+ end++ it "renders additional label content" do+ expect(subject).to have_css ".Link-content", text: "Bold Help Text Link"+ expect(subject).to have_css ".text-bold", text: "Bold Help Text Link"+ end+ endendshared_examples "component does not render" do