Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -63,6 +63,10 @@ class Configuration
# Default is false.
attr_accessor :confirm_fully_enable

# Public: if you want to get a confirm pop up box while disabling a feature
# Default is false.
attr_accessor :confirm_disable

VALID_BANNER_CLASS_VALUES = %w(
danger
dark
Expand Down Expand Up @@ -91,6 +95,7 @@ def initialize
@show_feature_description_in_list = false
@actors_separator = ','
@confirm_fully_enable = false
@confirm_disable = true
@read_only = false
end

Expand Down
13 changes: 12 additions & 1 deletion lib/flipper/ui/public/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ $(function () {
e.preventDefault();
}
});


$("#disable_feature__button").on("click", function (e) {
const featureName = $(e.target).data("confirmation-text");
const promptMessage = prompt(
`Are you sure you want to disable this feature for everyone? Please enter the name of the feature to confirm it: ${featureName}`
);

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

$("#delete_feature__button").on("click", function (e) {
const featureName = $(e.target).data("confirmation-text");
const promptMessage = prompt(
Expand Down
9 changes: 7 additions & 2 deletions lib/flipper/ui/views/feature.erb
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,13 @@

<% unless @feature.off? %>
<div class="col">
<button type="submit" name="action" value="Disable" class="btn btn-outline-danger btn-block">
<span class="d-block" data-toggle="tooltip" title="Disable for everyone by clearing all percentages, groups and actors.">
<button type="submit" name="action" value="Disable" <% if Flipper::UI.configuration.confirm_disable %>id="disable_feature__button"<% end %> class="btn btn-outline-danger btn-block">
<span class="d-block" data-toggle="tooltip"
<% if Flipper::UI.configuration.confirm_disable %>
data-confirmation-text="<%= feature_name %>"
<% end %>
title="Disable for everyone by clearing all percentages, groups and actors."
>
Disable
</span>
</button>
Expand Down