Skip to content

Commit

Permalink
Delegate primary_action and secondary_action
Browse files Browse the repository at this point in the history
  • Loading branch information
HDinger committed Sep 4, 2024
1 parent 68a1fde commit 2a500c9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-poets-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openproject/primer-view-components': patch
---

Delegate calls for `primary_action` and `secondary_action` from FeedbackMessage to the `Blankslate`
2 changes: 2 additions & 0 deletions app/components/primer/open_project/feedback_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def initialize(icon_arguments: {}, loading: false, **system_arguments)

delegate :description?, :description, :with_description, :with_description_content,
:heading?, :heading, :with_heading, :with_heading_content,
:primary_action?, :primary_action, :with_primary_action, :with_primary_action_content,
:secondary_action?, :secondary_action, :with_secondary_action, :with_secondary_action_content,
to: :@blankslate

private
Expand Down
8 changes: 8 additions & 0 deletions previews/primer/open_project/feedback_message_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ def loading_spinner
component.with_heading(tag: :h2) { "Please wait, your request is being processed." }
end
end

# @label With secondary action
def secondary_action
render(Primer::OpenProject::FeedbackMessage.new(loading: true)) do |component|
component.with_heading(tag: :h2) { "Please wait, your request is being processed." }
component.with_secondary_action(href: "#").with_content("Skip")
end
end
end
end
end
14 changes: 12 additions & 2 deletions test/components/primer/open_project/feedback_message_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,21 @@ def test_custom_icon
end

def test_renders_loading_spinner
render_inline(Primer::OpenProject::FeedbackMessage.new(loading: true)) do |dialog|
dialog.with_heading(tag: :h2) { "Ups, something went wrong" }
render_inline(Primer::OpenProject::FeedbackMessage.new(loading: true)) do |component|
component.with_heading(tag: :h2) { "Ups, something went wrong" }
end

assert_selector("h2", text: "Ups, something went wrong")
assert_selector("img.blankslate-image[src^='/assets/loading_indicator']")
end

def test_renders_secondary_action
render_inline(Primer::OpenProject::FeedbackMessage.new) do |component|
component.with_heading(tag: :h2) { "Secondary Action" }
component.with_secondary_action(href: "/blubs").with_content("Skip")
end

assert_selector("h2", text: "Secondary Action")
assert_selector("a[href='/blubs']", text: "Skip")
end
end

0 comments on commit 2a500c9

Please sign in to comment.