Skip to content

Commit d5d59e0

Browse files
authored
Merge pull request #959 from flippercloud/clicky-fixy
Fixes confirmation trigger for disable
2 parents b0ec079 + 50d967e commit d5d59e0

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

examples/ui/basic.ru

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Flipper::UI.configure do |config|
2525
config.feature_removal_enabled = true
2626
config.cloud_recommendation = true
2727
config.confirm_fully_enable = false
28+
config.confirm_disable = false
2829
config.read_only = false
2930
# config.show_feature_description_in_list = true
3031
config.descriptions_source = lambda do |_keys|

lib/flipper/ui/public/js/application.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ document.addEventListener("DOMContentLoaded", function () {
1212

1313
document.querySelectorAll("*[data-confirmation-text]").forEach(function (element) {
1414
element.addEventListener("click", function (e) {
15-
var expected = e.target.getAttribute("data-confirmation-text");
16-
var actual = prompt(e.target.getAttribute("data-confirmation-prompt"));
15+
var expected = element.getAttribute("data-confirmation-text");
16+
var actual = prompt(element.getAttribute("data-confirmation-prompt"));
1717

1818
if (expected !== actual) {
1919
e.preventDefault();

lib/flipper/ui/views/feature.erb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,13 @@
255255
<div class="row">
256256
<% unless @feature.boolean_value %>
257257
<div class="col d-grid">
258-
<button type="submit" name="action" value="Enable" class="btn btn-outline-success">
259-
<span class="d-block" data-bs-toggle="tooltip"
260-
<% if Flipper::UI.configuration.confirm_fully_enable %>
261-
data-confirmation-prompt="Are you sure you want to fully enable this feature for everyone? Please enter the name of the feature to confirm it: <%= feature_name %>"
262-
data-confirmation-text="<%= feature_name %>"
263-
<% end %>
264-
title="Enable for everyone"
265-
>
258+
<button type="submit" name="action" value="Enable" class="btn btn-outline-success"
259+
<% if Flipper::UI.configuration.confirm_fully_enable %>
260+
data-confirmation-prompt="Are you sure you want to fully enable this feature for everyone? Please enter the name of the feature to confirm it: <%= feature_name %>"
261+
data-confirmation-text="<%= feature_name %>"
262+
<% end %>
263+
>
264+
<span class="d-block" data-bs-toggle="tooltip" title="Enable for everyone">
266265
Fully Enable
267266
</span>
268267
</button>
@@ -271,14 +270,13 @@
271270

272271
<% unless @feature.off? %>
273272
<div class="col d-grid">
274-
<button type="submit" name="action" value="Disable" class="btn btn-outline-danger">
275-
<span class="d-block" data-bs-toggle="tooltip"
276-
<% if Flipper::UI.configuration.confirm_disable %>
277-
data-confirmation-prompt="Are you sure you want to disable this feature for everyone? Please enter the name of the feature to confirm it: <%= feature_name %>"
278-
data-confirmation-text="<%= feature_name %>"
279-
<% end %>
280-
title="Disable for everyone by clearing all percentages, groups and actors."
281-
>
273+
<button type="submit" name="action" value="Disable" class="btn btn-outline-danger"
274+
<% if Flipper::UI.configuration.confirm_disable %>
275+
data-confirmation-prompt="Are you sure you want to disable this feature for everyone? Please enter the name of the feature to confirm it: <%= feature_name %>"
276+
data-confirmation-text="<%= feature_name %>"
277+
<% end %>
278+
>
279+
<span class="d-block" data-bs-toggle="tooltip" title="Disable for everyone by clearing all percentages, groups and actors.">
282280
Disable
283281
</span>
284282
</button>

0 commit comments

Comments
 (0)