Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate primary_action and secondary_action #172

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading