flipper-ui 0.22.1 → 0.22.2
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/actions/actors_gate.rb +10 -7
- data/lib/flipper/ui/configuration.rb +6 -0
- data/lib/flipper/ui/views/add_actor.erb +1 -1
- data/lib/flipper/ui/views/feature.erb +2 -2
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/ui/actions/actors_gate_spec.rb +51 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b17af1c2cd05d9026a457941c46e7c497460e4289bd8446b90d2f0342e53f34c
|
4
|
+
data.tar.gz: 4adae31beca41aebaae69c9c3a0efe51bb024d0acc54eadf3982ddfff4a16748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8e0d113cb89d77c9e8cd0ec83d8deb7a26f3f6e00452aa81ab6a308843dfe45e069b0e1303374ece24e4a5bd79718958e160249db9195ea22249bab2df66a5d
|
7
|
+
data.tar.gz: cc5f6567f690c2bd48b762083046b19e868f4885384885667f20d808cd09f0533df5d3df5239e4a21cc649babbe231e494af984b5c1261b4ef9358b68581784a
|
@@ -25,19 +25,22 @@ module Flipper
|
|
25
25
|
def post
|
26
26
|
feature = flipper[feature_name]
|
27
27
|
value = params['value'].to_s.strip
|
28
|
+
values = value.split(UI.configuration.actors_separator).map(&:strip).uniq
|
28
29
|
|
29
|
-
if
|
30
|
+
if values.empty?
|
30
31
|
error = "#{value.inspect} is not a valid actor value."
|
31
32
|
redirect_to("/features/#{feature.key}/actors?error=#{error}")
|
32
33
|
end
|
33
34
|
|
34
|
-
|
35
|
+
values.each do |value|
|
36
|
+
actor = Flipper::Actor.new(value)
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
case params['operation']
|
39
|
+
when 'enable'
|
40
|
+
feature.enable_actor actor
|
41
|
+
when 'disable'
|
42
|
+
feature.disable_actor actor
|
43
|
+
end
|
41
44
|
end
|
42
45
|
|
43
46
|
redirect_to("/features/#{feature.key}")
|
@@ -44,6 +44,11 @@ module Flipper
|
|
44
44
|
# Default false. Only works when using descriptions.
|
45
45
|
attr_accessor :show_feature_description_in_list
|
46
46
|
|
47
|
+
# Public: What should be used to denote you are trying to add multiple
|
48
|
+
# actors at once (instead of just a single actor).
|
49
|
+
# Default is comma ",".
|
50
|
+
attr_accessor :actors_separator
|
51
|
+
|
47
52
|
VALID_BANNER_CLASS_VALUES = %w(
|
48
53
|
danger
|
49
54
|
dark
|
@@ -68,6 +73,7 @@ module Flipper
|
|
68
73
|
@add_actor_placeholder = "a flipper id"
|
69
74
|
@descriptions_source = DEFAULT_DESCRIPTIONS_SOURCE
|
70
75
|
@show_feature_description_in_list = false
|
76
|
+
@actors_separator = ','
|
71
77
|
end
|
72
78
|
|
73
79
|
def using_descriptions?
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<h4 class="card-header">Enable Actor for <%= @feature.key %></h4>
|
9
9
|
<div class="card-body">
|
10
10
|
<p>
|
11
|
-
Turn on this feature for
|
11
|
+
Turn on this feature for actors.
|
12
12
|
</p>
|
13
13
|
<form action="<%= script_name %>/features/<%= @feature.key %>/actors" method="post" class="form-inline">
|
14
14
|
<%== csrf_input_tag %>
|
@@ -130,8 +130,8 @@
|
|
130
130
|
<%== csrf_input_tag %>
|
131
131
|
<input type="hidden" name="operation" value="disable">
|
132
132
|
<input type="hidden" name="value" value="<%= item %>">
|
133
|
-
<button type="submit" value="Disable" class="btn btn-
|
134
|
-
|
133
|
+
<button type="submit" value="Disable" class="btn btn-outline-danger" data-toggle="tooltip" title="Disable <%= item %>" data-placement="left">
|
134
|
+
Remove
|
135
135
|
</button>
|
136
136
|
</form>
|
137
137
|
</div>
|
data/lib/flipper/version.rb
CHANGED
@@ -45,6 +45,7 @@ RSpec.describe Flipper::UI::Actions::ActorsGate do
|
|
45
45
|
describe 'POST /features/:feature/actors' do
|
46
46
|
context 'enabling an actor' do
|
47
47
|
let(:value) { 'User;6' }
|
48
|
+
let(:multi_value) { 'User;5, User;7, User;9, User;12' }
|
48
49
|
|
49
50
|
before do
|
50
51
|
post 'features/search/actors',
|
@@ -53,7 +54,18 @@ RSpec.describe Flipper::UI::Actions::ActorsGate do
|
|
53
54
|
end
|
54
55
|
|
55
56
|
it 'adds item to members' do
|
56
|
-
expect(flipper[:search].actors_value).to include(
|
57
|
+
expect(flipper[:search].actors_value).to include(value)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'adds item to multiple members' do
|
61
|
+
post 'features/search/actors',
|
62
|
+
{ 'value' => multi_value, 'operation' => 'enable', 'authenticity_token' => token },
|
63
|
+
'rack.session' => session
|
64
|
+
|
65
|
+
expect(flipper[:search].actors_value).to include('User;5')
|
66
|
+
expect(flipper[:search].actors_value).to include('User;7')
|
67
|
+
expect(flipper[:search].actors_value).to include('User;9')
|
68
|
+
expect(flipper[:search].actors_value).to include('User;12')
|
57
69
|
end
|
58
70
|
|
59
71
|
it 'redirects back to feature' do
|
@@ -80,10 +92,22 @@ RSpec.describe Flipper::UI::Actions::ActorsGate do
|
|
80
92
|
|
81
93
|
context 'value contains whitespace' do
|
82
94
|
let(:value) { ' User;6 ' }
|
95
|
+
let(:multi_value) { ' User;5 , User;7 , User;9 , User;12 ' }
|
83
96
|
|
84
97
|
it 'adds item without whitespace' do
|
85
98
|
expect(flipper[:search].actors_value).to include('User;6')
|
86
99
|
end
|
100
|
+
|
101
|
+
it 'adds item to multi members without whitespace' do
|
102
|
+
post 'features/search/actors',
|
103
|
+
{ 'value' => multi_value, 'operation' => 'enable', 'authenticity_token' => token },
|
104
|
+
'rack.session' => session
|
105
|
+
|
106
|
+
expect(flipper[:search].actors_value).to include('User;5')
|
107
|
+
expect(flipper[:search].actors_value).to include('User;7')
|
108
|
+
expect(flipper[:search].actors_value).to include('User;9')
|
109
|
+
expect(flipper[:search].actors_value).to include('User;12')
|
110
|
+
end
|
87
111
|
end
|
88
112
|
|
89
113
|
context 'for an invalid actor value' do
|
@@ -109,16 +133,29 @@ RSpec.describe Flipper::UI::Actions::ActorsGate do
|
|
109
133
|
|
110
134
|
context 'disabling an actor' do
|
111
135
|
let(:value) { 'User;6' }
|
136
|
+
let(:multi_value) { 'User;5, User;7, User;9, User;12' }
|
112
137
|
|
113
138
|
before do
|
114
|
-
flipper[:search].enable_actor Flipper::Actor.new(
|
139
|
+
flipper[:search].enable_actor Flipper::Actor.new(value)
|
115
140
|
post 'features/search/actors',
|
116
141
|
{ 'value' => value, 'operation' => 'disable', 'authenticity_token' => token },
|
117
142
|
'rack.session' => session
|
118
143
|
end
|
119
144
|
|
120
145
|
it 'removes item from members' do
|
121
|
-
expect(flipper[:search].actors_value).not_to include(
|
146
|
+
expect(flipper[:search].actors_value).not_to include(value)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'removes item from multi members' do
|
150
|
+
multi_value.split(',').map(&:strip).each do |value|
|
151
|
+
flipper[:search].enable_actor Flipper::Actor.new(value)
|
152
|
+
end
|
153
|
+
|
154
|
+
post 'features/search/actors',
|
155
|
+
{ 'value' => multi_value, 'operation' => 'disable', 'authenticity_token' => token },
|
156
|
+
'rack.session' => session
|
157
|
+
|
158
|
+
expect(flipper[:search].actors_value).not_to eq(Set.new(multi_value.split(',').map(&:strip)))
|
122
159
|
end
|
123
160
|
|
124
161
|
it 'redirects back to feature' do
|
@@ -128,10 +165,21 @@ RSpec.describe Flipper::UI::Actions::ActorsGate do
|
|
128
165
|
|
129
166
|
context 'value contains whitespace' do
|
130
167
|
let(:value) { ' User;6 ' }
|
168
|
+
let(:multi_value) { ' User;5 , User;7 , User;9 , User;12 ' }
|
131
169
|
|
132
170
|
it 'removes item without whitespace' do
|
133
171
|
expect(flipper[:search].actors_value).not_to include('User;6')
|
134
172
|
end
|
173
|
+
|
174
|
+
it 'removes item without whitespace' do
|
175
|
+
multi_value.split(',').map(&:strip).each do |value|
|
176
|
+
flipper[:search].enable_actor Flipper::Actor.new(value)
|
177
|
+
end
|
178
|
+
post 'features/search/actors',
|
179
|
+
{ 'value' => multi_value, 'operation' => 'disable', 'authenticity_token' => token },
|
180
|
+
'rack.session' => session
|
181
|
+
expect(flipper[:search].actors_value).not_to eq(Set.new(multi_value.split(',').map(&:strip)))
|
182
|
+
end
|
135
183
|
end
|
136
184
|
end
|
137
185
|
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.22.
|
4
|
+
version: 0.22.2
|
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-
|
11
|
+
date: 2021-10-06 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.22.
|
59
|
+
version: 0.22.2
|
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.22.
|
66
|
+
version: 0.22.2
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: erubi
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|