From b59af89c09c80e84748873fd8f0c914dc7ffa780 Mon Sep 17 00:00:00 2001 From: Adan Amarillas Date: Wed, 23 May 2018 11:31:53 -0700 Subject: [PATCH 1/6] Add 'settings' link to side menu on Admin's panel. --- app/views/admin/_menu.html.erb | 7 +++++++ 1 file changed, 7 insertions(+) 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 %> +
  • From 7f0bfd44b705b4ebdd1c34d68f7f6b749f128968 Mon Sep 17 00:00:00 2001 From: Adan Amarillas Date: Wed, 23 May 2018 16:38:00 -0700 Subject: [PATCH 2/6] Split configuration settings into tabs --- .../admin/settings/_banner_images.html.erb | 24 ++++ .../admin/settings/_banner_styles.html.erb | 24 ++++ .../admin/settings/_configuration.html.erb | 23 ++++ .../admin/settings/_feature_flags.html.erb | 28 +++++ .../admin/settings/_filter_subnav.html.erb | 31 +++++ .../settings/_map_configuration.html.erb | 8 ++ app/views/admin/settings/index.html.erb | 119 +++--------------- 7 files changed, 157 insertions(+), 100 deletions(-) create mode 100644 app/views/admin/settings/_banner_images.html.erb create mode 100644 app/views/admin/settings/_banner_styles.html.erb create mode 100644 app/views/admin/settings/_configuration.html.erb create mode 100644 app/views/admin/settings/_feature_flags.html.erb create mode 100644 app/views/admin/settings/_filter_subnav.html.erb create mode 100644 app/views/admin/settings/_map_configuration.html.erb 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..dad208e0d --- /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 %> +

    No banner images to show.

    +<% 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..90d303e45 --- /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 %> +

    No banner styles to show.

    +<% 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..89f57e1f7 --- /dev/null +++ b/app/views/admin/settings/_feature_flags.html.erb @@ -0,0 +1,28 @@ + +

    <%= 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..a7f2ae48f --- /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" %> +
    +
    From 2c5cefcfdd6656e7386fb5fd6e29a2852e66267a Mon Sep 17 00:00:00 2001 From: Adan Amarillas Date: Wed, 23 May 2018 18:58:14 -0700 Subject: [PATCH 3/6] Adjust tests to new navigation. Add id tag to map tab so it can be found by id --- app/views/admin/settings/_filter_subnav.html.erb | 2 +- spec/features/admin/settings_spec.rb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/admin/settings/_filter_subnav.html.erb b/app/views/admin/settings/_filter_subnav.html.erb index a7f2ae48f..0efa79570 100644 --- a/app/views/admin/settings/_filter_subnav.html.erb +++ b/app/views/admin/settings/_filter_subnav.html.erb @@ -23,7 +23,7 @@ <% end %> -
  • +
  • <%= link_to "#tab-map-configuration" do %> <%= t("admin.settings.index.map.title") %> <% end %> diff --git a/spec/features/admin/settings_spec.rb b/spec/features/admin/settings_spec.rb index c81b2d323..34c9732af 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" From 60bc3f663acd4faf9a6f7b695f9998c05f2deca3 Mon Sep 17 00:00:00 2001 From: Adan Amarillas Date: Thu, 24 May 2018 07:49:04 -0700 Subject: [PATCH 4/6] Make tabs i18n-friendly --- app/views/admin/settings/_banner_images.html.erb | 2 +- app/views/admin/settings/_banner_styles.html.erb | 2 +- app/views/admin/settings/_feature_flags.html.erb | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/admin/settings/_banner_images.html.erb b/app/views/admin/settings/_banner_images.html.erb index dad208e0d..a852f20b1 100644 --- a/app/views/admin/settings/_banner_images.html.erb +++ b/app/views/admin/settings/_banner_images.html.erb @@ -20,5 +20,5 @@ <% else %> -

    No banner images to show.

    +

    <%= 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 index 90d303e45..5477ce438 100644 --- a/app/views/admin/settings/_banner_styles.html.erb +++ b/app/views/admin/settings/_banner_styles.html.erb @@ -20,5 +20,5 @@ <% else %> -

    No banner styles to show.

    +

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

    <% end %> diff --git a/app/views/admin/settings/_feature_flags.html.erb b/app/views/admin/settings/_feature_flags.html.erb index 89f57e1f7..5c3660065 100644 --- a/app/views/admin/settings/_feature_flags.html.erb +++ b/app/views/admin/settings/_feature_flags.html.erb @@ -1,4 +1,3 @@ -

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

    From 1d974c41e3ad50030f6375c9c4a6a8edc99d8131 Mon Sep 17 00:00:00 2001 From: Adan Amarillas Date: Thu, 24 May 2018 12:27:07 -0700 Subject: [PATCH 5/6] Add missing i18n keys to locales --- config/locales/en/admin.yml | 2 ++ config/locales/es/admin.yml | 6 ++++-- spec/features/admin/settings_spec.rb | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 0292df944..28c395d04 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -919,6 +919,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 5d44c9a17..fb35855f2 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -917,8 +917,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 34c9732af..3e12bc54f 100644 --- a/spec/features/admin/settings_spec.rb +++ b/spec/features/admin/settings_spec.rb @@ -1,3 +1,4 @@ +# Failing spec require 'rails_helper' feature 'Admin settings' do @@ -124,4 +125,4 @@ feature 'Admin settings' do end -end \ No newline at end of file +end From 361518b57c60ff9479430c4c6712b3cffa79b91a Mon Sep 17 00:00:00 2001 From: Adan Amarillas Date: Thu, 24 May 2018 14:49:31 -0700 Subject: [PATCH 6/6] Modify tests to reflect the new navigation on admin configuration settings --- app/views/admin/settings/_filter_subnav.html.erb | 2 +- spec/features/admin/settings_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/admin/settings/_filter_subnav.html.erb b/app/views/admin/settings/_filter_subnav.html.erb index 0efa79570..c7d81e0a5 100644 --- a/app/views/admin/settings/_filter_subnav.html.erb +++ b/app/views/admin/settings/_filter_subnav.html.erb @@ -5,7 +5,7 @@ <% end %> -
  • +
  • <%= link_to "#tab-feature-flags" do %> <%= t("admin.settings.index.feature_flags") %> <% end %> diff --git a/spec/features/admin/settings_spec.rb b/spec/features/admin/settings_spec.rb index 3e12bc54f..7a98155bc 100644 --- a/spec/features/admin/settings_spec.rb +++ b/spec/features/admin/settings_spec.rb @@ -1,4 +1,3 @@ -# Failing spec require 'rails_helper' feature 'Admin settings' do @@ -100,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 @@ -113,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