flipper-ui 0.18.0 → 0.20.0.beta3

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: 9c1e364e1af2059e2eeb915be4ccacbc2a441429789bdd6a3241de011c5df2c5
4
- data.tar.gz: 21fbdf1b0e4276203ed05e63b938db518f5e04f925940ae9188ffa24986a4f40
3
+ metadata.gz: 645df1fe39894233c06b885bc09187b0e373fffca9ad334189a6999ed2e67584
4
+ data.tar.gz: 38055ad94d2c83d6ea76ef53ea0fca079c3fd546aa91d3b6930d2b77bf3cdfb7
5
5
  SHA512:
6
- metadata.gz: d958959d8acb5dd90bd73df0338676c89fa403fdbc71402307c91fdb3d33396bbbc3db158fb6cf0bdb6ed7054410f0f364e9df8a76720acd18092f7fe88c94ef
7
- data.tar.gz: 1401fabdbf9c9e4a1c5f1600955d55ae3bc7cecfdfbc95ed901b1d137b1715b12d43830d40f3ef3350a9066f2755454cfa71f9be9260c536518f49a1ed67d626
6
+ metadata.gz: 0763ae8da582b62fb6eab3b1aa2f5a4cf555961b6c2d3a89a4c61b0bb5e5d1a5a3a22973e759e9d4ed3bbaead96f3eeb74ab85692ff3268c6df4426577cafb0f
7
+ data.tar.gz: 45a41c6acae29ede69bd540e6f298ae066903261cbb900da2067d313ff66dc55301d7b166b4223043c3976ef7d9992c73b76760d6cc6f433da45462f5b1d78c8
@@ -5,9 +5,11 @@ UI for the [Flipper](https://github.com/jnunemaker/flipper) gem.
5
5
  ## Screenshots
6
6
 
7
7
  Viewing list of features:
8
+
8
9
  ![features](images/features.png)
9
10
 
10
11
  Viewing an individual feature:
12
+
11
13
  ![feature](images/feature.png)
12
14
 
13
15
  ## Installation
@@ -127,28 +129,11 @@ See [examples/ui/basic.ru](https://github.com/jnunemaker/flipper/blob/master/exa
127
129
 
128
130
  ### Configuration
129
131
 
130
- Flipper UI can be customized via `configure`, which yields a configuration instance for setting the text on the five main sections of the UI feature view.
131
-
132
- * `config.actors`
133
- * `config.groups`
134
- * `config.percentage_of_actors`
135
- * `config.percentage_of_time`
136
- * `config.delete`
137
-
138
- Each of these methods returns a [Flipper::UI::Option](https://github.com/jnunemaker/flipper/blob/master/lib/flipper/ui/configuration/option.rb) that responds to `title=`, `description=` as seen below.
139
-
140
- *e.g. customzing the percentage_of_actors and delete sections' titles and descriptions*
141
- ```ruby
142
- Flipper::UI.configure do |config|
143
- config.percentage_of_actors.title = "My Custom Title"
144
- config.percentage_of_actors.description = "My custom description"
132
+ Flipper UI can be customized via `configure`, which yields a configuration instance.
145
133
 
146
- config.delete.title = "BE VERY CAREFUL!"
147
- config.delete.description = "YOU'VE BEEN WARNED!"
148
- end
149
- ```
134
+ #### Description
150
135
 
151
- We can also associate a `description` for each `feature` by providing a descriptions source:
136
+ We can associate a `description` for each `feature` by providing a descriptions source:
152
137
 
153
138
  ```ruby
154
139
  Flipper::UI.configure do |config|
@@ -156,14 +141,18 @@ Flipper::UI.configure do |config|
156
141
  # descriptions loaded from YAML file or database (postgres, mysql, etc)
157
142
  # return has to be hash of {String key => String description}
158
143
  end
144
+
145
+ # Defaults to false. Set to true to show feature descriptions on the list
146
+ # page as well as the view page.
147
+ # config.show_feature_description_in_list = true
159
148
  end
160
149
  ```
161
150
 
162
- results in:
151
+ Descriptions show up in the UI like so:
163
152
 
164
- ![configure](images/configured-ui.png)
153
+ ![description](images/description.png)
165
154
 
166
- ### Banner
155
+ #### Banner
167
156
 
168
157
  Flipper UI can display a banner across the top of the page. The `banner_text` and `banner_class` can be configured by using the `Flipper::UI.configure` block as seen below.
169
158
 
@@ -178,9 +167,9 @@ By default the `environment` is set to an empty string so no banner will show. I
178
167
 
179
168
  The above configuration results in:
180
169
 
181
- ![configure](images/environment-banner.png)
170
+ ![banner](images/banner.png)
182
171
 
183
- ### Fun mode
172
+ #### Fun mode
184
173
 
185
174
  By default, Flipper UI displays a videoclip when there are no flags. The `fun` mode can be configured by using the `Flipper::UI.configure` block as seen below.
186
175
 
Binary file
Binary file
Binary file
@@ -39,6 +39,7 @@ Flipper::UI.configure do |config|
39
39
  # config.banner_class = 'danger'
40
40
  config.feature_creation_enabled = true
41
41
  config.feature_removal_enabled = true
42
+ # config.show_feature_description_in_list = true
42
43
  config.descriptions_source = lambda do |_keys|
43
44
  {
44
45
  "search_performance_another_long_thing" => "Just to test feature name length.",
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.metadata = Flipper::METADATA
22
22
 
23
23
  gem.add_dependency 'rack', '>= 1.4', '< 3'
24
- gem.add_dependency 'rack-protection', '>= 1.5.3', '< 2.1.0'
24
+ gem.add_dependency 'rack-protection', '>= 1.5.3', '< 2.2.0'
25
25
  gem.add_dependency 'flipper', "~> #{Flipper::VERSION}"
26
26
  gem.add_dependency 'erubi', '>= 1.0.0', '< 2.0.0'
27
27
  end
@@ -11,8 +11,20 @@ module Flipper
11
11
  def get
12
12
  @page_title = 'Features'
13
13
  keys = flipper.features.map(&:key)
14
+ descriptions = if Flipper::UI.configuration.show_feature_description_in_list?
15
+ Flipper::UI.configuration.descriptions_source.call(keys)
16
+ else
17
+ {}
18
+ end
19
+
14
20
  @features = flipper.features.map do |feature|
15
- Decorators::Feature.new(feature)
21
+ decorated_feature = Decorators::Feature.new(feature)
22
+
23
+ if Flipper::UI.configuration.show_feature_description_in_list?
24
+ decorated_feature.description = descriptions[feature.key]
25
+ end
26
+
27
+ decorated_feature
16
28
  end.sort
17
29
 
18
30
  @show_blank_slate = @features.empty?
@@ -33,9 +33,13 @@ module Flipper
33
33
 
34
34
  # Public: If you set this, Flipper::UI will fetch descriptions
35
35
  # from your external source. Descriptions for `features` will be shown on `feature`
36
- # and `features` pages. Defaults to empty block.
36
+ # page, and optionally the `features` pages. Defaults to empty block.
37
37
  attr_accessor :descriptions_source
38
38
 
39
+ # Public: Should feature descriptions be show on the `features` list page.
40
+ # Default false. Only works when using descriptions.
41
+ attr_accessor :show_feature_description_in_list
42
+
39
43
  VALID_BANNER_CLASS_VALUES = %w(
40
44
  danger
41
45
  dark
@@ -58,12 +62,17 @@ module Flipper
58
62
  @fun = true
59
63
  @add_actor_placeholder = "a flipper id"
60
64
  @descriptions_source = DEFAULT_DESCRIPTIONS_SOURCE
65
+ @show_feature_description_in_list = false
61
66
  end
62
67
 
63
68
  def using_descriptions?
64
69
  @descriptions_source != DEFAULT_DESCRIPTIONS_SOURCE
65
70
  end
66
71
 
72
+ def show_feature_description_in_list?
73
+ using_descriptions? && @show_feature_description_in_list
74
+ end
75
+
67
76
  def banner_class=(value)
68
77
  unless VALID_BANNER_CLASS_VALUES.include?(value)
69
78
  raise InvalidConfigurationValue, "The banner_class provided '#{value}' is " \
@@ -44,7 +44,12 @@
44
44
  </div>
45
45
  <div class="col-10">
46
46
  <a href="<%= "#{script_name}/features/#{feature.key}" %>" class="d-block px-0 py-3 btn text-left text-dark">
47
- <div class="text-truncate"><%= feature.key %></div>
47
+ <div class="text-truncate" style="font-weight: 500"><%= feature.key %></div>
48
+ <% if Flipper::UI.configuration.show_feature_description_in_list? && Flipper::UI::Util.present?(feature.description) %>
49
+ <div class="text-muted font-weight-light" style="line-height: 1.4; white-space: initial; padding: 8px 0">
50
+ <%= feature.description %>
51
+ </div>
52
+ <% end %>
48
53
  <div class="text-muted text-truncate">
49
54
  <%== feature.gates_in_words %>
50
55
  </div>
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.18.0'.freeze
2
+ VERSION = '0.20.0.beta3'.freeze
3
3
  end
@@ -100,4 +100,41 @@ RSpec.describe Flipper::UI::Configuration do
100
100
  end
101
101
  end
102
102
  end
103
+
104
+ describe "#show_feature_description_in_list" do
105
+ it "has default value" do
106
+ expect(configuration.show_feature_description_in_list).to eq(false)
107
+ end
108
+
109
+ it "can be updated" do
110
+ configuration.show_feature_description_in_list = true
111
+ expect(configuration.show_feature_description_in_list).to eq(true)
112
+ end
113
+ end
114
+
115
+ describe "#show_feature_description_in_list?" do
116
+ subject { configuration.show_feature_description_in_list? }
117
+
118
+ context 'when using_descriptions? is false and show_feature_description_in_list is false' do
119
+ it { is_expected.to eq(false) }
120
+ end
121
+
122
+ context 'when using_descriptions? is false and show_feature_description_in_list is true' do
123
+ before { configuration.show_feature_description_in_list = true }
124
+ it { is_expected.to eq(false) }
125
+ end
126
+
127
+ context 'when using_descriptions? is true and show_feature_description_in_list is false' do
128
+ before { allow(configuration).to receive(:using_descriptions?).and_return(true) }
129
+ it { is_expected.to eq(false) }
130
+ end
131
+
132
+ context 'when using_descriptions? is true and show_feature_description_in_list is true' do
133
+ before do
134
+ allow(configuration).to receive(:using_descriptions?).and_return(true)
135
+ configuration.show_feature_description_in_list = true
136
+ end
137
+ it { is_expected.to eq(true) }
138
+ end
139
+ end
103
140
  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.18.0
4
+ version: 0.20.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-25 00:00:00.000000000 Z
11
+ date: 2020-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: 1.5.3
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: 2.1.0
42
+ version: 2.2.0
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,21 +49,21 @@ dependencies:
49
49
  version: 1.5.3
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: 2.1.0
52
+ version: 2.2.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: flipper
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: 0.18.0
59
+ version: 0.20.0.beta3
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.18.0
66
+ version: 0.20.0.beta3
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: erubi
69
69
  requirement: !ruby/object:Gem::Requirement
@@ -92,8 +92,8 @@ extensions: []
92
92
  extra_rdoc_files: []
93
93
  files:
94
94
  - docs/ui/README.md
95
- - docs/ui/images/configured-ui.png
96
- - docs/ui/images/environment-banner.png
95
+ - docs/ui/images/banner.png
96
+ - docs/ui/images/description.png
97
97
  - docs/ui/images/feature.png
98
98
  - docs/ui/images/features.png
99
99
  - examples/ui/basic.ru
@@ -172,9 +172,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  requirements:
175
- - - ">="
175
+ - - ">"
176
176
  - !ruby/object:Gem::Version
177
- version: '0'
177
+ version: 1.3.1
178
178
  requirements: []
179
179
  rubygems_version: 3.0.3
180
180
  signing_key: