flipper-ui 1.4.1 → 1.5.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/flipper/ui/action.rb +46 -35
  3. data/lib/flipper/ui/actions/actors_gate.rb +17 -3
  4. data/lib/flipper/ui/actions/cloud_migrate.rb +1 -0
  5. data/lib/flipper/ui/actions/features.rb +5 -1
  6. data/lib/flipper/ui/actions/groups_gate.rb +6 -1
  7. data/lib/flipper/ui/actions/import.rb +21 -2
  8. data/lib/flipper/ui/actions/percentage_of_actors_gate.rb +2 -0
  9. data/lib/flipper/ui/actions/percentage_of_time_gate.rb +2 -0
  10. data/lib/flipper/ui/configuration.rb +12 -1
  11. data/lib/flipper/ui/decorators/feature.rb +6 -12
  12. data/lib/flipper/ui/error.rb +2 -2
  13. data/lib/flipper/ui/middleware.rb +10 -0
  14. data/lib/flipper/ui/public/images/logo.png +0 -0
  15. data/lib/flipper/ui/util.rb +5 -4
  16. data/lib/flipper/ui/views/feature.erb +8 -0
  17. data/lib/flipper/ui/views/layout.erb +15 -7
  18. data/lib/flipper/ui/views/settings.erb +23 -18
  19. data/lib/flipper/ui.rb +4 -1
  20. data/lib/flipper/version.rb +1 -1
  21. metadata +5 -32
  22. data/examples/ui/authorization.ru +0 -48
  23. data/examples/ui/basic.ru +0 -71
  24. data/examples/ui/prefixed.ru +0 -21
  25. data/examples/ui/read_only.ru +0 -43
  26. data/flipper-ui.gemspec +0 -29
  27. data/lib/flipper/ui/decorators/gate.rb +0 -37
  28. data/lib/flipper/ui/public/js/jquery-3.6.0.slim.js +0 -8782
  29. data/spec/flipper/ui/action_spec.rb +0 -76
  30. data/spec/flipper/ui/actions/actors_gate_spec.rb +0 -201
  31. data/spec/flipper/ui/actions/add_feature_spec.rb +0 -57
  32. data/spec/flipper/ui/actions/boolean_gate_spec.rb +0 -139
  33. data/spec/flipper/ui/actions/cloud_migrate_spec.rb +0 -54
  34. data/spec/flipper/ui/actions/export_spec.rb +0 -51
  35. data/spec/flipper/ui/actions/feature_spec.rb +0 -254
  36. data/spec/flipper/ui/actions/features_spec.rb +0 -233
  37. data/spec/flipper/ui/actions/file_spec.rb +0 -21
  38. data/spec/flipper/ui/actions/groups_gate_spec.rb +0 -144
  39. data/spec/flipper/ui/actions/home_spec.rb +0 -14
  40. data/spec/flipper/ui/actions/import_spec.rb +0 -41
  41. data/spec/flipper/ui/actions/percentage_of_actors_gate_spec.rb +0 -65
  42. data/spec/flipper/ui/actions/percentage_of_time_gate_spec.rb +0 -65
  43. data/spec/flipper/ui/actions/settings_spec.rb +0 -35
  44. data/spec/flipper/ui/configuration_spec.rb +0 -218
  45. data/spec/flipper/ui/decorators/feature_spec.rb +0 -59
  46. data/spec/flipper/ui/decorators/gate_spec.rb +0 -45
  47. data/spec/flipper/ui/util_spec.rb +0 -17
  48. data/spec/flipper/ui_spec.rb +0 -197
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '019dbf0664d70ba33fd6425f7ba20bff41a1be13ff42c97b184ea37c2c500fd5'
4
- data.tar.gz: d1f2131f1d38cc5aa1ac4b0b5cc1298c914e8d4fd6e6f8693f218f6802977e8b
3
+ metadata.gz: 9ea72780ce1cf2a406b7aab69a313469100bb4bd332d8dd09e5b7020a851cc28
4
+ data.tar.gz: 457c80398ddf72d7d4777965c1868c57b1b9b811d02c3fc6e657006150eb9ee6
5
5
  SHA512:
