Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Confirm Warning for Fully Enable feature #665

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/flipper/ui/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class Configuration
# Default is comma ",".
attr_accessor :actors_separator

# Public: if you want to get a confirm pop up box while fully enabling a feature
# Default is False
jnunemaker marked this conversation as resolved.
Show resolved Hide resolved
attr_accessor :confirm_fully_enable

VALID_BANNER_CLASS_VALUES = %w(
danger
dark
Expand All @@ -74,6 +78,7 @@ def initialize
@descriptions_source = DEFAULT_DESCRIPTIONS_SOURCE
@show_feature_description_in_list = false
@actors_separator = ','
@confirm_fully_enable = false
end

def using_descriptions?
Expand Down
11 changes: 11 additions & 0 deletions lib/flipper/ui/public/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ $(function () {
return $container.toggleClass("toggle-on");
});

$("#enable_feature__button").on("click", function (e) {
const featureName = $("#feature_name").val();
const promptMessage = prompt(
`Are you sure you want to Fully Enable this feature for everyone? Please enter the name of the feature to confirm it: ${featureName}`
jnunemaker marked this conversation as resolved.
Show resolved Hide resolved
);

if (promptMessage !== featureName) {
e.preventDefault();
}
});

$("#delete_feature__button").on("click", function (e) {
const featureName = $("#feature_name").val();
const promptMessage = prompt(
Expand Down
24 changes: 17 additions & 7 deletions lib/flipper/ui/views/feature.erb
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,23 @@

<div class="row">
<% unless @feature.boolean_value %>
<div class="col">
<button type="submit" name="action" value="Enable" class="btn btn-outline-success btn-block">
<span class="d-block" data-toggle="tooltip" title="Enable for everyone">
Fully Enable
</span>
</button>
</div>
<% if Flipper::UI.configuration.confirm_fully_enable %>
<div class="col">
<button type="submit" name="action" value="Enable" id="enable_feature__button" class="btn btn-outline-success btn-block">
<span class="d-block" data-toggle="tooltip" title="Enable for everyone">
Fully Enable
</span>
</button>
</div>
<% else %>
<div class="col">
<button type="submit" name="action" value="Enable" class="btn btn-outline-success btn-block">
<span class="d-block" data-toggle="tooltip" title="Enable for everyone">
Fully Enable
</span>
</button>
</div>
<% end %>
<% end %>

<% unless @feature.off? %>
Expand Down