adds specific treatment for feature flags in admin
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
class Admin::SettingsController < Admin::BaseController
|
class Admin::SettingsController < Admin::BaseController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@settings = Setting.all
|
all_settings = (Setting.all).group_by { |s| s.feature_flag? }
|
||||||
|
@settings = all_settings[false]
|
||||||
|
@feature_flags = all_settings[true]
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|||||||
@@ -12,3 +12,23 @@
|
|||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<h2><%= t("admin.settings.index.feature_flags") %></h2>
|
||||||
|
|
||||||
|
<ul class="admin-list">
|
||||||
|
<% @feature_flags.each do |feature_flag| %>
|
||||||
|
<li>
|
||||||
|
<strong><%= t("settings.#{feature_flag.key}") %></strong>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<%= feature_flag.enabled? ? t("admin.settings.index.features.enabled") : t("admin.settings.index.features.disabled") %>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<%= form_for(feature_flag, url: admin_setting_path(feature_flag), html: { id: "edit_#{dom_id(feature_flag)}"}) do |f| %>
|
||||||
|
|
||||||
|
<%= f.hidden_field :value, id: dom_id(feature_flag), value: (feature_flag.enabled? ? "" : "active") %>
|
||||||
|
<%= f.submit(t("admin.settings.index.features.#{feature_flag.enabled? ? 'disable' : 'enable'}"), class: "button radius tiny #{feature_flag.enabled? ? 'warning' : 'success'}", data: {confirm: t("admin.actions.confirm")}) %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
|||||||
@@ -123,6 +123,12 @@ en:
|
|||||||
index:
|
index:
|
||||||
title: Configuration settings
|
title: Configuration settings
|
||||||
update_setting: Update
|
update_setting: Update
|
||||||
|
feature_flags: Features
|
||||||
|
features:
|
||||||
|
enabled: "Feature enabled"
|
||||||
|
disabled: "Feature disabled"
|
||||||
|
enable: "Enable"
|
||||||
|
disable: "Disable"
|
||||||
shared:
|
shared:
|
||||||
proposal_search:
|
proposal_search:
|
||||||
button: Search
|
button: Search
|
||||||
|
|||||||
@@ -123,6 +123,12 @@ es:
|
|||||||
index:
|
index:
|
||||||
title: Configuración global
|
title: Configuración global
|
||||||
update_setting: Actualizar
|
update_setting: Actualizar
|
||||||
|
feature_flags: Funcionalidades
|
||||||
|
features:
|
||||||
|
enabled: "Funcionalidad activada"
|
||||||
|
disabled: "Funcionalidad desactivada"
|
||||||
|
enable: "Activar"
|
||||||
|
disable: "Desactivar"
|
||||||
shared:
|
shared:
|
||||||
proposal_search:
|
proposal_search:
|
||||||
button: Buscar
|
button: Buscar
|
||||||
|
|||||||
@@ -12,3 +12,6 @@ en:
|
|||||||
votes_for_proposal_success: "Number of votes necessary for approval of a Proposal"
|
votes_for_proposal_success: "Number of votes necessary for approval of a Proposal"
|
||||||
email_domain_for_officials: "Email domain for public officials"
|
email_domain_for_officials: "Email domain for public officials"
|
||||||
per_page_code: "Code to be included on every page"
|
per_page_code: "Code to be included on every page"
|
||||||
|
feature:
|
||||||
|
debates: Debates
|
||||||
|
spending_proposals: Spending proposals
|
||||||
|
|||||||
@@ -12,3 +12,6 @@ es:
|
|||||||
votes_for_proposal_success: "Número de votos necesarios para aprobar una Propuesta"
|
votes_for_proposal_success: "Número de votos necesarios para aprobar una Propuesta"
|
||||||
email_domain_for_officials: "Dominio de email para cargos públicos"
|
email_domain_for_officials: "Dominio de email para cargos públicos"
|
||||||
per_page_code: "Código a incluir en cada página"
|
per_page_code: "Código a incluir en cada página"
|
||||||
|
feature:
|
||||||
|
debates: Debates
|
||||||
|
spending_proposals: Propuestas de gasto
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ feature 'Admin feature flags' do
|
|||||||
visit admin_settings_path
|
visit admin_settings_path
|
||||||
|
|
||||||
within("#edit_setting_#{setting_id}") do
|
within("#edit_setting_#{setting_id}") do
|
||||||
fill_in "setting_#{setting_id}", with: ''
|
expect(page).to have_button "Disable"
|
||||||
click_button 'Update'
|
expect(page).to_not have_button "Enable"
|
||||||
|
click_button 'Disable'
|
||||||
end
|
end
|
||||||
|
|
||||||
visit admin_root_path
|
visit admin_root_path
|
||||||
@@ -48,8 +49,9 @@ feature 'Admin feature flags' do
|
|||||||
visit admin_settings_path
|
visit admin_settings_path
|
||||||
|
|
||||||
within("#edit_setting_#{setting_id}") do
|
within("#edit_setting_#{setting_id}") do
|
||||||
fill_in "setting_#{setting_id}", with: 'true'
|
expect(page).to have_button "Enable"
|
||||||
click_button 'Update'
|
expect(page).to_not have_button "Disable"
|
||||||
|
click_button 'Enable'
|
||||||
end
|
end
|
||||||
|
|
||||||
visit admin_root_path
|
visit admin_root_path
|
||||||
|
|||||||
Reference in New Issue
Block a user