6
- metadata.gz: 9cee5defa8de58857b30dabf3db81047e61b1138bfaa090817d2b9b0732bc662bf7b1eaa4e5973cb59ae1ded71ccda44c178901450ccd20c7b2ebec5b79f292b
7
- data.tar.gz: 011ba0f8d3db3ef0efaab5e684d79beb9fee04c28dc660ec394b1cdfab37ac1c0af3c83ab3f1731a623cdd92a159d87c8f157f269b0d1eac269603603eba18be
6
+ metadata.gz: 4ad0f71231b3b5296d330233493d2bb71c730094c2c39e763b40c9c1744df986b85235e7c3b7cc53ce3b8b1c40bea0e2e3d4fcbb686c535a56db5c46a6b1527a
7
+ data.tar.gz: 89affedb8ee0900ba9be1ebe8665a6ee4f99336ab19093b081062351647f480937d7afa095c48199d1b9139e65c8315aa35665574b59076a0670015b9c839611
@@ -29,6 +29,7 @@ module Flipper
29
29
  extend Forwardable
30
30
 
31
31
  VALID_REQUEST_METHOD_NAMES = Set.new([
32
+ 'head'.freeze,
32
33
  'get'.freeze,
33
34
  'post'.freeze,
34
35
  'put'.freeze,
@@ -103,31 +104,31 @@ module Flipper
103
104
  @headers = {Rack::CONTENT_TYPE => 'text/plain'}
104
105
  end
105
106
 
107
+ # Public: The banner text for this UI. An app built with
108
+ # Flipper::UI.app(flipper, banner_text: "...") uses its own, so two UIs
109
+ # (say, the default and a named instance) can be told apart.
110
+ def banner_text
111
+ request.env.fetch(Middleware::BANNER_ENV_KEY, {}).fetch(:text) { Flipper::UI.configuration.banner_text }
112
+ end
113
+
114
+ # Public: The banner's Bootstrap alert class for this UI.
115
+ def banner_class
116
+ request.env.fetch(Middleware::BANNER_ENV_KEY, {}).fetch(:class) { Flipper::UI.configuration.banner_class }
117
+ end
118
+
106
119
  # Public: Runs the request method for the provided request.
107
120
  #
108
121
  # Returns whatever the request method returns in the action.
109
122
  def run
110
- if valid_request_method? && respond_to?(request_method_name)
111
- catch(:halt) { send(request_method_name) }
112
- else
113
- raise UI::RequestMethodNotSupported,
114
- "#{self.class} does not support request method #{request_method_name.inspect}"
115
- end
116
- end
123
+ catch(:halt) do
124
+ method_not_allowed unless valid_request_method? && respond_to?(request_method_name)
117
125
 
118
- # Public: Runs another action from within the request method of a
119
- # different action.
120
- #
121
- # action_class - The class of the other action to run.
122
- #
123
- # Examples
124
- #
125
- # run_other_action Home
126
- # # => result of running Home action
127
- #
128
- # Returns result of other action.
129
- def run_other_action(action_class)
130
- action_class.new(flipper, request).run
126
+ begin
127
+ send(request_method_name)
128
+ rescue ReservedKeyError => error
129
+ redirect_to("/features/#{Util.escape error.key}?error=#{Util.escape reserved_name_error(error.key)}")
130
+ end
131
+ end
131
132
  end
132
133
 
133
134
  # Public: Call this with a response to immediately stop the current action
@@ -191,19 +192,6 @@ module Flipper
191
192
  @headers[name] = value
192
193
  end
193
194
 
194
- class Breadcrumb
195
- attr_reader :text, :href
196
-
197
- def initialize(text, href = nil)
198
- @text = text
199
- @href = href
200
- end
201
-
202
- def active?
203
- @href.nil?
204
- end
205
- end
206
-
207
195
  # Private
208
196
  def view_with_layout(&block)
209
197
  view :layout, &block
@@ -219,7 +207,8 @@ module Flipper
219
207
  path = views_path.join("#{name}.erb")
220
208
  raise "Template does not exist: #{path}" unless path.exist?
221
209
 
222
- eval(Erubi::Engine.new(path.read, escape: true).src)
210
+ # Views are UTF-8 (layout.erb has "‹"), whatever Ruby's default encoding is.
211
+ eval(Erubi::Engine.new(path.read(encoding: Encoding::UTF_8), escape: true).src)
223
212
  end
224
213
 
225
214
  # Internal: The path the app is mounted at.
@@ -249,7 +238,24 @@ module Flipper
249
238
 
250
239
  # Private: Returns the request method converted to an action method.
251
240
  def request_method_name
252
- @request_method_name ||= @request.request_method.downcase
241
+ @request_method_name ||= action_method_name(@request.request_method.downcase)
242
+ end
243
+
244
+ # Private: The action method that answers a request method. HEAD is
245
+ # answered by get.
246
+ def action_method_name(name)
247
+ name == "head" ? "get" : name
248
+ end
249
+
250
+ # Private: Responds 405 with an Allow header listing the methods this
251
+ # action answers.
252
+ def method_not_allowed
253
+ allowed = VALID_REQUEST_METHOD_NAMES.select do |name|
254
+ respond_to?(action_method_name(name))
255
+ end
256
+ status 405
257
+ header 'allow', allowed.map(&:upcase).join(', ')
258
+ halt [@code, @headers, ['Method Not Allowed']]
253
259
  end
254
260
 
255
261
  def csrf_input_tag
@@ -275,6 +281,11 @@ module Flipper
275
281
  !read_only?
276
282
  end
277
283
 
284
+ # Internal: The error shown for a feature name reserved for Flipper.
285
+ def reserved_name_error(key)
286
+ "#{key.inspect} is reserved for Flipper's internal use."
287
+ end
288
+
278
289
  def bootstrap_css
279
290
  asset_hash "/css/bootstrap.min.css"
280
291
  end
@@ -1,6 +1,7 @@
1
1
  require 'flipper/ui/action'
2
2
  require 'flipper/ui/decorators/feature'
3
3
  require 'flipper/ui/util'
4
+ require 'flipper/adapters/actor_limit'
4
5
 
5
6
  module Flipper
6
7
  module UI
@@ -21,11 +22,16 @@ module Flipper
21
22
 
22
23
  feature = flipper[feature_name]
23
24
  value = params['value'].to_s.strip
24
- values = value.split(UI.configuration.actors_separator).map(&:strip).uniq
25
+ # The Remove button posts one enabled actor, whose id may contain the
26
+ # separator (e.g. "OrderItem;[1, 2]" from a composite primary key).
27
+ values = if params['operation'] == 'disable' && feature.actors_value.include?(value)
28
+ [value]
29
+ else
30
+ value.split(UI.configuration.actors_separator).map(&:strip).uniq
31
+ end
25
32
 
26
33
  if values.empty?
27
- error = "#{value.inspect} is not a valid actor value."
28
- redirect_to("/features/#{Flipper::UI::Util.escape feature.key}/actors?error=#{Flipper::UI::Util.escape error}")
34
+ redirect_to_form(feature, "#{value.inspect} is not a valid actor value.")
29
35
  end
30
36
 
31
37
  values.each do |value|
@@ -40,6 +46,14 @@ module Flipper
40
46
  end
41
47
 
42
48
  redirect_to("/features/#{Flipper::UI::Util.escape feature.key}")
49
+ rescue Flipper::Adapters::ActorLimit::LimitExceeded => exception
50
+ redirect_to_form(feature, exception.message)
51
+ end
52
+
53
+ private
54
+
55
+ def redirect_to_form(feature, error)
56
+ redirect_to("/features/#{Flipper::UI::Util.escape feature.key}/actors?error=#{Flipper::UI::Util.escape error}")
43
57
  end
44
58
  end
45
59
  end
@@ -1,5 +1,6 @@
1
1
  require 'flipper/ui/action'
2
2
  require 'flipper/ui/util'
3
+ require 'flipper/cloud/migrate'
3
4
 
4
5
  module Flipper
5
6
  module UI
@@ -41,13 +41,17 @@ module Flipper
41
41
  halt view_response(:feature_creation_disabled)
42
42
  end
43
43
 
44
- value = params['value'].to_s.strip
44
+ value = Util.normalize_feature_name(params['value'])
45
45
 
46
46
  if Util.blank?(value)
47
47
  error = "#{value.inspect} is not a valid feature name."
48
48
  redirect_to("/features/new?error=#{Flipper::UI::Util.escape error}")
49
49
  end
50
50
 
51
+ if Flipper.reserved_key?(value)
52
+ redirect_to("/features/new?error=#{Flipper::UI::Util.escape reserved_name_error(value)}")
53
+ end
54
+
51
55
  feature = flipper[value]
52
56
  feature.add
53
57
 
@@ -22,7 +22,7 @@ module Flipper
22
22
  feature = flipper[feature_name]
23
23
  value = params['value'].to_s.strip
24
24
 
25
- if Flipper.group_exists?(value)
25
+ if flipper.group_exists?(value)
26
26
  case params['operation']
27
27
  when 'enable'
28
28
  feature.enable_group value
@@ -30,6 +30,11 @@ module Flipper
30
30
  feature.disable_group value
31
31
  end
32
32
 
33
+ redirect_to("/features/#{Flipper::UI::Util.escape feature.key}")
34
+ elsif params['operation'] == 'disable'
35
+ # Only enabling needs a registered group. Removing one that was
36
+ # unregistered after it was enabled has to work too.
37
+ feature.disable_group value
33
38
  redirect_to("/features/#{Flipper::UI::Util.escape feature.key}")
34
39
  else
35
40
  error = "The group named #{value.inspect} has not been registered."
@@ -8,10 +8,29 @@ module Flipper
8
8
  route %r{\A/settings\/import/?\Z}
9
9
 
10
10
  def post
11
- contents = params['file'][:tempfile].read
12
- export = Flipper::Exporters::Json::Export.new(contents: contents)
11
+ render_read_only if read_only?
12
+
13
+ file = params['file']
14
+ unless file.is_a?(Hash) && file[:tempfile]
15
+ redirect_to_settings("You must select a file to import.")
16
+ end
17
+
18
+ tempfile = file[:tempfile]
19
+ if tempfile.size > Flipper::Exporters::Json::Export::MAX_BYTES
20
+ redirect_to_settings("The import file is too large to import.")
21
+ end
22
+
23
+ export = Flipper::Exporters::Json::Export.new(contents: tempfile.read)
13
24
  flipper.import(export)
14
25
  redirect_to "/features"
26
+ rescue Flipper::Exporters::Json::InvalidError
27
+ redirect_to_settings("The import file is invalid.")
28
+ end
29
+
30
+ private
31
+
32
+ def redirect_to_settings(error)
33
+ redirect_to "/settings?error=#{Flipper::UI::Util.escape(error)}"
15
34
  end
16
35
  end
17
36
  end
@@ -17,6 +17,8 @@ module Flipper
17
17
 
18
18
  begin
19
19
  feature.enable_percentage_of_actors params['value']
20
+ rescue ReservedKeyError
21
+ raise
20
22
  rescue ArgumentError => exception
21
23
  error = "Invalid percentage of actors value: #{exception.message}"
22
24
  redirect_to("/features/#{Flipper::UI::Util.escape @feature.key}?error=#{Flipper::UI::Util.escape error}")
@@ -17,6 +17,8 @@ module Flipper
17
17
 
18
18
  begin
19
19
  feature.enable_percentage_of_time params['value']
20
+ rescue ReservedKeyError
21
+ raise
20
22
  rescue ArgumentError => exception
21
23
  error = "Invalid percentage of time value: #{exception.message}"
22
24
  redirect_to("/features/#{Flipper::UI::Util.escape @feature.key}?error=#{Flipper::UI::Util.escape error}")
@@ -45,6 +45,11 @@ module Flipper
45
45
  # false and it will go away. Defaults to true.
46
46
  attr_accessor :cloud_recommendation
47
47
 
48
+ # Public: Set to false to disable the version check that fetches the
49
+ # latest release from flippercloud.io. Useful when a strict Content
50
+ # Security Policy is in place. Defaults to true.
51
+ attr_accessor :version_check_enabled
52
+
48
53
  # Public: What should show up in the form to add actors. This can be
49
54
  # different per application since flipper_id's can be whatever an
50
55
  # application needs. Defaults to "a flipper id".
@@ -114,6 +119,7 @@ module Flipper
114
119
  @feature_removal_enabled = true
115
120
  @fun = true
116
121
  @cloud_recommendation = true
122
+ @version_check_enabled = true
117
123
  @add_actor_placeholder = "a flipper id"
118
124
  @descriptions_source = DEFAULT_DESCRIPTIONS_SOURCE
119
125
  @actor_names_source = DEFAULT_ACTOR_NAMES_SOURCE
@@ -146,11 +152,16 @@ module Flipper
146
152
  end
147
153
 
148
154
  def banner_class=(value)
155
+ @banner_class = self.class.validate_banner_class(value)
156
+ end
157
+
158
+ # Internal: Returns value, or raises if it isn't a valid banner class.
159
+ def self.validate_banner_class(value)
149
160
  unless VALID_BANNER_CLASS_VALUES.include?(value)
150
161
  raise InvalidConfigurationValue, "The banner_class provided '#{value}' is " \
151
162
  "not one of: #{VALID_BANNER_CLASS_VALUES.join(', ')}"
152
163
  end
153
- @banner_class = value
164
+ value
154
165
  end
155
166
  end
156
167
  end
@@ -1,5 +1,4 @@
1
1
  require 'delegate'
2
- require 'flipper/ui/decorators/gate'
3
2
  require 'flipper/ui/util'
4
3
 
5
4
  module Flipper
@@ -19,11 +18,6 @@ module Flipper
19
18
  # configured for Flipper::UI.
20
19
  attr_accessor :actor_names
21
20
 
22
- # Public: Returns name titleized.
23
- def pretty_name
24
- @pretty_name ||= Util.titleize(name)
25
- end
26
-
27
21
  def color_class
28
22
  case feature.state
29
23
  when :on
@@ -41,11 +35,13 @@ module Flipper
41
35
  statuses = []
42
36
 
43
37
  if feature.actors_value.count > 0
44
- statuses << %Q(<span data-toggle="tooltip" data-placement="bottom" title="#{Util.to_sentence(feature.actors_value.to_a)}">) + Util.pluralize(feature.actors_value.count, 'actor', 'actors') + "</span>"
38
+ title = Rack::Utils.escape_html(Util.to_sentence(feature.actors_value.to_a))
39
+ statuses << %Q(<span data-toggle="tooltip" data-placement="bottom" title="#{title}">) + Util.pluralize(feature.actors_value.count, 'actor', 'actors') + "</span>"
45
40
  end
46
41
 
47
42
  if feature.groups_value.count > 0
48
- statuses << %Q(<span data-toggle="tooltip" data-placement="bottom" title="#{Util.to_sentence(feature.groups_value.to_a)}">) + Util.pluralize(feature.groups_value.count, 'group', 'groups') + "</span>"
43
+ title = Rack::Utils.escape_html(Util.to_sentence(feature.groups_value.to_a))
44
+ statuses << %Q(<span data-toggle="tooltip" data-placement="bottom" title="#{title}">) + Util.pluralize(feature.groups_value.count, 'group', 'groups') + "</span>"
49
45
  end
50
46
 
51
47
  if feature.percentage_of_actors_value > 0
@@ -56,6 +52,8 @@ module Flipper
56
52
  statuses << "#{feature.percentage_of_time_value}% of time"
57
53
  end
58
54
 
55
+ statuses << "an expression" if feature.expression_value
56
+
59
57
  Util.to_sentence(statuses)
60
58
  end
61
59
 
@@ -70,10 +68,6 @@ module Flipper
70
68
  end
71
69
  end
72
70
 
73
- def pretty_enabled_gate_names
74
- enabled_gates.map { |gate| Util.titleize(gate.key) }.sort.join(', ')
75
- end
76
-
77
71
  StateSortMap = {
78
72
  on: 1,
79
73
  conditional: 2,
@@ -3,8 +3,8 @@ module Flipper
3
3
  # All flipper ui errors inherit from this.
4
4
  Error = Class.new(StandardError)
5
5
 
6
- # Raised when a request method (get, post, etc.) is called for an action
7
- # that does not know how to handle it.
6
+ # No longer raised: actions answer 405 for request methods they don't
7
+ # handle. Kept so code that rescues it still loads.
8
8
  RequestMethodNotSupported = Class.new(Error)
9
9
  end
10
10
  end
@@ -1,3 +1,4 @@
1
+ require 'pathname'
1
2
  require 'rack'
2
3
  require 'flipper/ui/action_collection'
3
4
 
@@ -9,10 +10,18 @@ end
9
10
  module Flipper
10
11
  module UI
11
12
  class Middleware
13
+ # Internal: Where this app's own banner travels to the actions.
14
+ BANNER_ENV_KEY = 'flipper.ui.banner'.freeze
15
+
12
16
  def initialize(app, options = {})
13
17
  @app = app
14
18
  @env_key = options.fetch(:env_key, 'flipper')
15
19
  @flipper = options.fetch(:flipper) { Flipper }
20
+ @banner = {}
21
+ @banner[:text] = options[:banner_text] if options[:banner_text]
22
+ if (banner_class = options[:banner_class])
23
+ @banner[:class] = Configuration.validate_banner_class(banner_class)
24
+ end
16
25
 
17
26
  @action_collection = ActionCollection.new
18
27
 
@@ -48,6 +57,7 @@ module Flipper
48
57
  if action_class.nil?
49
58
  @app.call(env)
50
59
  else
60
+ env[BANNER_ENV_KEY] = @banner unless @banner.empty?
51
61
  flipper = env.fetch(@env_key) { Flipper }
52
62
  action_class.run(flipper, request)
53
63
  end
Binary file
@@ -1,4 +1,5 @@
1
1
  require "rack/utils"
2
+ require "flipper/typecast"
2
3
 
3
4
  module Flipper
4
5
  module UI
@@ -14,6 +15,10 @@ module Flipper
14
15
  Rack::Utils.unescape(str)
15
16
  end
16
17
 
18
+ def self.normalize_feature_name(str)
19
+ Typecast.to_feature_name(str)
20
+ end
21
+
17
22
  def self.blank?(str)
18
23
  str.to_s !~ NON_WHITESPACE_REGEXP
19
24
  end
@@ -22,10 +27,6 @@ module Flipper
22
27
  !blank?(str)
23
28
  end
24
29
 
25
- def self.titleize(str)
26
- str.to_s.split('_').map(&:capitalize).join(' ')
27
- end
28
-
29
30
  def self.truncate(str, length: 30)
30
31
  if str.length > length
31
32
  str[0..length]
@@ -245,6 +245,14 @@
245
245
  </div>
246
246
  <% end %>
247
247
  </div>
248
+
249
+ <% if (expression = @feature.expression_value) %>
250
+ <%# Expression (read only, set with the Ruby or HTTP API) %>
251
+ <div class="card-body border-bottom">
252
+ <h6><strong>Enabled for an expression</strong></h6>
253
+ <code class="text-break"><%= Flipper::Typecast.to_json(expression) %></code>
254
+ </div>
255
+ <% end %>
248
256
  <% end %>
249
257
 
250
258
  <% if write_allowed? %>
@@ -11,15 +11,17 @@
11
11
  </head>
12
12
  <body class="py-4">
13
13
  <div class="container mw-600">
14
- <%- unless Flipper::UI.configuration.banner_text.nil? -%>
15
- <div class="alert alert-<%= Flipper::UI.configuration.banner_class %> text-center fw-bold">
16
- <%== Sanitize.fragment(Flipper::UI.configuration.banner_text, Sanitize::Config::BASIC) %>
14
+ <%- unless banner_text.nil? -%>
15
+ <div class="alert alert-<%= banner_class %> text-center fw-bold">
16
+ <%== Sanitize.fragment(banner_text, Sanitize::Config::BASIC) %>
17
17
  </div>
18
18
  <%- end -%>
19
19
 
20
20
  <div class="text-muted small text-end">
21
- <a href="#" class="badge text-bg-warning ms-2 d-none" style="font-size:100%" id="new-version-badge" data-version="<%= Flipper::VERSION %>">
22
- </a>
21
+ <% if Flipper::UI.configuration.version_check_enabled %>
22
+ <a href="#" class="badge text-bg-warning ms-2 d-none" style="font-size:100%" id="new-version-badge" data-version="<%= Flipper::VERSION %>">
23
+ </a>
24
+ <% end %>
23
25
 
24
26
  <% if Flipper.deprecated_ruby_version? %>
25
27
  <a href="https://github.com/flippercloud/flipper/pull/776" class="badge text-bg-danger ms-2" style="font-size:100%">
@@ -55,6 +57,10 @@
55
57
  <li class="nav-item ms-auto text-muted small">
56
58
  <a href="https://www.flippercloud.io/docs/ui?utm_source=oss&utm_medium=ui&utm_campaign=docs">Docs</a>
57
59
  &bull;
60
+ <% if Flipper::UI.configuration.fun %>
61
+ <a href="https://shop.verygoodsoftware.company/product/i-deploy-on-fridays-tee?utm_source=oss&utm_medium=ui&utm_campaign=merch" title="Do you deploy on Fridays?">Shirt</a>
62
+ &bull;
63
+ <% end %>
58
64
  Version: <%= Flipper::VERSION %>
59
65
  </li>
60
66
  </ul>
@@ -73,7 +79,7 @@
73
79
  </a>
74
80
  </div>
75
81
  <div class="col text-muted p-0">
76
- <small>For audit history, rollback, finer-grained permissions, and multi-environment sync check out <a href="https://www.flippercloud.io/?utm_source=oss&utm_medium=ui&utm_campaign=spread_the_love">Flipper&nbsp;Cloud</a>. We even have a free tier!</small>
82
+ <small>For audit history, rollback, finer-grained permissions, multi-environment sync, and an MCP server that finds flags ready to remove, check out <a href="https://www.flippercloud.io/?utm_source=oss&utm_medium=ui&utm_campaign=spread_the_love">Flipper&nbsp;Cloud</a>. We even have a free tier!</small>
77
83
  </div>
78
84
  </div>
79
85
  </div>
@@ -83,6 +89,8 @@
83
89
  <script src="<%= script_name + popper_js[:src] %>" integrity="<%= popper_js[:hash] %>" crossorigin="anonymous"></script>
84
90
  <script src="<%= script_name + bootstrap_js[:src] %>" integrity="<%= bootstrap_js[:hash] %>" crossorigin="anonymous"></script>
85
91
  <script src="<%= script_name %>/js/application.js?v=<%= Flipper::VERSION %>"></script>
86
- <script src="<%= script_name %>/js/version.js?v=<%= Flipper::VERSION %>"></script>
92
+ <% if Flipper::UI.configuration.version_check_enabled %>
93
+ <script src="<%= script_name %>/js/version.js?v=<%= Flipper::VERSION %>"></script>
94
+ <% end %>
87
95
  </body>
88
96
  </html>
@@ -2,28 +2,31 @@
2
2
  <div class="alert alert-danger"><%= params["error"] %></div>
3
3
  <% end %>
4
4
 
5
- <div class="card mb-4">
6
- <div class="card-header">
7
- <h4 class="m-0">Migrate to Flipper Cloud</h4>
8
- </div>
9
- <div class="card-body">
10
- <p>Flipper Cloud gives you audit history, rollback, finer-grained permissions, and multi-environment sync. We even have a free tier!</p>
5
+ <% if Flipper::UI.configuration.cloud_recommendation %>
6
+ <div class="card mb-4">
7
+ <div class="card-header">
8
+ <h4 class="m-0">Migrate to Flipper Cloud</h4>
9
+ </div>
10
+ <div class="card-body">
11
+ <p>Flipper Cloud gives you audit history, rollback, finer-grained permissions, multi-environment sync, and an MCP server for AI assistants. We even have a free tier!</p>
11
12
 
12
- <ul class="mb-3">
13
- <li>Audit log of every feature change</li>
14
- <li>Instant rollback to any previous state</li>
15
- <li>Team permissions and approval workflows</li>
16
- <li>Sync flags across environments</li>
17
- </ul>
13
+ <ul class="mb-3">
14
+ <li>Audit log of every feature change</li>
15
+ <li>Instant rollback to any previous state</li>
16
+ <li>Team permissions and approval workflows</li>
17
+ <li>Sync flags across environments</li>
18
+ <li>MCP server so AI assistants can find flags ready to remove</li>
19
+ </ul>
18
20
 
19
- <p>You have <strong><%= flipper.features.count %></strong> <%= flipper.features.count == 1 ? 'feature' : 'features' %> ready to migrate.</p>
21
+ <p>You have <strong><%= flipper.features.count %></strong> <%= flipper.features.count == 1 ? 'feature' : 'features' %> ready to migrate.</p>
20
22
 
21
- <form action="<%= script_name %>/settings/cloud" method="post">
22
- <%== csrf_input_tag %>
23
- <input type="submit" value="Migrate to Flipper Cloud" class="btn btn-primary">
24
- </form>
23
+ <form action="<%= script_name %>/settings/cloud" method="post">
24
+ <%== csrf_input_tag %>
25
+ <input type="submit" value="Migrate to Flipper Cloud" class="btn btn-primary">
26
+ </form>
27
+ </div>
25
28
  </div>
26
- </div>
29
+ <% end %>
27
30
 
28
31
  <div class="card mb-4 ">
29
32
  <div class="card-header">
@@ -38,6 +41,7 @@
38
41
  </div>
39
42
  </div>
40
43
 
44
+ <% if write_allowed? %>
41
45
  <div class="card">
42
46
  <div class="card-header">
43
47
  <h4 class="m-0">Import</h4>
@@ -51,3 +55,4 @@
51
55
  </form>
52
56
  </div>
53
57
  </div>
58
+ <% end %>
data/lib/flipper/ui.rb CHANGED
@@ -7,6 +7,7 @@ rescue LoadError
7
7
  require 'rack/methodoverride'
8
8
  end
9
9
  require 'rack/protection'
10
+ require 'rack/session'
10
11
 
11
12
  require 'flipper'
12
13
  require 'flipper/ui/middleware'
@@ -29,6 +30,7 @@ module Flipper
29
30
  app = ->(_) { [200, { Rack::CONTENT_TYPE => 'text/html' }, ['']] }
30
31
  builder = Rack::Builder.new
31
32
  yield builder if block_given?
33
+ builder.use Rack::Head
32
34
 
33
35
  # Only use Rack::Protection::AuthenticityToken if no other options are
34
36
  # provided. Should avoid some pain for some people. If any options are
@@ -42,7 +44,8 @@ module Flipper
42
44
 
43
45
  builder.use Rack::MethodOverride
44
46
  builder.use Flipper::Middleware::SetupEnv, flipper, env_key: env_key
45
- builder.use Flipper::UI::Middleware, flipper: flipper, env_key: env_key
47
+ builder.use Flipper::UI::Middleware, flipper: flipper, env_key: env_key,
48
+ banner_text: options[:banner_text], banner_class: options[:banner_class]
46
49
  builder.run app
47
50
  klass = self
48
51
  app = builder.to_app
@@ -1,5 +1,5 @@
1
1
  module Flipper
2
- VERSION = '1.4.1'.freeze
2
+ VERSION = '1.5.0.rc1'.freeze
3
3
 
4
4
  REQUIRED_RUBY_VERSION = '2.6'.freeze
5
5
  NEXT_REQUIRED_RUBY_VERSION = '3.0'.freeze