-
Notifications
You must be signed in to change notification settings - Fork 127
Move preview controllers to the engine #3501
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
Move preview controllers to the engine #3501
Conversation
|
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.
Pull Request Overview
Moves server-side preview controllers and views into the Primer::ViewComponents
Rails engine and updates form helper paths to point at the new engine routes.
- Updates
ImmediateValidationForm
to use engine routes for auto-check endpoints - Adds a suite of preview controllers under
app/controllers/primer/view_components
- Introduces an engine-level
ApplicationController
for all preview controllers
Reviewed Changes
Copilot reviewed 69 out of 69 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
app/forms/immediate_validation_form.rb | Updated auto_check_src to use engine route helpers |
app/controllers/primer/view_components/application_controller.rb | New base controller for engine previews |
app/controllers/primer/view_components/toggle_switch_controller.rb | Added preview controller for toggle switch |
app/controllers/primer/view_components/select_panel_items_controller.rb | Added preview controller for select panel items |
app/controllers/primer/view_components/nav_list_items_controller.rb | Added preview controller for nav list pagination |
app/controllers/primer/view_components/multi_controller.rb | Added preview controller for multi-input form |
app/controllers/primer/view_components/include_fragment_controller.rb | Added preview controller for fragment inclusion |
app/controllers/primer/view_components/form_handler_controller.rb | Added preview controller for form submission demo |
app/controllers/primer/view_components/auto_complete_test_controller.rb | Added preview controller for autocomplete behavior |
app/controllers/primer/view_components/auto_check_controller.rb | Added preview controller for auto-check behaviors |
app/controllers/primer/view_components/action_menu_controller.rb | Added preview controller for action menu demos |
Comments suppressed due to low confidence (2)
app/controllers/primer/view_components/select_panel_items_controller.rb:21
- The page offset calculation is incorrect. For page 1 it yields -2. It should likely be
(params[:page].to_i - 1) * items_per_page
.
start_index = (params[:page].to_i - items_per_page) * items_per_page
app/controllers/primer/view_components/toggle_switch_controller.rb:1
- Consider adding a basic request spec to verify the
create
endpoint returns the correct status and handles thefail
parameter.
# frozen_string_literal: true
Thanks @camertron There's a failure still going on, something about a missing method in the forms previews? |
…tron/view_components into move_preview_controllers_to_engine
@jonrohan whoops, should be fixed now 😄 |
@jonrohan oops, looks like there was one more URL helper that needed to be fixed. Should be good now. Feel like adding me to the list of users allowed to kick off workflow runs? 😉 |
What are you trying to accomplish?
Hey everyone 👋 I'm contracting with the OpenProject team for the next few weeks on a couple of new Primer components they need for their app. The OP team mounts all Primer's component previews inside their app's Lookbook, much like GitHub does inside dotcom's Lookbook. Several of PVC's previews however rely on server-side behavior in controllers and views that live in the demo app, eg. demo/app/controllers and demo/app/views. This means that, while some previews render just fine in OP's Lookbook, some error out or simply don't work.
This PR addresses the issue by moving these controllers and views into PVC's Rails engine. This makes them accessible to a host application via Rails' engine mounting mechanism. In other words, a host app can make everything Just Work™ by adding the following to the app's config/routes.rb:
I have verified everything works as expected inside OpenProject's app. This change should not affect dotcom or any other GitHub property, as the functionality in question is dev-only (or at least, not user-facing) and maintains all existing functionality.
Can't stop, won't stop!
Integration
No changes necessary in production.
Risk Assessment
Accessibility
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.