diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 134725cda..d29f10ba2 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -212,5 +212,12 @@ + +
  • "> + <%= link_to admin_settings_path do %> + + <%= t("admin.settings.index.title") %> + <% end %> +
  • diff --git a/app/views/admin/settings/_banner_images.html.erb b/app/views/admin/settings/_banner_images.html.erb new file mode 100644 index 000000000..a852f20b1 --- /dev/null +++ b/app/views/admin/settings/_banner_images.html.erb @@ -0,0 +1,24 @@ +<% if @banner_imgs.present?%> +

    <%= t("admin.settings.index.banner_imgs") %>

    + + + + <% @banner_imgs.each do |setting| %> + + + + + + <% end %> + +
    + <%= t("settings.#{setting.key}") %> + + <%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %> + <%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %> + <%= f.submit(t('admin.settings.index.update_setting'), class: "button small success") %> + <% end %> +
    +<% else %> +

    <%= t("admin.settings.index.no_banners_images") %>

    +<% end %> diff --git a/app/views/admin/settings/_banner_styles.html.erb b/app/views/admin/settings/_banner_styles.html.erb new file mode 100644 index 000000000..5477ce438 --- /dev/null +++ b/app/views/admin/settings/_banner_styles.html.erb @@ -0,0 +1,24 @@ +<% if @banner_styles.present? %> +

    <%= t("admin.settings.index.banners") %>

    + + + + <% @banner_styles.each do |setting| %> + + + + + + <% end %> + +
    + <%= t("settings.#{setting.key}") %> + + <%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %> + <%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %> + <%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow") %> + <% end %> +
    +<% else %> +

    <%= t("admin.settings.index.no_banners_styles") %>

    +<% end %> diff --git a/app/views/admin/settings/_configuration.html.erb b/app/views/admin/settings/_configuration.html.erb new file mode 100644 index 000000000..edadbb604 --- /dev/null +++ b/app/views/admin/settings/_configuration.html.erb @@ -0,0 +1,23 @@ +

    <%= t("admin.settings.index.title") %>

    + + + + <% @settings.each do |setting| %> + + + + + <% end %> + +
    + <%= t("settings.#{setting.key}") %> + + <%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %> +
    + <%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %> +
    +
    + <%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %> +
    + <% end %> +
    diff --git a/app/views/admin/settings/_feature_flags.html.erb b/app/views/admin/settings/_feature_flags.html.erb new file mode 100644 index 000000000..5c3660065 --- /dev/null +++ b/app/views/admin/settings/_feature_flags.html.erb @@ -0,0 +1,27 @@ +

    <%= t("admin.settings.index.feature_flags") %>

    + + + + <% @feature_flags.each do |feature_flag| %> + + + + + + + + <% end %> + +
    + <%= t("settings.#{feature_flag.key}") %> + + <%= feature_flag.enabled? ? t("admin.settings.index.features.enabled") : t("admin.settings.index.features.disabled") %> + + <%= 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 expanded #{feature_flag.enabled? ? 'hollow alert' : 'success'}", + data: {confirm: t("admin.actions.confirm")}) %> + <% end %> +
    diff --git a/app/views/admin/settings/_filter_subnav.html.erb b/app/views/admin/settings/_filter_subnav.html.erb new file mode 100644 index 000000000..c7d81e0a5 --- /dev/null +++ b/app/views/admin/settings/_filter_subnav.html.erb @@ -0,0 +1,31 @@ + diff --git a/app/views/admin/settings/_map_configuration.html.erb b/app/views/admin/settings/_map_configuration.html.erb new file mode 100644 index 000000000..342e05f32 --- /dev/null +++ b/app/views/admin/settings/_map_configuration.html.erb @@ -0,0 +1,8 @@ +<% if feature?(:map) %> +

    <%= t("admin.settings.index.map.title") %>

    +

    <%= t("admin.settings.index.map.help") %>

    + + <%= render "map_form" %> +<% else %> +

    No map to show.

    +<% end %> diff --git a/app/views/admin/settings/index.html.erb b/app/views/admin/settings/index.html.erb index e49174fca..7c03d77a5 100644 --- a/app/views/admin/settings/index.html.erb +++ b/app/views/admin/settings/index.html.erb @@ -1,105 +1,24 @@ -

    <%= t("admin.settings.index.title") %>

    +

    Settings

    +
    + <%= render "filter_subnav" %> - - - <% @settings.each do |setting| %> - - - - - <% end %> - -
    - <%= t("settings.#{setting.key}") %> - - <%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %> -
    - <%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %> -
    -
    - <%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %> -
    - <% end %> -
    +
    + <%= render "configuration" %> +
    -

    <%= t("admin.settings.index.feature_flags") %>

    +
    + <%= render "feature_flags" %> +
    - - - <% @feature_flags.each do |feature_flag| %> - - +
    + <%= render "banner_styles" %> +
    - +
    + <%= render "banner_images" %> +
    - - - <% end %> - -
    - <%= t("settings.#{feature_flag.key}") %> - - <%= feature_flag.enabled? ? t("admin.settings.index.features.enabled") : t("admin.settings.index.features.disabled") %> - - <%= 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 expanded #{feature_flag.enabled? ? 'hollow alert' : 'success'}", - data: {confirm: t("admin.actions.confirm")}) %> - <% end %> -
    - -<% if @banner_styles.present? %> -

    <%= t("admin.settings.index.banners") %>

    - - - - <% @banner_styles.each do |setting| %> - - - - - - <% end %> - -
    - <%= t("settings.#{setting.key}") %> - - <%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %> - <%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %> - <%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow") %> - <% end %> -
    -<% end %> - -<% if @banner_imgs.present?%> -

    <%= t("admin.settings.index.banner_imgs") %>

    - - - - <% @banner_imgs.each do |setting| %> - - - - - - <% end %> - -
    - <%= t("settings.#{setting.key}") %> - - <%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %> - <%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %> - <%= f.submit(t('admin.settings.index.update_setting'), class: "button small success") %> - <% end %> -
    -<% end %> - -<% if feature?(:map) %> -

    <%= t("admin.settings.index.map.title") %>

    -

    <%= t("admin.settings.index.map.help") %>

    - - <%= render "map_form" %> - -<% end %> +
    + <%= render "map_configuration" %> +
    +
    diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index bf4202a60..c0690c3f2 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -921,6 +921,8 @@ en: index: banners: Banner styles banner_imgs: Banner images + no_banners_images: No banner images + no_banners_styles: No banner styles title: Configuration settings update_setting: Update feature_flags: Features diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 002fb21ed..7e0d36fd3 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -919,8 +919,10 @@ es: flash: updated: Valor actualizado index: - banners: Banner style - banner_imgs: Banner images + banners: Estilo del banner + banner_imgs: Imagenes del banner + no_banners_images: No hay imagenes de banner + no_banners_styles: No hay estilos de banner title: Configuración global update_setting: Actualizar feature_flags: Funcionalidades diff --git a/spec/features/admin/settings_spec.rb b/spec/features/admin/settings_spec.rb index c81b2d323..7a98155bc 100644 --- a/spec/features/admin/settings_spec.rb +++ b/spec/features/admin/settings_spec.rb @@ -35,8 +35,9 @@ feature 'Admin settings' do admin = create(:administrator).user login_as(admin) visit admin_settings_path + find("#map-tab").click - expect(page).not_to have_content "Map configuration" + expect(page).not_to have_css("#admin-map") end scenario "Should be able when map feature activated" do @@ -44,8 +45,9 @@ feature 'Admin settings' do admin = create(:administrator).user login_as(admin) visit admin_settings_path + find("#map-tab").click - expect(page).to have_content "Map configuration" + expect(page).to have_css("#admin-map") end scenario "Should show successful notice" do @@ -78,6 +80,7 @@ feature 'Admin settings' do login_as(admin) visit admin_settings_path + find("#map-tab").click find("#admin-map").click within "#map-form" do click_on "Update" @@ -96,6 +99,7 @@ feature 'Admin settings' do setting = Setting.where(key: "feature.user.skip_verification").first visit admin_settings_path + find("#features-tab").click accept_alert do find("#edit_setting_#{setting.id} .button").click @@ -109,6 +113,7 @@ feature 'Admin settings' do setting = Setting.where(key: "feature.user.skip_verification").first visit admin_settings_path + find("#features-tab").click accept_alert do find("#edit_setting_#{setting.id} .button").click @@ -121,4 +126,4 @@ feature 'Admin settings' do end -end \ No newline at end of file +end