diff --git a/.env.test b/.env.test index 3398f16e..d4f76620 100644 --- a/.env.test +++ b/.env.test @@ -1,5 +1,5 @@ ALMA_OPENURL=https://na06.alma.exlibrisgroup.com/view/uresolver/01MIT_INST/openurl? -GDT=false +FEATURE_GEODATA=false MIT_PRIMO_URL=https://mit.primo.exlibrisgroup.com PRIMO_API_KEY=FAKE_PRIMO_API_KEY PRIMO_API_URL=https://api-na.hosted.exlibrisgroup.com/primo/v1 @@ -12,4 +12,4 @@ TACOS_URL=http://FAKE_TACOS_HOST/graphql TACOS_SOURCE=FAKE_TACOS_SOURCE TIMDEX_GRAPHQL=https://FAKE_TIMDEX_HOST/graphql TIMDEX_HOST=FAKE_TIMDEX_HOST -TIMDEX_INDEX=FAKE_TIMDEX_INDEX \ No newline at end of file +TIMDEX_INDEX=FAKE_TIMDEX_INDEX diff --git a/Gemfile b/Gemfile index db1bab33..317b3125 100644 --- a/Gemfile +++ b/Gemfile @@ -52,5 +52,3 @@ group :test do gem 'vcr' gem 'webmock' end - -gem 'flipflop', '~> 2.7' diff --git a/Gemfile.lock b/Gemfile.lock index 95ebd9fc..72625ff9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -139,9 +139,6 @@ GEM ffi (>= 1.15.5) rake fiber-storage (1.0.1) - flipflop (2.8.0) - activesupport (>= 4.0) - terminal-table (>= 1.8) globalid (1.3.0) activesupport (>= 6.1) graphql (2.5.14) @@ -359,8 +356,6 @@ GEM stimulus-rails (1.3.4) railties (>= 6.0.0) stringio (3.1.7) - terminal-table (4.0.0) - unicode-display_width (>= 1.1.1, < 4) thor (1.4.0) tilt (2.6.0) timeout (0.4.3) @@ -415,7 +410,6 @@ DEPENDENCIES climate_control debug dotenv-rails - flipflop (~> 2.7) graphql graphql-client http diff --git a/README.md b/README.md index 3aae88d1..289f1b8b 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ requires testing against an index that contains geospatial records.) 3. Confirm that filters from multiple categories can be applied and removed, both on the sidebar and the panel beneath the search form. -If the `flipflop` gem has been updated, check that the `:gdt` feature is working by ensuring that +Check that the `:geodata` feature is working by ensuring that UI elements specific to GDT (e.g., geospatial search fields or the 'Ask GIS' link) appear with the feature flag enabled, and do not when it is disabled. @@ -91,8 +91,11 @@ See `Optional Environment Variables` for more information. `basic_search#index`. - `ACTIVE_FILTERS`: If populated, this list of strings defines which filters are shown to the user, and the order in which they appear. Values are case sensitive, and must match the corresponding aggregations used in the TIMDEX GraphQL query. Extraneous values will be ignored. If not populated, all filters will be shown. - `BOOLEAN_OPTIONS`: comma separated list of values to present to testers on instances where `BOOLEAN_PICKER` feature is enabled. -- `BOOLEAN_PICKER`: feature to allow users to select their preferred boolean type. If set, feature is enabled. This feature is only intended for internal team +- `FEATURE_BOOLEAN_PICKER`: feature to allow users to select their preferred boolean type. If set to `true`, feature is enabled. This feature is only intended for internal team testing and should never be enabled in production (mostly because the UI is a mess more than it would cause harm). +- `FEATURE_GEODATA`: Enables features related to geospatial data discovery. Setting this variable to `true` will trigger geodata +mode. Note that this is currently intended _only_ for the geodata app and +may have unexpected consequences if applied to other TIMDEX UI apps. - `FILTER_ACCESS_TO_FILES`: The name to use instead of "Access to files" for that filter / aggregation. - `FILTER_CONTENT_TYPE`: The name to use instead of "Content type" for that filter / aggregation. - `FILTER_CONTRIBUTOR`: The name to use instead of "Contributor" for that filter / aggregation. @@ -102,9 +105,6 @@ See `Optional Environment Variables` for more information. - `FILTER_PLACE`: The name to use instead of "Place" for that filter / aggregation. - `FILTER_SOURCE`: The name to use instead of "Source" for that filter / aggregation. - `FILTER_SUBJECT`: The name to use instead of "Subject" for that filter / aggregation. -- `GDT`: Enables features related to geospatial data discovery. Setting this variable with any value will trigger GDT -mode (e.g., `GDT=false` will still enable GDT features). Note that this is currently intended _only_ for the GDT app and -may have unexpected consequences if applied to other TIMDEX UI apps. - `GLOBAL_ALERT`: The main functionality for this comes from our theme gem, but when set the value will be rendered as safe html above the main header of the site. - `ORIGINS`: sets origins for CORS (currently used only for TACOS API calls). diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 6de03e29..7ddc5aad 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,22 +1,20 @@ class SearchController < ApplicationController before_action :validate_q!, only: %i[results] - if Flipflop.enabled?(:gdt) - before_action :validate_geobox_presence!, only: %i[results] - before_action :validate_geobox_range!, only: %i[results] - before_action :validate_geobox_values!, only: %i[results] - before_action :validate_geodistance_presence!, only: %i[results] - before_action :validate_geodistance_range!, only: %i[results] - before_action :validate_geodistance_value!, only: %i[results] - before_action :validate_geodistance_units!, only: %i[results] - end + before_action :validate_geobox_presence!, only: %i[results] + before_action :validate_geobox_range!, only: %i[results] + before_action :validate_geobox_values!, only: %i[results] + before_action :validate_geodistance_presence!, only: %i[results] + before_action :validate_geodistance_range!, only: %i[results] + before_action :validate_geodistance_value!, only: %i[results] + before_action :validate_geodistance_units!, only: %i[results] def results # inject session preference for boolean type if it is present params[:booleanType] = cookies[:boolean_type] || 'AND' # Determine which tab to load - default to primo unless gdt is enabled - @active_tab = if Flipflop.enabled?(:gdt) + @active_tab = if Feature.enabled?(:geodata) 'gdt' # Keep existing GDT behavior unchanged else params[:tab] || 'primo' # Default to primo for new tabbed interface @@ -24,7 +22,7 @@ def results @enhanced_query = Enhancer.new(params).enhanced_query # Route to appropriate search based on active tab - if Flipflop.enabled?(:gdt) + if Feature.enabled?(:geodata) # Keep existing GDT behavior unchanged load_gdt_results render 'results_geo' @@ -185,6 +183,8 @@ def validate_q! end def validate_geodistance_presence! + return unless Feature.enabled?(:geodata) + return unless params[:geodistance]&.strip == 'true' geodistance_params = [params[:geodistanceLatitude]&.strip, params[:geodistanceLongitude]&.strip, @@ -196,6 +196,8 @@ def validate_geodistance_presence! end def validate_geobox_presence! + return unless Feature.enabled?(:geodata) + return unless params[:geobox]&.strip == 'true' geobox_params = [params[:geoboxMinLatitude]&.strip, params[:geoboxMinLongitude]&.strip, @@ -207,6 +209,8 @@ def validate_geobox_presence! end def validate_geodistance_range! + return unless Feature.enabled?(:geodata) + return unless params[:geodistance]&.strip == 'true' invalid_range = false @@ -222,6 +226,8 @@ def validate_geodistance_range! end def validate_geobox_range! + return unless Feature.enabled?(:geodata) + return unless params[:geobox]&.strip == 'true' invalid_range = false @@ -237,6 +243,8 @@ def validate_geobox_range! end def validate_geodistance_value! + return unless Feature.enabled?(:geodata) + return unless params[:geodistance]&.strip == 'true' distance = params[:geodistanceDistance]&.strip.to_i @@ -247,6 +255,8 @@ def validate_geodistance_value! end def validate_geodistance_units! + return unless Feature.enabled?(:geodata) + return unless params[:geodistance]&.strip == 'true' distance = params[:geodistanceDistance]&.strip @@ -265,6 +275,8 @@ def validate_geodistance_units! end def validate_geobox_values! + return unless Feature.enabled?(:geodata) + return unless params[:geobox]&.strip == 'true' geobox_lat = [params[:geoboxMinLatitude]&.strip.to_f, params[:geoboxMaxLatitude]&.strip.to_f] diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index ca04667c..23284a9d 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -77,7 +77,7 @@ def applied_advanced_terms(query) # Query params need some treatment to look decent in the search summary panel. def readable_param(param) return 'Keyword anywhere' if param == 'q' - return 'Authors' if param == 'contributors' && Flipflop.enabled?(:gdt) + return 'Authors' if param == 'contributors' && Feature.enabled?(:geodata) if param.starts_with?('geodistance') param = param.gsub('geodistance', '') diff --git a/app/models/enhancer.rb b/app/models/enhancer.rb index b922240e..61e006c0 100644 --- a/app/models/enhancer.rb +++ b/app/models/enhancer.rb @@ -14,7 +14,7 @@ def initialize(params) @enhanced_query[:advanced] = 'true' if params[:advanced].present? @enhanced_query[:booleanType] = params[:booleanType] || 'AND' - if Flipflop.enabled?(:gdt) + if Feature.enabled?(:geodata) @enhanced_query[:geobox] = 'true' if params[:geobox] == 'true' @enhanced_query[:geodistance] = 'true' if params[:geodistance] == 'true' end @@ -38,7 +38,7 @@ def extract_query(params) end def extract_geosearch(params) - return unless Flipflop.enabled?(:gdt) + return unless Feature.enabled?(:geodata) GEO_PARAMS.each do |gp| @enhanced_query[gp] = params[gp] if params[gp].present? diff --git a/app/models/query_builder.rb b/app/models/query_builder.rb index a50037a5..4031feb2 100644 --- a/app/models/query_builder.rb +++ b/app/models/query_builder.rb @@ -12,7 +12,7 @@ def initialize(enhanced_query) @query = {} @query['from'] = calculate_from(enhanced_query[:page]) - if Flipflop.enabled?(:gdt) + if Feature.enabled?(:geodata) @query['geobox'] = 'true' if enhanced_query[:geobox] == 'true' @query['geodistance'] = 'true' if enhanced_query[:geodistance] == 'true' end @@ -40,7 +40,7 @@ def extract_query(enhanced_query) end def extract_geosearch(enhanced_query) - return unless Flipflop.enabled?(:gdt) + return unless Feature.enabled?(:geodata) GEO_PARAMS.each do |gp| if coerce_to_float?(gp) diff --git a/app/views/basic_search/index.html.erb b/app/views/basic_search/index.html.erb index 7b2c7996..4c8f803c 100644 --- a/app/views/basic_search/index.html.erb +++ b/app/views/basic_search/index.html.erb @@ -2,6 +2,6 @@
<%= render partial: "shared/site_title" %> - <%= render partial: "search/form_geo" if Flipflop.enabled?(:gdt) %> + <%= render partial: "search/form_geo" if Feature.enabled?(:geodata) %> <%= render partial: "static/about" if ENV.fetch('ABOUT_APP', nil) %>
diff --git a/app/views/layouts/_site_header.html.erb b/app/views/layouts/_site_header.html.erb index ad3c9193..49332e99 100644 --- a/app/views/layouts/_site_header.html.erb +++ b/app/views/layouts/_site_header.html.erb @@ -20,12 +20,12 @@ - <%= render partial: 'search/form' unless Flipflop.enabled?(:gdt) %> + <%= render partial: 'search/form' unless Feature.enabled?(:geodata) %> - \ No newline at end of file + diff --git a/app/views/record/_sidebar.html.erb b/app/views/record/_sidebar.html.erb index 51e0c8fe..0d95121e 100644 --- a/app/views/record/_sidebar.html.erb +++ b/app/views/record/_sidebar.html.erb @@ -1,15 +1,15 @@ -<% if Flipflop.enabled?(:gdt) %> +<% if Feature.enabled?(:geodata) %> <% else %> diff --git a/app/views/record/view.html.erb b/app/views/record/view.html.erb index cd5c4a2e..511a3558 100644 --- a/app/views/record/view.html.erb +++ b/app/views/record/view.html.erb @@ -12,7 +12,7 @@ <% if @record.nil? %> <%= render('record_empty') %> -<% elsif Flipflop.enabled?(:gdt) %> +<% elsif Feature.enabled?(:geodata) %> <%= render('record_geo') %> <% else %> <%= render('record') %> diff --git a/app/views/search/_filter.html.erb b/app/views/search/_filter.html.erb index 9c71da4f..09355113 100644 --- a/app/views/search/_filter.html.erb +++ b/app/views/search/_filter.html.erb @@ -15,7 +15,7 @@ Apply filter: <% end %> - <% if Flipflop.enabled?(:gdt) %> + <% if Feature.enabled?(:geodata) %> <%= gdt_sources(term['key'], category) %> <% else %> <%= term['key'] %> diff --git a/app/views/search/_form.html.erb b/app/views/search/_form.html.erb index deacab7f..157029f6 100644 --- a/app/views/search/_form.html.erb +++ b/app/views/search/_form.html.erb @@ -11,7 +11,7 @@ -<% if Flipflop.enabled?(:boolean_picker) %> +<% if Feature.enabled?(:boolean_picker) %>