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

Fix hyrax js not rendering correctly #5672

Merged
merged 1 commit into from
Jun 9, 2022
Merged

Conversation

abelemlih
Copy link
Contributor

I attached notes to each to clarify the reasoning behind it and what it is intended to achieve.


//= require hyrax
JS
insert_into_file 'app/assets/javascripts/application.js', after: "//= require blacklight/blacklight\n" do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the generation of a new app using Rails 6, the application.js generated is missing //= require_tree ., which led to the failure of the inseration of the Hyrax js. This change insures the inclusion of hyrax is inserted below blacklight/blacklight, which is a core dependency that will always be included when the test app is generated.

@@ -5,6 +5,14 @@ class TestAppGenerator < Rails::Generators::Base
# so the following path gets us to /path/to/hyrax/spec/test_app_templates/
source_root File.expand_path('../../../../spec/test_app_templates/', __FILE__)

def install_turbolinks
gem 'turbolinks', '~> 5'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test app generated using Rails 6 and engine_cart is missing turbolinks by default, and the test app or any app dependent on Hyrax cannot function properly unless it includes turbolinks. I tried including turbolinks in the hyrax gemspec, but that does not set it up correctly, and leads to the following error:

couldn't find file 'turbolinks' with type 'application/javascript'

@@ -198,7 +206,7 @@ def configure_action_cable_to_use_redis
end

def install_universal_viewer
raise '`yarn install` failed!' unless system('./bin/yarn install')
raise '`yarn install` failed!' unless system('yarn install')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

./bin/yarn install fails while yarn install succeeds, which is why I made the switch. Unless there is a particular reason behind the use of ./bin/yarn install, this change should be ok.

'--skip-bootsnap',
'--skip-listen',
'--skip-test',
'--skip-javascript',
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 added an override of the engine_cart:create_test_rails_app primarily to enforce skipping javascript in the generation of a new Rails app by default. In Rails 6, unless you use --skip-javascript, the webpacker gem is installed and leads to a variety of changes and errors on the app.

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of overriding engine_cart, can we instead update relevant documentation and the CI config to insert --skip-javascript using the ENGINE_CART_RAILS_OPTIONS environment variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dlpierce I added the change you recommended, and I deleted the engine_cart.yml file, because it overrides the options set in the circleci config, and currently has a bug that does not allow for adding multiple options. Please refer to this thread for more details: cbeer/engine_cart#102

@abelemlih abelemlih marked this pull request as ready for review June 9, 2022 15:57
@abelemlih abelemlih requested review from dlpierce and bwatson78 June 9, 2022 16:04
Copy link
Contributor

@bwatson78 bwatson78 left a comment

Choose a reason for hiding this comment

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

I'll pass on my approval, seeing that it greatly reduces the failures, but I'd really love someone with more time in the project being the deciding vote to merge this.

@abelemlih abelemlih force-pushed the abel-hyrax_js_fix branch from 14463b3 to 3af711d Compare June 9, 2022 18:55
'--skip-bootsnap',
'--skip-listen',
'--skip-test',
'--skip-javascript',
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of overriding engine_cart, can we instead update relevant documentation and the CI config to insert --skip-javascript using the ENGINE_CART_RAILS_OPTIONS environment variable?

@abelemlih abelemlih requested a review from dlpierce June 9, 2022 20:41
@abelemlih abelemlih force-pushed the abel-hyrax_js_fix branch from 9643936 to df201e3 Compare June 9, 2022 20:54
@abelemlih abelemlih merged commit 95ecddd into bl7boot4rails6 Jun 9, 2022
@abelemlih abelemlih deleted the abel-hyrax_js_fix branch June 9, 2022 21:09
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.

3 participants