flipper-ui 0.20.2 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 535c19177c80d64f3874e491e6822ffe5cb82f8414e0ec71d29351cba342437f
4
- data.tar.gz: a793c3179f888f8a5f427a40ec61cef1387ca09aa5fda81fd88d48ee00685ae1
3
+ metadata.gz: dd4963986e65fb20081d23374099f2a054df7e78a81e2571ad3640831b7d0d81
4
+ data.tar.gz: b94fc64dcf6752a2951c8c03bd6161c46e4850f206ebb049f4aa8b0a5b20e881
5
5
  SHA512:
6
- metadata.gz: 1732f43d892f4cdff1731488c746099449ca11866d6cf0ba5382c68ff1ed7cc6039b9bd7744fe20602e0a9f74cf470ea2923d5258e639c19e591318a385ccc87
7
- data.tar.gz: 737ae2c852886ec20a19a63ef5c9df628155c0301f30460ccf608f02e93c20a9caa6dbde7ef52d53275c798ab06cc63bdc55023a2ad6b955ae026a655f0f9558
6
+ metadata.gz: c46dbab449279c506b9d5ce1d2869392b8e4f0f6b8dab59b527b64a2acf25504cb5fb3e8af2e2601176f0f7c026afdf547196d197d4d0cfad0031e8a26f270bc
7
+ data.tar.gz: 95ed1aefbe02cdac6f8e938107a00a41e2e8754fa20351fa35948942557746d863d542c52b3993846828ce327b52aa4c151e1422997baea0e8099ff4c3580988
data/docs/ui/README.md CHANGED
@@ -109,7 +109,7 @@ Minimal example for Rack:
109
109
  ```ruby
110
110
  # config.ru
111
111
 
112
- require 'flipper-ui'
112
+ require 'flipper/ui'
113
113
 
114
114
  adapter = Flipper::Adapters::Memory.new
115
115
  flipper = Flipper.new(adapter)
@@ -0,0 +1,84 @@
1
+ #
2
+ # Usage:
3
+ # bundle exec rackup examples/ui/authorization.ru -p 9999
4
+ # bundle exec shotgun examples/ui/authorization.ru -p 9999
5
+ # http://localhost:9999/
6
+ #
7
+ require 'bundler/setup'
8
+ require "logger"
9
+
10
+ require "flipper/ui"
11
+ require "flipper/adapters/pstore"
12
+ require "active_support/notifications"
13
+
14
+ Flipper.register(:admins) { |actor|
15
+ actor.respond_to?(:admin?) && actor.admin?
16
+ }
17
+
18
+ Flipper.register(:early_access) { |actor|
19
+ actor.respond_to?(:early?) && actor.early?
20
+ }
21
+
22
+ # Setup logging of flipper calls.
23
+ if ENV["LOG"] == "1"
24
+ $logger = Logger.new(STDOUT)
25
+ require "flipper/instrumentation/log_subscriber"
26
+ Flipper::Instrumentation::LogSubscriber.logger = $logger
27
+ end
28
+
29
+ adapter = Flipper::Adapters::PStore.new
30
+ flipper = Flipper.new(adapter, instrumenter: ActiveSupport::Notifications)
31
+
32
+ Flipper::UI.configure do |config|
33
+ # config.banner_text = 'Production Environment'
34
+ # config.banner_class = 'danger'
35
+ config.feature_creation_enabled = true
36
+ config.feature_removal_enabled = true
37
+ # config.show_feature_description_in_list = true
38
+ config.descriptions_source = lambda do |_keys|
39
+ {
40
+ "search_performance_another_long_thing" => "Just to test feature name length.",
41
+ "gauges_tracking" => "Should we track page views with gaug.es.",
42
+ "unused" => "Not used.",
43
+ "suits" => "Are suits necessary in business?",
44
+ "secrets" => "Secrets are lies.",
45
+ "logging" => "Log all the things.",
46
+ "new_cache" => "Like the old cache but newer.",
47
+ "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.",
48
+ }
49
+ end
50
+ end
51
+
52
+ # Example middleware to allow reading the Flipper UI but nothing else.
53
+ class FlipperReadOnlyMiddleware
54
+ def initialize(app)
55
+ @app = app
56
+ end
57
+
58
+ def call(env)
59
+ request = Rack::Request.new(env)
60
+
61
+ if request.get?
62
+ @app.call(env)
63
+ else
64
+ [401, {}, ["You can only look"]]
65
+ end
66
+ end
67
+ end
68
+
69
+ # You can uncomment these to get some default data:
70
+ # flipper[:search_performance_another_long_thing].enable
71
+ # flipper[:gauges_tracking].enable
72
+ # flipper[:unused].disable
73
+ # flipper[:suits].enable_actor Flipper::Actor.new('1')
74
+ # flipper[:suits].enable_actor Flipper::Actor.new('6')
75
+ # flipper[:secrets].enable_group :admins
76
+ # flipper[:secrets].enable_group :early_access
77
+ # flipper[:logging].enable_percentage_of_time 5
78
+ # flipper[:new_cache].enable_percentage_of_actors 15
79
+ # flipper["something/slashed"].add
80
+
81
+ run Flipper::UI.app(flipper) { |builder|
82
+ builder.use Rack::Session::Cookie, secret: "_super_secret"
83
+ builder.use FlipperReadOnlyMiddleware
84
+ }
data/examples/ui/basic.ru CHANGED
@@ -1,20 +1,16 @@
1
1
  #
2
2
  # Usage:
3
- # bundle exec rackup examples/ui/basic.ru -p 9999
4
- # bundle exec shotgun examples/ui/basic.ru -p 9999
3
+ # # if you want it to not reload and be really fast
4
+ # bin/rackup examples/ui/basic.ru -p 9999
5
+ #
6
+ # # if you want reloading
7
+ # bin/shotgun examples/ui/basic.ru -p 9999
8
+ #
5
9
  # http://localhost:9999/
6
10
  #
7
- require "pp"
8
- require "logger"
9
- require "pathname"
10
-
11
- root_path = Pathname(__FILE__).dirname.join("..").expand_path
12
- lib_path = root_path.join("lib")
13
- $:.unshift(lib_path)
14
-
15
- require "flipper-ui"
11
+ require 'bundler/setup'
12
+ require "flipper/ui"
16
13
  require "flipper/adapters/pstore"
17
- require "active_support/notifications"
18
14
 
19
15
  Flipper.register(:admins) { |actor|
20
16
  actor.respond_to?(:admin?) && actor.admin?
@@ -24,21 +20,12 @@ Flipper.register(:early_access) { |actor|
24
20
  actor.respond_to?(:early?) && actor.early?
25
21
  }
26
22
 
27
- # Setup logging of flipper calls.
28
- if ENV["LOG"] == "1"
29
- $logger = Logger.new(STDOUT)
30
- require "flipper/instrumentation/log_subscriber"
31
- Flipper::Instrumentation::LogSubscriber.logger = $logger
32
- end
33
-
34
- adapter = Flipper::Adapters::PStore.new
35
- flipper = Flipper.new(adapter, instrumenter: ActiveSupport::Notifications)
36
-
37
23
  Flipper::UI.configure do |config|
38
24
  # config.banner_text = 'Production Environment'
39
25
  # config.banner_class = 'danger'
40
26
  config.feature_creation_enabled = true
41
27
  config.feature_removal_enabled = true
28
+ config.cloud_recommendation = true
42
29
  # config.show_feature_description_in_list = true
43
30
  config.descriptions_source = lambda do |_keys|
44
31
  {
@@ -66,6 +53,6 @@ end
66
53
  # flipper[:new_cache].enable_percentage_of_actors 15
67
54
  # flipper["a/b"].add
68
55
 
69
- run Flipper::UI.app(flipper) { |builder|
56
+ run Flipper::UI.app { |builder|
70
57
  builder.use Rack::Session::Cookie, secret: "_super_secret"
71
58
  }
@@ -26,6 +26,10 @@ module Flipper
26
26
  # won't see a videoclip of Taylor Swift when there aren't any features
27
27
  attr_accessor :fun
28
28
 
29
+ # Public: Tired of seeing the awesome message about Cloud? Set this to
30
+ # false and it will go away. Defaults to true.
31
+ attr_accessor :cloud_recommendation
32
+
29
33
  # Public: What should show up in the form to add actors. This can be
30
34
  # different per application since flipper_id's can be whatever an
31
35
  # application needs. Defaults to "a flipper id".
@@ -60,6 +64,7 @@ module Flipper
60
64
  @feature_creation_enabled = true
61
65
  @feature_removal_enabled = true
62
66
  @fun = true
67
+ @cloud_recommendation = true
63
68
  @add_actor_placeholder = "a flipper id"
64
69
  @descriptions_source = DEFAULT_DESCRIPTIONS_SOURCE
65
70
  @show_feature_description_in_list = false
Binary file
@@ -1,5 +1,5 @@
1
1
  <% if @show_blank_slate %>
2
- <div class="jumbotron text-center">
2
+ <div class="jumbotron text-center m-0">
3
3
  <% if Flipper::UI.configuration.fun %>
4
4
  <h4>But I've got a blank space baby...</h4>
5
5
  <p>And I'll flip your features.</p>
@@ -35,6 +35,21 @@
35
35
  <div>
36
36
  <%== yield %>
37
37
  </div>
38
+
39
+ <% if Flipper::UI.configuration.cloud_recommendation %>
40
+ <div class="d-flex justify-content-center mt-5">
41
+ <div class="row" style="max-width: 350px;">
42
+ <div class="col-auto d-flex align-items-center">
43
+ <a href="https://www.flippercloud.io/?utm_source=oss&utm_medium=ui&utm_campaign=spread_the_love">
44
+ <img src="<%= script_name %>/images/logo.png" width="50" />
45
+ </a>
46
+ </div>
47
+ <div class="col text-muted p-0">
48
+ <small>For support, audit history, finer-grained permissions, multi-environment sync, and all your projects in one place check out <a href="https://www.flippercloud.io/?utm_source=oss&utm_medium=ui&utm_campaign=spread_the_love">Flipper&nbsp;Cloud</a>.</small>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ <% end %>
38
53
  </div>
39
54
 
40
55
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.20.2'.freeze
2
+ VERSION = '0.21.0'.freeze
3
3
  end
@@ -59,6 +59,17 @@ RSpec.describe Flipper::UI::Configuration do
59
59
  end
60
60
  end
61
61
 
62
+ describe "#cloud_recommendation" do
63
+ it "has default value" do
64
+ expect(configuration.cloud_recommendation).to eq(true)
65
+ end
66
+
67
+ it "can be updated" do
68
+ configuration.cloud_recommendation = false
69
+ expect(configuration.cloud_recommendation).to eq(false)
70
+ end
71
+ end
72
+
62
73
  describe "#feature_removal_enabled" do
63
74
  it "has default value" do
64
75
  expect(configuration.feature_removal_enabled).to eq(true)
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: 0.20.2
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-08 00:00:00.000000000 Z
11
+ date: 2021-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -56,14 +56,14 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: 0.20.2
59
+ version: 0.21.0
60
60
  type: :runtime
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: 0.20.2
66
+ version: 0.21.0
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: erubi
69
69
  requirement: !ruby/object:Gem::Requirement
@@ -96,6 +96,7 @@ files:
96
96
  - docs/ui/images/description.png
97
97
  - docs/ui/images/feature.png
98
98
  - docs/ui/images/features.png
99
+ - examples/ui/authorization.ru
99
100
  - examples/ui/basic.ru
100
101
  - flipper-ui.gemspec
101
102
  - lib/flipper-ui.rb