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
Add empty state for /developers
#484
Conversation
4cb8e07
to
2822a84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! I requested some small copy and design tweaks.
Other than that, I don't love the inline logic for dynamically setting the copy. Let's create a new component that inherits from EmptyStateComponent
and move the logic into the new component.
@joemasilotti I believe the best change is to add a new argument to the existing If you don't like that, I can make a EmptyDevelopersComponent and push the logic inside of there. I was unable to test that functionality though. When I stub out the Rails.env, for some reason a Stripe API request gets dispatched 🤷 # test/components/empty_state_component_test.rb
class EmptyStateComponentTest < ViewComponent::TestCase
# ...
test "Renders title, unseeded_body and icon" do
title = "No notifications"
body = "Nothing to see"
unseeded_body = "Seed the database"
User.destroy_all
Rails.stub(:env, ActiveSupport::StringInquirer.new('development')) do
render_inline(EmptyStateComponent.new(title:, body:, unseeded_body:, icon: "icons/brands/github.svg"))
assert_selector("h3", text: title)
assert_selector("p", text: unseeded_body)
assert_selector "svg[title='GitHub logo']"
end
end
end |
Instead of stubbing Env we can inject the environment via an initializer.
|
@joemasilotti Thanks for the feedback! I added a new Observation: I'm not sure if where I ended up is far from where you would have gone yourself, but it does seem like there's a lot more lines of code just to rewrite the initial ternary in the template by introducing a new component. I don't have visibility into opportunities for reuse of the component though, so if there are future plans for lots of Developers views, I could see it being worth it. |
Apologies, my quickly written response earlier wasn't very clear. I meant to only pass in the environment to the View Component and then do the querying and dev check inside the component. It's not documented (yet), but all of the components inside a domain folder are not meant to be reused outside of their specific application. They should be treated like glorified partials (with testing). The components that live at the root level of (I'm hoping to document some of this in So for this component I would rather have it know how to query for zero developers if there are no results and if we are in the development environment. That way we can pass only the environment flag or nothing at all in. Does that make sense? |
@joemasilotti I think it makes sense. I made changes inline with my understanding. Hopefully it meets your needs 😄 More broadly, I think this is just some unsurfaced complexity. Thinking through it:
|
That's an excellent point! I'd love to change the scope of this PR to handle just that, if you have the appetite.
How does that sound? |
@joemasilotti sounds good 👍 I'll slightly rewrite the issue and let's split it into 2 PRs. That way we can land the relatively simple empty state and get that benefit to users, and then land the development message. |
Co-authored-by: Joe Masilotti <joe@masilotti.com>
Co-authored-by: Joe Masilotti <joe@masilotti.com>
Co-authored-by: Joe Masilotti <joe@masilotti.com>
9c2abec
to
21430bb
Compare
Good idea. Let me know when this one is ready for another review. |
@joemasilotti this is ready for another review 😄 |
I also just pushed up #494 for db:seed hinting. I can rebase it once this PR goes in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two tiny suggestions and we are good to merge!
Co-authored-by: Joe Masilotti <joe@masilotti.com>
Co-authored-by: Joe Masilotti <joe@masilotti.com>
Awesome! Thanks for the contribution and feedback on this one. I like where it ended up much better than what I originally imagined. 💪 |
Connects to #472.
I used the existing
EmptyStateComponent
to structure the content. Is the language and icon appropriate?Pull request checklist
bin/check