Skip to content

Commit

Permalink
Merge pull request #680 from Lockyy/decouple-confirmation-text
Browse files Browse the repository at this point in the history
Flipper UI - Fix issue preventing feature flags being enabled when confirm_fully_enable is on and feature_removal_enabled is off
  • Loading branch information
jnunemaker committed Dec 1, 2022
2 parents 5e7d9bb + 01156ac commit 21c5610
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/flipper/ui/public/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $(function () {
});

$("#enable_feature__button").on("click", function (e) {
const featureName = $("#feature_name").val();
const featureName = $(e.target).data("confirmation-text");
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}`
);
Expand All @@ -16,7 +16,7 @@ $(function () {
});

$("#delete_feature__button").on("click", function (e) {
const featureName = $("#feature_name").val();
const featureName = $(e.target).data("confirmation-text");
const promptMessage = prompt(
`Are you sure you want to remove this feature from the list of features and disable it for everyone? Please enter the name of the feature to confirm it: ${featureName}`
);
Expand Down
5 changes: 4 additions & 1 deletion lib/flipper/ui/views/feature.erb
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@
<div class="col">
<button type="submit" name="action" value="Enable" <% if Flipper::UI.configuration.confirm_fully_enable %>id="enable_feature__button"<% end %> class="btn btn-outline-success btn-block" <% if Flipper::UI.configuration.read_only %>disabled<% end %>>
<span class="d-block" data-toggle="tooltip"
<% if Flipper::UI.configuration.confirm_fully_enable %>
data-confirmation-text="<%= feature_name %>"
<% end %>
<% if Flipper::UI.configuration.read_only %>
title="Fully enable is not allowed in read only mode."
<% else %>
Expand Down Expand Up @@ -289,7 +292,7 @@
<%== csrf_input_tag %>
<input type="hidden" id="feature_name" name="_feature" value="<%= feature_name %>">
<input type="hidden" name="_method" value="DELETE">
<button type="submit" name="action" value="Delete" id="delete_feature__button" class="btn btn-outline-danger" data-toggle="tooltip" title="Remove feature from list of features and disable it." data-placement="right">Delete</button>
<button type="submit" name="action" value="Delete" id="delete_feature__button" data-confirmation-text="<%= feature_name %>" class="btn btn-outline-danger" data-toggle="tooltip" title="Remove feature from list of features and disable it." data-placement="right">Delete</button>
</form>
</div>
</div>
Expand Down
11 changes: 11 additions & 0 deletions spec/flipper/ui/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@
end
end

describe "#confirm_fully_enable" do
it "has default value" do
expect(configuration.confirm_fully_enable).to eq(false)
end

it "can be updated" do
configuration.confirm_fully_enable = true
expect(configuration.confirm_fully_enable).to eq(true)
end
end

describe "#show_feature_description_in_list" do
it "has default value" do
expect(configuration.show_feature_description_in_list).to eq(false)
Expand Down

0 comments on commit 21c5610

Please sign in to comment.