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

Load extra JS scripts into flipper-ui #873

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nicastelo
Copy link

Adds the ability to load extra JS scripts into flipper UI.

Added a new field scripts to lib/flipper/ui/configuration.rb so it allows to load scripts into the layout of flipper-ui.

Usage:

Flipper::UI.configure do |config|
  config.scripts << { src: "https://example.com/script.js" }
end

@jnunemaker
Copy link
Collaborator

@nicastelo hey! Looks good. I'm curious what the use case is. I'd love to know that prior to merging.

@nicastelo
Copy link
Author

@nicastelo hey! Looks good. I'm curious what the use case is. I'd love to know that prior to merging.

Thanks!

In my case, I wanted to load some extra content into the page, like a list of actors to select from. Apart from that, this feature could be useful for adding custom styles or have some company branding, like a logo. It can even be useful for tracking stuff on the frontend side if you wanted to.

Initially, I thought I could extend the ERB views but didn’t find an easy way to do so, apart from potentially monkey-patching and creating another set of views. With JS, I can simply load whatever content I want onto the page.

@jnunemaker
Copy link
Collaborator

Ok, sorry for the delay. I'm back cleaning up flipper issues and re-read this. This PR looks great -- clean code and specs.

But I'm struggling with allowing random scripts. My concern is the scripts are out of my control yet I may get issues and have to debug them only to find out it was a custom script. It also means that the html becomes a bit of an "open" api. If I change the html then others scripts will fail.

I think I'd prefer to make explicit configuration for each part people want to customize.

For your list of actors, would it just be a select for that and that's all? Or would you also allow people putting in their own actors via text field too?

@jnunemaker
Copy link
Collaborator

If you don't mind, I would love to know what you are using flipper for as well and how it is working out for you (what went well, what was hard other than what you mentioned here).

If you aren't comfortable leaving that information here in a public comment, feel free to email me directly [email protected]. I'm just always curious. :)

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.

2 participants