From 3029f51427de3fede2214c440bb5fe13f4e79834 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Tue, 18 Apr 2023 10:41:16 +0100 Subject: [PATCH] CLDC-2279 Bulk upload split feature toggle by log type (#1552) # Context - https://digital.dclg.gov.uk/jira/browse/CLDC-2279 # Changes - split bulk upload feature toggle by log type ie lettings and sales - this allows us to toggle with finer granularity - moved `FeatureToggle` from initializer to service class. not sure why it was an initializer in the first place? this means its available to zeitwerk and will be reloaded when needed --- {config/initializers => app/services}/feature_toggle.rb | 6 +++++- app/views/logs/index.html.erb | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) rename {config/initializers => app/services}/feature_toggle.rb (91%) diff --git a/config/initializers/feature_toggle.rb b/app/services/feature_toggle.rb similarity index 91% rename from config/initializers/feature_toggle.rb rename to app/services/feature_toggle.rb index 9986af543..eed6244d1 100644 --- a/config/initializers/feature_toggle.rb +++ b/app/services/feature_toggle.rb @@ -36,7 +36,11 @@ class FeatureToggle true end - def self.bulk_upload_logs? + def self.bulk_upload_lettings_logs? + !Rails.env.production? + end + + def self.bulk_upload_sales_logs? !Rails.env.production? end diff --git a/app/views/logs/index.html.erb b/app/views/logs/index.html.erb index 2d88c9bd6..04209be73 100644 --- a/app/views/logs/index.html.erb +++ b/app/views/logs/index.html.erb @@ -55,8 +55,12 @@ <%= govuk_button_to "Create a new sales log", sales_logs_path, class: "govuk-!-margin-right-6" %> <% end %> - <% if FeatureToggle.bulk_upload_logs? %> - <%= govuk_button_link_to "Upload #{log_type_for_controller(controller)} logs in bulk", bulk_upload_path_for_controller(controller, id: "start"), secondary: true %> + <% if FeatureToggle.bulk_upload_lettings_logs? && log_type_for_controller(controller) == "lettings" %> + <%= govuk_button_link_to "Upload lettings logs in bulk", bulk_upload_path_for_controller(controller, id: "start"), secondary: true %> + <% end %> + + <% if FeatureToggle.bulk_upload_sales_logs? && log_type_for_controller(controller) == "sales" %> + <%= govuk_button_link_to "Upload sales logs in bulk", bulk_upload_path_for_controller(controller, id: "start"), secondary: true %> <% end %> <% end %>