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.
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 +20 -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 +6 -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 +8 -4
  18. data/lib/flipper/ui/views/settings.erb +21 -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 -63
  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 -229
  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
@@ -1,48 +0,0 @@
1
- #
2
- # Usage:
3
- # bundle exec rackup examples/ui/authorization.ru -p 9999
4
- # http://localhost:9999/
5
- #
6
- require 'bundler/setup'
7
- require 'rack/reloader'
8
- require "flipper/ui"
9
- require "flipper/adapters/pstore"
10
-
11
- Flipper.register(:admins) { |actor|
12
- actor.respond_to?(:admin?) && actor.admin?
13
- }
14
-
15
- # Example middleware to allow reading the Flipper UI but nothing else.
16
- class FlipperReadOnlyMiddleware
17
- def initialize(app)
18
- @app = app
19
- end
20
-
21
- def call(env)
22
- request = Rack::Request.new(env)
23
-
24
- if request.get?
25
- @app.call(env)
26
- else
27
- [401, {}, ["You can only look"]]
28
- end
29
- end
30
- end
31
-
32
- # You can uncomment these to get some default data:
33
- # Flipper.enable(:search_performance_another_long_thing)
34
- # Flipper.disable(:gauges_tracking)
35
- # Flipper.disable(:unused)
36
- # Flipper.enable_actor(:suits, Flipper::Actor.new('1'))
37
- # Flipper.enable_actor(:suits, Flipper::Actor.new('6'))
38
- # Flipper.enable_group(:secrets, :admins)
39
- # Flipper.enable_percentage_of_time(:logging, 5)
40
- # Flipper.enable_percentage_of_actors(:new_cache, 15)
41
- # Flipper.add("a/b")
42
-
43
- use Rack::Reloader
44
-
45
- run Flipper::UI.app { |builder|
46
- builder.use Rack::Session::Cookie, secret: "_super_secret"
47
- builder.use FlipperReadOnlyMiddleware
48
- }
data/examples/ui/basic.ru DELETED
@@ -1,71 +0,0 @@
1
- #
2
- # Usage:
3
- # # if you want it to not reload and be really fast
4
- # bundle exec rackup examples/ui/basic.ru -p 9999
5
- #
6
- # http://localhost:9999/
7
- #
8
- require 'bundler/setup'
9
- require 'rack/reloader'
10
- require "flipper/ui"
11
- require "flipper/adapters/pstore"
12
-
13
- Flipper.register(:admins) { |actor|
14
- actor.respond_to?(:admin?) && actor.admin?
15
- }
16
-
17
- Flipper.register(:early_access) { |actor|
18
- actor.respond_to?(:early?) && actor.early?
19
- }
20
-
21
- Flipper::UI.configure do |config|
22
- # config.banner_text = 'Production Environment'
23
- # config.banner_class = 'danger'
24
- config.feature_creation_enabled = true
25
- config.feature_removal_enabled = true
26
- config.cloud_recommendation = true
27
- config.confirm_fully_enable = false
28
- config.confirm_disable = false
29
- config.read_only = false
30
- # config.show_feature_description_in_list = true
31
- config.descriptions_source = lambda do |_keys|
32
- {
33
- "search_performance_another_long_thing" => "Just to test feature name length.",
34
- "gauges_tracking" => "Should we track page views with gaug.es.",
35
- "unused" => "Not used.",
36
- "suits" => "Are suits necessary in business?",
37
- "secrets" => "Secrets are lies.",
38
- "logging" => "Log all the things.",
39
- "new_cache" => "Like the old cache but newer.",
40
- "a/b" => "Why would someone use a slash? I don't know but someone did. Let's make this really long so they regret using slashes. Please don't use slashes.",
41
- }
42
- end
43
-
44
- config.actor_names_source = lambda do |_keys|
45
- {
46
- '1' => '<a href="https://johnnunemaker.com">John</a>',
47
- '6' => '<a href="https://opensoul.org">Brandon</a>',
48
- }
49
- end
50
-
51
- config.application_href = "https://example.com"
52
- end
53
-
54
- # You can uncomment these to get some default data:
55
- # Flipper.enable(:search_performance_another_long_thing)
56
- # Flipper.disable(:gauges_tracking)
57
- # Flipper.disable(:unused)
58
- # Flipper.enable_actor(:suits, Flipper::Actor.new('1'))
59
- # Flipper.enable_actor(:suits, Flipper::Actor.new('6'))
60
- # Flipper.enable_group(:secrets, :admins)
61
- # Flipper.enable_group(:secrets, :early_access)
62
- # Flipper.enable_percentage_of_time(:logging, 5)
63
- # Flipper.enable_percentage_of_actors(:new_cache, 15)
64
- # Flipper.add("a/b")
65
-
66
- use Rack::Reloader
67
-
68
- run Flipper::UI.app { |builder|
69
- builder.use Rack::Reloader, 1
70
- builder.use Rack::Session::Cookie, secret: "_super_secret"
71
- }
@@ -1,21 +0,0 @@
1
- #
2
- # Usage:
3
- # bundle exec rackup examples/ui/prefixed.ru -p 9999
4
- #
5
- # http://localhost:9999/
6
- #
7
- require 'bundler/setup'
8
- require 'rack/reloader'
9
- require "flipper/ui"
10
- require "flipper/adapters/pstore"
11
-
12
- use Rack::Reloader
13
-
14
- run Rack::URLMap.new(
15
- "/" => lambda { |env|
16
- [302, {"Location" => "/flipper"}, [] ]
17
- },
18
- "/flipper" => Flipper::UI.app { |builder|
19
- builder.use Rack::Session::Cookie, secret: "_super_secret"
20
- }
21
- )
@@ -1,43 +0,0 @@
1
- #
2
- # Usage:
3
- # # if you want it to not reload and be really fast
4
- # bundle exec rackup examples/ui/read_only.ru -p 9999
5
- #
6
- # http://localhost:9999/
7
- #
8
- require 'bundler/setup'
9
- require 'rack/reloader'
10
- require "flipper/ui"
11
- require "flipper/adapters/pstore"
12
-
13
- Flipper.register(:admins) { |actor|
14
- actor.respond_to?(:admin?) && actor.admin?
15
- }
16
-
17
- Flipper.register(:early_access) { |actor|
18
- actor.respond_to?(:early?) && actor.early?
19
- }
20
-
21
- Flipper::UI.configure do |config|
22
- config.banner_text = 'Read only mode.'
23
- config.banner_class = 'danger'
24
- config.read_only = true
25
- end
26
-
27
- # You can uncomment these to get some default data:
28
- # Flipper.enable(:search_performance_another_long_thing)
29
- # Flipper.disable(:gauges_tracking)
30
- # Flipper.disable(:unused)
31
- # Flipper.enable_actor(:suits, Flipper::Actor.new('1'))
32
- # Flipper.enable_actor(:suits, Flipper::Actor.new('6'))
33
- # Flipper.enable_group(:secrets, :admins)
34
- # Flipper.enable_group(:secrets, :early_access)
35
- # Flipper.enable_percentage_of_time(:logging, 5)
36
- # Flipper.enable_percentage_of_actors(:new_cache, 15)
37
- # Flipper.add("a/b")
38
-
39
- use Rack::Reloader
40
-
41
- run Flipper::UI.app { |builder|
42
- builder.use Rack::Session::Cookie, secret: "_super_secret"
43
- }
data/flipper-ui.gemspec DELETED
@@ -1,29 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/flipper/version', __FILE__)
3
- require File.expand_path('../lib/flipper/metadata', __FILE__)
4
-
5
- flipper_ui_files = lambda do |file|
6
- file =~ %r{(docs|examples|flipper)[\/-]ui}
7
- end
8
-
9
- Gem::Specification.new do |gem|
10
- gem.authors = ['John Nunemaker']
11
- gem.email = 'support@flippercloud.io'
12
- gem.summary = 'Feature flag UI for the Flipper gem'
13
- gem.license = 'MIT'
14
- gem.homepage = 'https://www.flippercloud.io/docs/ui'
15
-
16
- gem.files = `git ls-files`.split("\n").select(&flipper_ui_files) + ['lib/flipper/version.rb']
17
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_ui_files)
18
- gem.name = 'flipper-ui'
19
- gem.require_paths = ['lib']
20
- gem.version = Flipper::VERSION
21
- gem.metadata = Flipper::METADATA
22
-
23
- gem.add_dependency 'rack', '>= 1.4', '< 4'
24
- gem.add_dependency 'rack-protection', '>= 1.5.3', '<5.0.0'
25
- gem.add_dependency 'rack-session', '>= 1.0.2', '< 3.0.0'
26
- gem.add_dependency 'flipper', "~> #{Flipper::VERSION}"
27
- gem.add_dependency 'erubi', '>= 1.0.0', '< 2.0.0'
28
- gem.add_dependency 'sanitize', '< 8'
29
- end
@@ -1,37 +0,0 @@
1
- require 'delegate'
2
-
3
- module Flipper
4
- module UI
5
- module Decorators
6
- class Gate < SimpleDelegator
7
- # Public: The gate being decorated.
8
- alias_method :gate, :__getobj__
9
-
10
- # Public: The value for the gate from the adapter.
11
- attr_reader :value
12
-
13
- def initialize(gate, value = nil)
14
- super gate
15
- @value = value
16
- end
17
-
18
- # Public: Returns instance as hash that is ready to be json dumped.
19
- def as_json
20
- value_as_json =
21
- case data_type
22
- when :set
23
- value.to_a # json doesn't like sets
24
- else
25
- value
26
- end
27
-
28
- {
29
- 'key' => gate.key.to_s,
30
- 'name' => gate.name.to_s,
31
- 'value' => value_as_json,
32
- }
33
- end
34
- end
35
- end
36
- end
37
- end