flipper-ui 0.7.5 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flipper/ui.rb +7 -0
- data/lib/flipper/ui/actions/add_feature.rb +10 -0
- data/lib/flipper/ui/actions/features.rb +10 -0
- data/lib/flipper/ui/assets/stylesheets/application.scss +4 -0
- data/lib/flipper/ui/public/css/application.css +3 -0
- data/lib/flipper/ui/views/add_feature.erb +6 -1
- data/lib/flipper/ui/views/feature.erb +3 -0
- data/lib/flipper/ui/views/feature_creation_disabled.erb +3 -0
- data/lib/flipper/ui/views/layout.erb +3 -1
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/ui/actions/add_feature_spec.rb +27 -1
- data/spec/flipper/ui/actions/features_spec.rb +33 -1
- data/spec/flipper/ui_spec.rb +37 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9ad8f99301748583192db920f873597dc0d3ac3
|
4
|
+
data.tar.gz: d41e140edc11650a62521e840db6476042404110
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2df9f15278dce52132dd77fa494f963a7fa2e000f5d43b1797de2498d6e95a66e4e27e7ccda3a8fff06c95f8e3a992326d312f8d4f0588ef50fbd7b3848d8a6e
|
7
|
+
data.tar.gz: 81eb62be1129995195ef6621b0dc9c3059dfbede4fc2035789c8825bcb30b9c2f65799b39abe311037f83fa51657cc3919597d2a0de82d15770a1b144c3f9077
|
data/lib/flipper/ui.rb
CHANGED
@@ -21,8 +21,15 @@ module Flipper
|
|
21
21
|
# says "App" which points to this href. The href can be a path (ie: "/")
|
22
22
|
# or full url ("https://app.example.com/").
|
23
23
|
attr_accessor :application_breadcrumb_href
|
24
|
+
|
25
|
+
# Public: Is feature creation allowed from the UI? Defaults to true. If
|
26
|
+
# set to false, users of the UI cannot create features. All feature
|
27
|
+
# creation will need to be done through the conigured flipper instance.
|
28
|
+
attr_accessor :feature_creation_enabled
|
24
29
|
end
|
25
30
|
|
31
|
+
self.feature_creation_enabled = true
|
32
|
+
|
26
33
|
def self.root
|
27
34
|
@root ||= Pathname(__FILE__).dirname.expand_path.join('ui')
|
28
35
|
end
|
@@ -8,6 +8,16 @@ module Flipper
|
|
8
8
|
route %r{features/new/?\Z}
|
9
9
|
|
10
10
|
def get
|
11
|
+
unless Flipper::UI.feature_creation_enabled
|
12
|
+
status 403
|
13
|
+
|
14
|
+
breadcrumb "Home", "/"
|
15
|
+
breadcrumb "Features", "/features"
|
16
|
+
breadcrumb "Noooooope"
|
17
|
+
|
18
|
+
halt view_response(:feature_creation_disabled)
|
19
|
+
end
|
20
|
+
|
11
21
|
breadcrumb "Home", "/"
|
12
22
|
breadcrumb "Features", "/features"
|
13
23
|
breadcrumb "Add"
|
@@ -24,6 +24,16 @@ module Flipper
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def post
|
27
|
+
unless Flipper::UI.feature_creation_enabled
|
28
|
+
status 403
|
29
|
+
|
30
|
+
breadcrumb "Home", "/"
|
31
|
+
breadcrumb "Features", "/features"
|
32
|
+
breadcrumb "Noooooope"
|
33
|
+
|
34
|
+
halt view_response(:feature_creation_disabled)
|
35
|
+
end
|
36
|
+
|
27
37
|
value = params["value"]
|
28
38
|
|
29
39
|
if Util.blank?(value)
|
@@ -11,8 +11,13 @@
|
|
11
11
|
<div class="panel-body">
|
12
12
|
<form action="<%= script_name %>/features" method="post">
|
13
13
|
<%== csrf_input_tag %>
|
14
|
-
<input type="text" name="value" placeholder="ie:
|
14
|
+
<input type="text" name="value" size="30" placeholder="ie: search, new_pricing, etc.">
|
15
15
|
<input type="submit" value="Add Feature" class="btn">
|
16
16
|
</form>
|
17
|
+
<p class="help">
|
18
|
+
Recommended naming conventions: lower case, <a href="https://en.wikipedia.org/wiki/Snake_case">snake case</a>, underscores over dashes.
|
19
|
+
<strong>Good</strong>: foo_bar, foo.
|
20
|
+
<strong>Bad</strong>: FooBar, Foo Bar, foo bar, foo-bar.
|
21
|
+
</p>
|
17
22
|
</div>
|
18
23
|
</div>
|
@@ -56,6 +56,7 @@
|
|
56
56
|
<input type="text" name="value" <% if @feature.percentage_of_actors_value > 0 %>value="<%= @feature.percentage_of_actors_value %>"<% end %> placeholder="custom (ie: 26, 32, etc.)" class="input-mini">
|
57
57
|
<input type="submit" name="action" value="Enable" class="btn btn-sm">
|
58
58
|
</form>
|
59
|
+
<p class="help"><small>Percentage of actors functions independently of percentage of time. If you enable 50% of Actors and 25% of Time then the feature will always be enabled for 50% of users and occasionally enabled 25% of the time for everyone.</small></p>
|
59
60
|
</div>
|
60
61
|
</div>
|
61
62
|
</div>
|
@@ -81,6 +82,8 @@
|
|
81
82
|
<input type="text" name="value" <% if @feature.percentage_of_time_value > 0 %>value="<%= @feature.percentage_of_time_value %>"<% end %> placeholder="custom (ie: 26, 32, etc.)" class="input-mini">
|
82
83
|
<input type="submit" name="action" value="Enable" class="btn btn-sm">
|
83
84
|
</form>
|
85
|
+
|
86
|
+
<p class="help"><small>Percentage of time functions independently of percentage of actors. If you enable 50% of Actors and 25% of Time then the feature will always be enabled for 50% of users and occasionally enabled 25% of the time for everyone.</small></p>
|
84
87
|
</div>
|
85
88
|
</div>
|
86
89
|
</div>
|
@@ -17,7 +17,9 @@
|
|
17
17
|
</head>
|
18
18
|
<body>
|
19
19
|
<div class="container header">
|
20
|
-
|
20
|
+
<%- if Flipper::UI.feature_creation_enabled -%>
|
21
|
+
<a class="btn btn-sm right" href="<%= script_name %>/features/new">Add Feature</a>
|
22
|
+
<%- end -%>
|
21
23
|
|
22
24
|
<ol class="breadcrumb">
|
23
25
|
<% @breadcrumbs.each do |breadcrumb| %>
|
data/lib/flipper/version.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
RSpec.describe Flipper::UI::Actions::AddFeature do
|
4
|
-
describe "GET /features/new" do
|
4
|
+
describe "GET /features/new with feature_creation_enabled set to true" do
|
5
5
|
before do
|
6
|
+
@original_feature_creation_enabled = Flipper::UI.feature_creation_enabled
|
7
|
+
Flipper::UI.feature_creation_enabled = true
|
6
8
|
get "/features/new"
|
7
9
|
end
|
8
10
|
|
11
|
+
after do
|
12
|
+
Flipper::UI.feature_creation_enabled = @original_feature_creation_enabled
|
13
|
+
end
|
14
|
+
|
9
15
|
it "responds with success" do
|
10
16
|
expect(last_response.status).to be(200)
|
11
17
|
end
|
@@ -14,4 +20,24 @@ RSpec.describe Flipper::UI::Actions::AddFeature do
|
|
14
20
|
expect(last_response.body).to include('<form action="/features" method="post">')
|
15
21
|
end
|
16
22
|
end
|
23
|
+
|
24
|
+
describe "GET /features/new with feature_creation_enabled set to false" do
|
25
|
+
before do
|
26
|
+
@original_feature_creation_enabled = Flipper::UI.feature_creation_enabled
|
27
|
+
Flipper::UI.feature_creation_enabled = false
|
28
|
+
get "/features/new"
|
29
|
+
end
|
30
|
+
|
31
|
+
after do
|
32
|
+
Flipper::UI.feature_creation_enabled = @original_feature_creation_enabled
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns 403" do
|
36
|
+
expect(last_response.status).to be(403)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "renders feature creation disabled template" do
|
40
|
+
expect(last_response.body).to include("Feature creation is disabled.")
|
41
|
+
end
|
42
|
+
end
|
17
43
|
end
|
@@ -18,13 +18,19 @@ RSpec.describe Flipper::UI::Actions::Features do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe "POST /features" do
|
21
|
+
describe "POST /features with feature_creation_enabled set to true" do
|
22
22
|
before do
|
23
|
+
@original_feature_creation_enabled = Flipper::UI.feature_creation_enabled
|
24
|
+
Flipper::UI.feature_creation_enabled = true
|
23
25
|
post "/features",
|
24
26
|
{"value" => "notifications_next", "authenticity_token" => "a"},
|
25
27
|
"rack.session" => {"_csrf_token" => "a"}
|
26
28
|
end
|
27
29
|
|
30
|
+
after do
|
31
|
+
Flipper::UI.feature_creation_enabled = @original_feature_creation_enabled
|
32
|
+
end
|
33
|
+
|
28
34
|
it "adds feature" do
|
29
35
|
expect(flipper.features.map(&:key)).to include("notifications_next")
|
30
36
|
end
|
@@ -34,4 +40,30 @@ RSpec.describe Flipper::UI::Actions::Features do
|
|
34
40
|
expect(last_response.headers["Location"]).to eq("/features/notifications_next")
|
35
41
|
end
|
36
42
|
end
|
43
|
+
|
44
|
+
describe "POST /features with feature_creation_enabled set to false" do
|
45
|
+
before do
|
46
|
+
@original_feature_creation_enabled = Flipper::UI.feature_creation_enabled
|
47
|
+
Flipper::UI.feature_creation_enabled = false
|
48
|
+
post "/features",
|
49
|
+
{"value" => "notifications_next", "authenticity_token" => "a"},
|
50
|
+
"rack.session" => {"_csrf_token" => "a"}
|
51
|
+
end
|
52
|
+
|
53
|
+
after do
|
54
|
+
Flipper::UI.feature_creation_enabled = @original_feature_creation_enabled
|
55
|
+
end
|
56
|
+
|
57
|
+
it "does not add feature" do
|
58
|
+
expect(flipper.features.map(&:key)).to_not include("notifications_next")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "returns 403" do
|
62
|
+
expect(last_response.status).to be(403)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "renders feature creation disabled template" do
|
66
|
+
expect(last_response.body).to include("Feature creation is disabled.")
|
67
|
+
end
|
68
|
+
end
|
37
69
|
end
|
data/spec/flipper/ui_spec.rb
CHANGED
@@ -93,4 +93,41 @@ RSpec.describe Flipper::UI do
|
|
93
93
|
expect(last_response.body).to include('<a href="https://myapp.com/">App</a>')
|
94
94
|
end
|
95
95
|
end
|
96
|
+
|
97
|
+
it "should set feature_creation_enabled to true by default" do
|
98
|
+
expect(Flipper::UI.feature_creation_enabled).to be(true)
|
99
|
+
end
|
100
|
+
|
101
|
+
context "with feature_creation_enabled set to true" do
|
102
|
+
before do
|
103
|
+
@original_feature_creation_enabled = Flipper::UI.feature_creation_enabled
|
104
|
+
Flipper::UI.feature_creation_enabled = true
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'has the add_feature button' do
|
108
|
+
get '/features'
|
109
|
+
expect(last_response.body).to include('Add Feature')
|
110
|
+
end
|
111
|
+
|
112
|
+
after do
|
113
|
+
Flipper::UI.feature_creation_enabled = @original_feature_creation_enabled
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "with feature_creation_enabled set to false" do
|
118
|
+
before do
|
119
|
+
@original_feature_creation_enabled = Flipper::UI.feature_creation_enabled
|
120
|
+
Flipper::UI.feature_creation_enabled = false
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'does not have the add_feature button' do
|
124
|
+
get '/features'
|
125
|
+
expect(last_response.body).to_not include('Add Feature')
|
126
|
+
end
|
127
|
+
|
128
|
+
after do
|
129
|
+
Flipper::UI.feature_creation_enabled = @original_feature_creation_enabled
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
96
133
|
end
|
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.
|
4
|
+
version: 0.8.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: 2016-
|
11
|
+
date: 2016-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.
|
53
|
+
version: 0.8.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0.
|
60
|
+
version: 0.8.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: erubis
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -245,6 +245,7 @@ files:
|
|
245
245
|
- lib/flipper/ui/views/add_feature.erb
|
246
246
|
- lib/flipper/ui/views/add_group.erb
|
247
247
|
- lib/flipper/ui/views/feature.erb
|
248
|
+
- lib/flipper/ui/views/feature_creation_disabled.erb
|
248
249
|
- lib/flipper/ui/views/features.erb
|
249
250
|
- lib/flipper/ui/views/layout.erb
|
250
251
|
- lib/flipper/version.rb
|