Choosing between React or ERB Layout


#1

Hello everyone.
We are ready to create a Full React view, starting with the Audits page. I wrote a component that is essentially app/views/layouts/_application_content.html.erb in React.

When rendering a React page, application_content.html.erb should not be rendered,
We thought the best approach is to create a class ReactController < ApplicationController that will contain a boolean telling the Layout its a React View. Thoughts?

Thanks :slight_smile:


#2

That’s good news. Please note that the expire_hosts plugin does some overrides on the audits page and that we should make sure not to break the plugin.

That sounds sane to me. We probably want to have that controller for all SPA pages anyways.


#3

@TimoGoebel I think it is going to be blocker issue because we still don’t have a ready solution for extending react components/pages.

I love the idea of using ReactController :+1:
I afraid boolean telling the layout what kind of layout to render can lead us to abuse it in a way we will start add if react do .. else do .. in too many places.

I prefer a solution when we have different layout files for react pages. (we can reuse whatever stay the same between layouts).

This is basically the approach @amirfefer and I went throw when we implemented the POC for SPA:

The react controller:

The non-react layout (layout with content):

The react layout (layout without content):


#4

Implemented @sharvit suggestion.

PR is up!


#5

Is there a way to test it? currently the Audits table is already in React, so there is no reason the plugin shouldn’t work (if its working now)


#6

This functionality was broken when the audit page was moved to react. I just noticed now. I believe we need a solution for this. Plugin’s are key to Foreman’s success in the community and we’re currently doing a great job making it hard for plugin authors.