Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/flipper/ui/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ class Configuration
# Default is false.
attr_accessor :confirm_disable

# Public: An array of scripts to include in the UI. Each script should be
# a hash with a `:src` key and optionally a `:integrity` key. Example:
# config.scripts << { src: "https://example.com/script.js", integrity: "sha384-abc123" }
attr_accessor :scripts

VALID_BANNER_CLASS_VALUES = %w(
danger
dark
Expand Down Expand Up @@ -111,6 +116,7 @@ def initialize
{ title: "Features", href: "features" },
{ title: "Settings", href: "settings" },
]
@scripts = []
end

def using_descriptions?
Expand Down
11 changes: 11 additions & 0 deletions lib/flipper/ui/views/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,16 @@
<script src="<%= script_name + bootstrap_js[:src] %>" integrity="<%= bootstrap_js[:hash] %>" crossorigin="anonymous"></script>
<script src="<%= script_name %>/js/application.js?v=<%= Flipper::VERSION %>"></script>
<script src="<%= script_name %>/js/version.js?v=<%= Flipper::VERSION %>"></script>
<% unless Flipper::UI.configuration.scripts.empty? %>
<% Flipper::UI.configuration.scripts.each do |script| %>
<script
src="<%= script[:src] %>"
<% if script[:integrity].present? %>
integrity="<%= script[:integrity] %>"
<% end %>
crossorigin="anonymous">
</script>
<% end %>
<% end %>
</body>
</html>
11 changes: 11 additions & 0 deletions spec/flipper/ui/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,15 @@
it { is_expected.to eq(true) }
end
end

describe "#scripts" do
it "has default value" do
expect(configuration.scripts).to eq([])
end

it "can be updated" do
configuration.scripts << { src: "https://example.com/script.js", integrity: "sha384-abc123" }
expect(configuration.scripts).to eq([{ src: "https://example.com/script.js", integrity: "sha384-abc123" }])
end
end
end