X Tutup
The Wayback Machine - https://web.archive.org/web/20220512140826/https://github.com/github/view_component/pull/1269
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

Move preview controller logic into concern #1269

Merged
merged 3 commits into from May 4, 2022

Conversation

sammyhenningsson
Copy link
Contributor

@sammyhenningsson sammyhenningsson commented Feb 10, 2022

Make it easier to get ViewComponent previews into an existing app.

If we want previews to be shown inside existing application layouts, which requires application logic. E.g. url helpers and helper methods like current_user etc. Then we need write a custom controller, and either write all the preview stuff from scratch or copy and paste from ViewComponentsController. If we instead move the content of ViewComponentsController inside a module, then we could just mixin this logic into the application code. Then applications only need something like this:

#app/controllers/view_component_preview_controller.rb
class ViewComponentPreviewController < ApplicationController
  include ViewComponent::PreviewActions
end
#config/application.rb
config.view_component.preview_controller = "ViewComponentPreviewController"

And we are free to use all the application specific stuff that comes with ApplicationController

docs/CHANGELOG.md Outdated Show resolved Hide resolved
@joelhawksley joelhawksley merged commit e8c85a4 into github:main May 4, 2022
43 checks passed
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.

None yet

2 participants
X Tutup