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

refactoring navbar as component with slot for prepend component #3171

Merged
merged 6 commits into from
Oct 7, 2024

Conversation

hudajkhan
Copy link
Contributor

@hudajkhan hudajkhan commented Oct 4, 2024

Closes #3167 .

What this pull request does:

  • Capture the logic previously in the views/shared/_exhibit_navbar partial into a component (Spotlight::ExhibitNavbarComponent), providing a slot for content to prepend in the view. The slot will allow implementation for search tips in Stanford's Spotlight implementation.
  • Replicate the view based tests in the component test, updating specific view configuration/context information.
  • Add a test that checks if overriding the prepend_to_search method will display that content in the page.
  • Remove the view based test from spec/views/shared.
  • The _exhibit_navbar partial now renders the component. The code checks for catalog controller configuration for the Exhibit Navbar Component to display. If none is available, Spotlight::ExhibitNavbarComponent is used.
  • A deprecation method has also been added in order to support the use of a component within blacklight configuration.

@hudajkhan hudajkhan marked this pull request as ready for review October 4, 2024 23:56
<% end %>
</div>
</div>
<%= render (blacklight_config&.view_config(document_index_view_type)&.exhibit_navbar_component || Spotlight::ExhibitNavbarComponent).new %>
Copy link
Contributor

@dnoneill dnoneill Oct 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should probably be defined in the controller somewhere. i.e. in the catalogcontroller you should define

config.index.exhibit_navbar_component = Spotlight::ExhibitNavbarComponent

I would also update the deprecation warning to point to the catalog controller where it is set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've addresses both comments @dnoneill

</div>
</div>
<%= render (blacklight_config&.view_config(document_index_view_type)&.exhibit_navbar_component || Spotlight::ExhibitNavbarComponent).new %>
<% Spotlight.deprecator.warn("_exhibit_navbar.html.erb will be deprecated in future versions. Please use the catalog controller's exhibit_navbar_component setting.") %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<% Spotlight.deprecator.warn("_exhibit_navbar.html.erb will be deprecated in future versions. Please use the catalog controller's exhibit_navbar_component setting.") %>
<% Spotlight.deprecator.warn("_exhibit_navbar.html.erb will be removed; customize the exhibit navbar using components instead") %>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corylown I used a period instead of a semi-colon but otherwise it is the same :)

@@ -16,6 +16,7 @@ class CatalogController < ApplicationController
# Blacklight 8 sets a default value to 'advanced'
config.json_solr_path = nil
config.header_component = Spotlight::HeaderComponent
config.exhibit_navbar_component = Spotlight::ExhibitNavbarComponent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this is config.index?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the question is, does it make sense to configure a different navbar depending on whether you're in the index or show view, or should this be configurable at the app level like the header component?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it matters, but either this or this https://github.com/projectblacklight/spotlight/pull/3171/files#diff-de18dc9392ca38402d097f5d638e554a17c8b0ba6b2e341fe46ca6188e05cf1cR9 line need to be updated to be inline with each other.

@corylown corylown merged commit 5fd1d64 into main Oct 7, 2024
6 checks passed
@corylown corylown deleted the navbarcomponent branch October 7, 2024 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert _exhibit_navbar.html.erb to a component with slots for adding content before and after the search bar
3 participants