flipper-ui 1.4.2 → 1.5.0.rc2
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.
- checksums.yaml +4 -4
- data/lib/flipper/ui/action.rb +46 -35
- data/lib/flipper/ui/actions/actors_gate.rb +17 -3
- data/lib/flipper/ui/actions/cloud_migrate.rb +1 -0
- data/lib/flipper/ui/actions/features.rb +5 -1
- data/lib/flipper/ui/actions/groups_gate.rb +6 -1
- data/lib/flipper/ui/actions/import.rb +20 -2
- data/lib/flipper/ui/actions/percentage_of_actors_gate.rb +2 -0
- data/lib/flipper/ui/actions/percentage_of_time_gate.rb +2 -0
- data/lib/flipper/ui/configuration.rb +6 -1
- data/lib/flipper/ui/decorators/feature.rb +6 -12
- data/lib/flipper/ui/error.rb +2 -2
- data/lib/flipper/ui/middleware.rb +10 -0
- data/lib/flipper/ui/public/images/logo.png +0 -0
- data/lib/flipper/ui/util.rb +5 -4
- data/lib/flipper/ui/views/feature.erb +8 -0
- data/lib/flipper/ui/views/layout.erb +8 -4
- data/lib/flipper/ui/views/settings.erb +21 -18
- data/lib/flipper/ui.rb +4 -1
- data/lib/flipper/version.rb +1 -1
- metadata +5 -32
- data/examples/ui/authorization.ru +0 -48
- data/examples/ui/basic.ru +0 -71
- data/examples/ui/prefixed.ru +0 -21
- data/examples/ui/read_only.ru +0 -43
- data/flipper-ui.gemspec +0 -29
- data/lib/flipper/ui/decorators/gate.rb +0 -37
- data/lib/flipper/ui/public/js/jquery-3.6.0.slim.js +0 -8782
- data/spec/flipper/ui/action_spec.rb +0 -76
- data/spec/flipper/ui/actions/actors_gate_spec.rb +0 -201
- data/spec/flipper/ui/actions/add_feature_spec.rb +0 -57
- data/spec/flipper/ui/actions/boolean_gate_spec.rb +0 -139
- data/spec/flipper/ui/actions/cloud_migrate_spec.rb +0 -54
- data/spec/flipper/ui/actions/export_spec.rb +0 -51
- data/spec/flipper/ui/actions/feature_spec.rb +0 -254
- data/spec/flipper/ui/actions/features_spec.rb +0 -233
- data/spec/flipper/ui/actions/file_spec.rb +0 -21
- data/spec/flipper/ui/actions/groups_gate_spec.rb +0 -144
- data/spec/flipper/ui/actions/home_spec.rb +0 -14
- data/spec/flipper/ui/actions/import_spec.rb +0 -63
- data/spec/flipper/ui/actions/percentage_of_actors_gate_spec.rb +0 -65
- data/spec/flipper/ui/actions/percentage_of_time_gate_spec.rb +0 -65
- data/spec/flipper/ui/actions/settings_spec.rb +0 -35
- data/spec/flipper/ui/configuration_spec.rb +0 -229
- data/spec/flipper/ui/decorators/feature_spec.rb +0 -59
- data/spec/flipper/ui/decorators/gate_spec.rb +0 -45
- data/spec/flipper/ui/util_spec.rb +0 -17
- data/spec/flipper/ui_spec.rb +0 -197
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 86171a115881a6677d106155e0225f9c1543b5d8bfa0b3886556add68437ce4f
|
|
4
|
+
data.tar.gz: ae4a40e327254414780a24d791d41d05408257c278adde7bf6a66eee43a6daa8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd2b72eec292435304c15a0dd79c4174365daad651917bca1b2c3a2829125dccea44d0d18724d4109701bcc2a221beeb7489b2b8efb91db30a5ef09ec50f2537
|
|
7
|
+
data.tar.gz: 985053ce5f53b9ef8ab649c54dbf1c67654235232217a349cf6d0af55acb1e24814f22fe2cc68315f03aa07853fcd0e4e1d81570255b156bc72fe3baa714cf0e
|
data/lib/flipper/ui/action.rb
CHANGED
|
@@ -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
|
-
|
|
111
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -41,13 +41,17 @@ module Flipper
|
|
|
41
41
|
halt view_response(:feature_creation_disabled)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
value = params['value']
|
|
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
|
|
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."
|
|
@@ -9,10 +9,28 @@ module Flipper
|
|
|
9
9
|
|
|
10
10
|
def post
|
|
11
11
|
render_read_only if read_only?
|
|
12
|
-
|
|
13
|
-
|
|
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)
|
|
14
24
|
flipper.import(export)
|
|
15
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)}"
|
|
16
34
|
end
|
|
17
35
|
end
|
|
18
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}")
|
|
@@ -152,11 +152,16 @@ module Flipper
|
|
|
152
152
|
end
|
|
153
153
|
|
|
154
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)
|
|
155
160
|
unless VALID_BANNER_CLASS_VALUES.include?(value)
|
|
156
161
|
raise InvalidConfigurationValue, "The banner_class provided '#{value}' is " \
|
|
157
162
|
"not one of: #{VALID_BANNER_CLASS_VALUES.join(', ')}"
|
|
158
163
|
end
|
|
159
|
-
|
|
164
|
+
value
|
|
160
165
|
end
|
|
161
166
|
end
|
|
162
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
|
-
|
|
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
|
-
|
|
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,
|
data/lib/flipper/ui/error.rb
CHANGED
|
@@ -3,8 +3,8 @@ module Flipper
|
|
|
3
3
|
# All flipper ui errors inherit from this.
|
|
4
4
|
Error = Class.new(StandardError)
|
|
5
5
|
|
|
6
|
-
#
|
|
7
|
-
#
|
|
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
|
data/lib/flipper/ui/util.rb
CHANGED
|
@@ -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,9 +11,9 @@
|
|
|
11
11
|
</head>
|
|
12
12
|
<body class="py-4">
|
|
13
13
|
<div class="container mw-600">
|
|
14
|
-
<%- unless
|
|
15
|
-
<div class="alert alert-<%=
|
|
16
|
-
<%== Sanitize.fragment(
|
|
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
|
|
|
@@ -57,6 +57,10 @@
|
|
|
57
57
|
<li class="nav-item ms-auto text-muted small">
|
|
58
58
|
<a href="https://www.flippercloud.io/docs/ui?utm_source=oss&utm_medium=ui&utm_campaign=docs">Docs</a>
|
|
59
59
|
•
|
|
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
|
+
•
|
|
63
|
+
<% end %>
|
|
60
64
|
Version: <%= Flipper::VERSION %>
|
|
61
65
|
</li>
|
|
62
66
|
</ul>
|
|
@@ -75,7 +79,7 @@
|
|
|
75
79
|
</a>
|
|
76
80
|
</div>
|
|
77
81
|
<div class="col text-muted p-0">
|
|
78
|
-
<small>For audit history, rollback, finer-grained permissions,
|
|
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 Cloud</a>. We even have a free tier!</small>
|
|
79
83
|
</div>
|
|
80
84
|
</div>
|
|
81
85
|
</div>
|
|
@@ -2,28 +2,31 @@
|
|
|
2
2
|
<div class="alert alert-danger"><%= params["error"] %></div>
|
|
3
3
|
<% end %>
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
<div class="card-
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
21
|
+
<p>You have <strong><%= flipper.features.count %></strong> <%= flipper.features.count == 1 ? 'feature' : 'features' %> ready to migrate.</p>
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
29
|
+
<% end %>
|
|
27
30
|
|
|
28
31
|
<div class="card mb-4 ">
|
|
29
32
|
<div class="card-header">
|
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
|
data/lib/flipper/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flipper-ui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.0.rc2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Nunemaker
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rack
|
|
@@ -76,14 +76,14 @@ dependencies:
|
|
|
76
76
|
requirements:
|
|
77
77
|
- - "~>"
|
|
78
78
|
- !ruby/object:Gem::Version
|
|
79
|
-
version: 1.
|
|
79
|
+
version: 1.5.0.rc2
|
|
80
80
|
type: :runtime
|
|
81
81
|
prerelease: false
|
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
|
83
83
|
requirements:
|
|
84
84
|
- - "~>"
|
|
85
85
|
- !ruby/object:Gem::Version
|
|
86
|
-
version: 1.
|
|
86
|
+
version: 1.5.0.rc2
|
|
87
87
|
- !ruby/object:Gem::Dependency
|
|
88
88
|
name: erubi
|
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -124,11 +124,6 @@ executables: []
|
|
|
124
124
|
extensions: []
|
|
125
125
|
extra_rdoc_files: []
|
|
126
126
|
files:
|
|
127
|
-
- examples/ui/authorization.ru
|
|
128
|
-
- examples/ui/basic.ru
|
|
129
|
-
- examples/ui/prefixed.ru
|
|
130
|
-
- examples/ui/read_only.ru
|
|
131
|
-
- flipper-ui.gemspec
|
|
132
127
|
- lib/flipper-ui.rb
|
|
133
128
|
- lib/flipper/ui.rb
|
|
134
129
|
- lib/flipper/ui/action.rb
|
|
@@ -150,7 +145,6 @@ files:
|
|
|
150
145
|
- lib/flipper/ui/configuration.rb
|
|
151
146
|
- lib/flipper/ui/configuration/option.rb
|
|
152
147
|
- lib/flipper/ui/decorators/feature.rb
|
|
153
|
-
- lib/flipper/ui/decorators/gate.rb
|
|
154
148
|
- lib/flipper/ui/error.rb
|
|
155
149
|
- lib/flipper/ui/middleware.rb
|
|
156
150
|
- lib/flipper/ui/public/css/application.css
|
|
@@ -158,7 +152,6 @@ files:
|
|
|
158
152
|
- lib/flipper/ui/public/images/logo.png
|
|
159
153
|
- lib/flipper/ui/public/js/application.js
|
|
160
154
|
- lib/flipper/ui/public/js/bootstrap.min.js
|
|
161
|
-
- lib/flipper/ui/public/js/jquery-3.6.0.slim.js
|
|
162
155
|
- lib/flipper/ui/public/js/popper.min.js
|
|
163
156
|
- lib/flipper/ui/public/js/version.js
|
|
164
157
|
- lib/flipper/ui/sources.json
|
|
@@ -175,26 +168,6 @@ files:
|
|
|
175
168
|
- lib/flipper/ui/views/read_only.erb
|
|
176
169
|
- lib/flipper/ui/views/settings.erb
|
|
177
170
|
- lib/flipper/version.rb
|
|
178
|
-
- spec/flipper/ui/action_spec.rb
|
|
179
|
-
- spec/flipper/ui/actions/actors_gate_spec.rb
|
|
180
|
-
- spec/flipper/ui/actions/add_feature_spec.rb
|
|
181
|
-
- spec/flipper/ui/actions/boolean_gate_spec.rb
|
|
182
|
-
- spec/flipper/ui/actions/cloud_migrate_spec.rb
|
|
183
|
-
- spec/flipper/ui/actions/export_spec.rb
|
|
184
|
-
- spec/flipper/ui/actions/feature_spec.rb
|
|
185
|
-
- spec/flipper/ui/actions/features_spec.rb
|
|
186
|
-
- spec/flipper/ui/actions/file_spec.rb
|
|
187
|
-
- spec/flipper/ui/actions/groups_gate_spec.rb
|
|
188
|
-
- spec/flipper/ui/actions/home_spec.rb
|
|
189
|
-
- spec/flipper/ui/actions/import_spec.rb
|
|
190
|
-
- spec/flipper/ui/actions/percentage_of_actors_gate_spec.rb
|
|
191
|
-
- spec/flipper/ui/actions/percentage_of_time_gate_spec.rb
|
|
192
|
-
- spec/flipper/ui/actions/settings_spec.rb
|
|
193
|
-
- spec/flipper/ui/configuration_spec.rb
|
|
194
|
-
- spec/flipper/ui/decorators/feature_spec.rb
|
|
195
|
-
- spec/flipper/ui/decorators/gate_spec.rb
|
|
196
|
-
- spec/flipper/ui/util_spec.rb
|
|
197
|
-
- spec/flipper/ui_spec.rb
|
|
198
171
|
homepage: https://www.flippercloud.io/docs/ui
|
|
199
172
|
licenses:
|
|
200
173
|
- MIT
|
|
@@ -203,7 +176,7 @@ metadata:
|
|
|
203
176
|
homepage_uri: https://www.flippercloud.io
|
|
204
177
|
source_code_uri: https://github.com/flippercloud/flipper
|
|
205
178
|
bug_tracker_uri: https://github.com/flippercloud/flipper/issues
|
|
206
|
-
changelog_uri: https://github.com/flippercloud/flipper/releases/tag/v1.
|
|
179
|
+
changelog_uri: https://github.com/flippercloud/flipper/releases/tag/v1.5.0.rc2
|
|
207
180
|
funding_uri: https://github.com/sponsors/flippercloud
|
|
208
181
|
post_install_message:
|
|
209
182
|
rdoc_options: []
|