From f717b684a2967aac304babc299d764129a634ec7 Mon Sep 17 00:00:00 2001 From: Alexander Brandon Coles Date: Wed, 8 Jan 2025 08:17:35 -0300 Subject: [PATCH 1/4] [#60359] Harmonise FeedbackDialog slot naming Renames the `additional_content` slot to `additional_details` to make Feedback Dialog consistent with the newly introduced Danger Confirmation Dialog. ViewComponent defines a `with_SLOT_NAME_content` method for given slots. Using `additional_content` as a slot name results in a `with_additonal_content_content` method being generated - this makes for a poor API for component users. --- .../primer/open_project/feedback_dialog.html.erb | 4 ++-- app/components/primer/open_project/feedback_dialog.rb | 6 +++--- .../playground.html.erb | 2 +- .../primer/open_project/feedback_dialog_preview.rb | 10 +++++----- ...al_content.html.erb => additional_details.html.erb} | 2 +- .../feedback_dialog_preview/playground.html.erb | 6 +++--- .../primer/open_project/feedback_dialog_test.rb | 6 +++--- 7 files changed, 18 insertions(+), 18 deletions(-) rename previews/primer/open_project/feedback_dialog_preview/{additional_content.html.erb => additional_details.html.erb} (89%) diff --git a/app/components/primer/open_project/feedback_dialog.html.erb b/app/components/primer/open_project/feedback_dialog.html.erb index b9de1f6859..a4b102865e 100644 --- a/app/components/primer/open_project/feedback_dialog.html.erb +++ b/app/components/primer/open_project/feedback_dialog.html.erb @@ -1,8 +1,8 @@ <%= render @dialog do |dialog| %> <% dialog.with_body do %> <%= feedback_message %> - <% if additional_content.present? %> - <%= additional_content %> + <% if additional_details.present? %> + <%= additional_details %> <% end %> <% end %> <% dialog.with_footer do %> diff --git a/app/components/primer/open_project/feedback_dialog.rb b/app/components/primer/open_project/feedback_dialog.rb index bf12929e7a..bc1951d015 100644 --- a/app/components/primer/open_project/feedback_dialog.rb +++ b/app/components/primer/open_project/feedback_dialog.rb @@ -17,15 +17,15 @@ class FeedbackDialog < Primer::Component Primer::OpenProject::FeedbackMessage.new(icon_arguments: icon_arguments, **system_arguments) } - # Optional additional_content like a form input or toast. + # Optional additional_details like a form input or toast. # # @param system_arguments [Hash] <%= link_to_system_arguments_docs %> - renders_one :additional_content, lambda { |**system_arguments| + renders_one :additional_details, lambda { |**system_arguments| deny_tag_argument(**system_arguments) system_arguments[:tag] = :div system_arguments[:classes] = class_names( system_arguments[:classes], - "FeedbackDialog-additionalContent" + "FeedbackDialog-additionalDetails" ) system_arguments[:display] ||= :flex diff --git a/previews/primer/open_project/danger_confirmation_dialog_preview/playground.html.erb b/previews/primer/open_project/danger_confirmation_dialog_preview/playground.html.erb index cee05ef801..8e2f98b5f5 100644 --- a/previews/primer/open_project/danger_confirmation_dialog_preview/playground.html.erb +++ b/previews/primer/open_project/danger_confirmation_dialog_preview/playground.html.erb @@ -6,7 +6,7 @@ <% end %> <% if show_additional_details %> <% dialog.with_additional_details do %> - <%= render(Primer::Alpha::Banner.new) { "Some additional content below" } %> + <%= render(Primer::Alpha::Banner.new) { "Some additional details below" } %> <% end %> <% end %> <% dialog.with_confirmation_check_box_content(check_box_text) %> diff --git a/previews/primer/open_project/feedback_dialog_preview.rb b/previews/primer/open_project/feedback_dialog_preview.rb index 27b6bff5be..c20262df70 100644 --- a/previews/primer/open_project/feedback_dialog_preview.rb +++ b/previews/primer/open_project/feedback_dialog_preview.rb @@ -24,19 +24,19 @@ def default # @param icon_color [Symbol] select [default, muted, subtle, accent, success, attention, severe, danger, open, closed, done, sponsors, on_emphasis, inherit] # @param loading_state [Boolean] toggle # @param show_description toggle - # @param show_additional_content toggle + # @param show_additional_details toggle # @param custom_footer toggle - def playground(icon: :"check-circle", icon_color: :success, loading_state: false, show_description: true, show_additional_content: false, custom_footer: false) + def playground(icon: :"check-circle", icon_color: :success, loading_state: false, show_description: true, show_additional_details: false, custom_footer: false) render_with_template(locals: { icon: icon, icon_color: icon_color, loading_state: loading_state, show_description: show_description, - show_additional_content: show_additional_content, + show_additional_details: show_additional_details, custom_footer: custom_footer }) end - # @label With additional content - def additional_content + # @label With additional details + def additional_details render_with_template(locals: {}) end diff --git a/previews/primer/open_project/feedback_dialog_preview/additional_content.html.erb b/previews/primer/open_project/feedback_dialog_preview/additional_details.html.erb similarity index 89% rename from previews/primer/open_project/feedback_dialog_preview/additional_content.html.erb rename to previews/primer/open_project/feedback_dialog_preview/additional_details.html.erb index ada7f18e73..4504f0caef 100644 --- a/previews/primer/open_project/feedback_dialog_preview/additional_content.html.erb +++ b/previews/primer/open_project/feedback_dialog_preview/additional_details.html.erb @@ -3,7 +3,7 @@ <% dialog.with_feedback_message do |message| %> <% message.with_heading(tag: :h2).with_content("Action successful") %> <% end %> - <% dialog.with_additional_content do %> + <% dialog.with_additional_details do %> <% render(Primer::Beta::Text.new) { "You can render whatever component you want here." } %> <% end %> <% end %> diff --git a/previews/primer/open_project/feedback_dialog_preview/playground.html.erb b/previews/primer/open_project/feedback_dialog_preview/playground.html.erb index f08960864c..1f47f7132a 100644 --- a/previews/primer/open_project/feedback_dialog_preview/playground.html.erb +++ b/previews/primer/open_project/feedback_dialog_preview/playground.html.erb @@ -4,9 +4,9 @@ <% message.with_heading(tag: :h2).with_content("Awesome!") %> <% message.with_description { "Great! Everything worked well." } if show_description %> <% end %> - <% if show_additional_content %> - <% dialog.with_additional_content(display: :inline) do %> - <%= render(Primer::Alpha::Banner.new) { "Some additional content below" } %> + <% if show_additional_details %> + <% dialog.with_additional_details(display: :inline) do %> + <%= render(Primer::Alpha::Banner.new) { "Some additional details below" } %> <% end %> <% end %> <% if custom_footer %> diff --git a/test/components/primer/open_project/feedback_dialog_test.rb b/test/components/primer/open_project/feedback_dialog_test.rb index eb9997570f..23720242fb 100644 --- a/test/components/primer/open_project/feedback_dialog_test.rb +++ b/test/components/primer/open_project/feedback_dialog_test.rb @@ -19,16 +19,16 @@ def test_renders end end - def test_renders_additional_content + def test_renders_additional_details render_inline(Primer::OpenProject::FeedbackDialog.new) do |dialog| dialog.with_feedback_message do |message| message.with_heading(tag: :h2) { "Success" } end - dialog.with_additional_content { "Some additional content" } + dialog.with_additional_details { "Some additional details" } end assert_selector("dialog.FeedbackDialog") do - assert_selector(".FeedbackDialog-additionalContent", text: "Some additional content") + assert_selector(".FeedbackDialog-additionalDetails", text: "Some additional details") end end From e278cb84783ff0e799b374ad28675cbe06b20247 Mon Sep 17 00:00:00 2001 From: Alexander Brandon Coles Date: Fri, 10 Jan 2025 09:55:12 -0300 Subject: [PATCH 2/4] Harmonise FeedbackDialog preview template naming Makes naming of Feedback Dialog preview templates consistent with those used by newly introduced Danger Confirmation Dialog. --- previews/primer/open_project/feedback_dialog_preview.rb | 4 ++-- ...onal_details.html.erb => with_additional_details.html.erb} | 0 .../{custom_footer.html.erb => with_custom_footer.html.erb} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename previews/primer/open_project/feedback_dialog_preview/{additional_details.html.erb => with_additional_details.html.erb} (100%) rename previews/primer/open_project/feedback_dialog_preview/{custom_footer.html.erb => with_custom_footer.html.erb} (100%) diff --git a/previews/primer/open_project/feedback_dialog_preview.rb b/previews/primer/open_project/feedback_dialog_preview.rb index c20262df70..3234f2c7ca 100644 --- a/previews/primer/open_project/feedback_dialog_preview.rb +++ b/previews/primer/open_project/feedback_dialog_preview.rb @@ -36,7 +36,7 @@ def playground(icon: :"check-circle", icon_color: :success, loading_state: false end # @label With additional details - def additional_details + def with_additional_details render_with_template(locals: {}) end @@ -52,7 +52,7 @@ def custom_icon end # @label With custom footer - def custom_footer + def with_custom_footer render_with_template(locals: {}) end diff --git a/previews/primer/open_project/feedback_dialog_preview/additional_details.html.erb b/previews/primer/open_project/feedback_dialog_preview/with_additional_details.html.erb similarity index 100% rename from previews/primer/open_project/feedback_dialog_preview/additional_details.html.erb rename to previews/primer/open_project/feedback_dialog_preview/with_additional_details.html.erb diff --git a/previews/primer/open_project/feedback_dialog_preview/custom_footer.html.erb b/previews/primer/open_project/feedback_dialog_preview/with_custom_footer.html.erb similarity index 100% rename from previews/primer/open_project/feedback_dialog_preview/custom_footer.html.erb rename to previews/primer/open_project/feedback_dialog_preview/with_custom_footer.html.erb From e3a93b72299395d039758b1fda8ec78d51687127 Mon Sep 17 00:00:00 2001 From: Alexander Brandon Coles Date: Fri, 10 Jan 2025 10:11:28 -0300 Subject: [PATCH 3/4] Create changeset --- .changeset/short-students-type.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/short-students-type.md diff --git a/.changeset/short-students-type.md b/.changeset/short-students-type.md new file mode 100644 index 0000000000..7fd2b45245 --- /dev/null +++ b/.changeset/short-students-type.md @@ -0,0 +1,5 @@ +--- +'@openproject/primer-view-components': minor +--- + +[#60359] Harmonise FeedbackDialog slot naming: renames the `additional_content` slot to `additional_details` to make Feedback Dialog consistent with the newly introduced Danger Confirmation Dialog. From dae6eae34648390cd75112115bd86017ee26dd6d Mon Sep 17 00:00:00 2001 From: Henriette Darge Date: Fri, 10 Jan 2025 16:18:16 +0100 Subject: [PATCH 4/4] Generate static files --- static/info_arch.json | 12 ++++++------ static/previews.json | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/static/info_arch.json b/static/info_arch.json index 6f5345669b..1b3584ed8d 100644 --- a/static/info_arch.json +++ b/static/info_arch.json @@ -17497,8 +17497,8 @@ ] }, { - "name": "additional_content", - "description": "Optional additional_content like a form input or toast.", + "name": "additional_details", + "description": "Optional additional_details like a form input or toast.", "parameters": [ { "name": "system_arguments", @@ -17547,8 +17547,8 @@ } }, { - "preview_path": "primer/open_project/feedback_dialog/additional_content", - "name": "additional_content", + "preview_path": "primer/open_project/feedback_dialog/with_additional_details", + "name": "with_additional_details", "snapshot": "false", "skip_rules": { "wont_fix": [ @@ -17573,8 +17573,8 @@ } }, { - "preview_path": "primer/open_project/feedback_dialog/custom_footer", - "name": "custom_footer", + "preview_path": "primer/open_project/feedback_dialog/with_custom_footer", + "name": "with_custom_footer", "snapshot": "false", "skip_rules": { "wont_fix": [ diff --git a/static/previews.json b/static/previews.json index 39d5c2f821..2e65785c39 100644 --- a/static/previews.json +++ b/static/previews.json @@ -3680,8 +3680,8 @@ } }, { - "preview_path": "primer/open_project/feedback_dialog/additional_content", - "name": "additional_content", + "preview_path": "primer/open_project/feedback_dialog/with_additional_details", + "name": "with_additional_details", "snapshot": "false", "skip_rules": { "wont_fix": [ @@ -3706,8 +3706,8 @@ } }, { - "preview_path": "primer/open_project/feedback_dialog/custom_footer", - "name": "custom_footer", + "preview_path": "primer/open_project/feedback_dialog/with_custom_footer", + "name": "with_custom_footer", "snapshot": "false", "skip_rules": { "wont_fix": [