rails / mission_control-jobs

Dashboard and Active Job extensions to operate and troubleshoot background jobs
MIT License
604 stars 70 forks source link

Support for cssbundling-rails? #164

Open olinelson opened 1 month ago

olinelson commented 1 month ago

I'm currently trying to use mission_control-jobs with a setup utilising cssbundling-rails.

Whilst Sprockets seems to compile Mission Control's assets perfectly fine they aren't provided as stylesheet links to the application layout by default. I've tried adding stylesheet links to my layout manually but that seems to only partially fix the problem.

application.html.erb

      <%= stylesheet_link_tag "mission_control/jobs/application", "data-turbo-track": "reload" %>
      <%= stylesheet_link_tag "mission_control/jobs/forms", "data-turbo-track": "reload" %>
      <%= stylesheet_link_tag "mission_control/jobs/jobs", "data-turbo-track": "reload" %>

Somewhat adding to my confusion is the fact that the view renders only the queues table not the tabs or navbar:

Screenshot 2024-09-23 at 7 14 25 PM

Is there an existing way for things to play nicely with cssbundling-rails?

HamptonMakes commented 1 month ago

Hmm, I have to ask what your goal is? Why are you including anything Mission Control related in your main application layout?

Mission Control is a Rails Engine that is supposed to have full control and management of it's own assets and layout.

Generally, you install the Gem, and then when you mount it into your Routes, you use that path and everything is taken care of for you! No need to modify anything in your application.

olinelson commented 1 month ago

Hi @HamptonMakes, thanks for your response. My goal is to simply display Mission Control at my application's /jobs path. I started going down the path of experimenting with assets as the default behaviour of Mission Control (with my css-bundling-rails setup) seems to not work...

I assume it's something to do with css-bundling-rails as Mission Control works fine on another project of mine with a no-build css setup.

Any pointers or theories greatly appreciated.

Cheers!

rosa commented 1 week ago

Hey @olinelson, sorry for the delay! I also don't quite understand very well what's happening here 😕 What happens if you simply mount Mission Control on /jobs in your routes? What kind of error do you get?

kivanio commented 1 day ago

If you have content_security_policy enabled in your app.

You will need to add the css 'bulma', used by mission_control to the style_src, otherwise it will not work.

Rails.application.configure do
  config.content_security_policy do |policy|
      policy.style_src       :self, 'https://cdn.jsdelivr.net/npm/bulma@1.0.1/css/bulma.min.css'
 end
end

It should be documented. Or added by default when loading mission_control.

rosa commented 1 day ago

@kivanio good point. I'm going to vendor https://cdn.jsdelivr.net/npm/bulma@1.0.1/css/bulma.min.css instead, so that you don't need to set your CSP to allow it.

rosa commented 1 day ago

https://github.com/rails/mission_control-jobs/pull/206

rosa commented 1 day ago

I released 0.6.0 with that change and other changes I had pending. @olinelson do you think the CSP was your problem?

kivanio commented 1 day ago

ohh that was fast 🚀 good work @rosa 👍🏻

I confirm it working now