From 98fc2fcc914aea067597b28cd1d94a6c89dc99a6 Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Thu, 23 Oct 2025 16:02:58 -0400 Subject: [PATCH 1/6] Remove FlipFlip gem https://mitlibraries.atlassian.net/browse/USE-77 --- .env.test | 4 ++-- Gemfile | 2 -- Gemfile.lock | 6 ------ README.md | 10 +++++----- config/application.rb | 8 -------- config/environments/development.rb | 8 -------- config/environments/test.rb | 8 -------- config/features.rb | 13 ------------- config/routes.rb | 1 - db/migrate/20251023203259_drop_flipflip_features.rb | 10 ++++++++++ db/schema.rb | 9 +-------- 11 files changed, 18 insertions(+), 61 deletions(-) delete mode 100644 config/features.rb create mode 100644 db/migrate/20251023203259_drop_flipflip_features.rb 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..b225d095 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_GDT`: 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/config/application.rb b/config/application.rb index 7ea7b1b2..db6e9070 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,14 +11,6 @@ module TimdexUi class Application < Rails::Application - # Before filter for Flipflop dashboard. Replace with a lambda or method name - # defined in ApplicationController to implement access control. - config.flipflop.dashboard_access_filter = -> { head :forbidden } - - # By default, when set to `nil`, strategy loading errors are suppressed in test - # mode. Set to `true` to always raise errors, or `false` to always warn. - config.flipflop.raise_strategy_errors = nil - # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.2 diff --git a/config/environments/development.rb b/config/environments/development.rb index 9e75f029..9b673600 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,14 +1,6 @@ require "active_support/core_ext/integer/time" Rails.application.configure do - # Before filter for Flipflop dashboard. Replace with a lambda or method name - # defined in ApplicationController to implement access control. - config.flipflop.dashboard_access_filter = nil - - # By default, when set to `nil`, strategy loading errors are suppressed in test - # mode. Set to `true` to always raise errors, or `false` to always warn. - config.flipflop.raise_strategy_errors = nil - # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded any time diff --git a/config/environments/test.rb b/config/environments/test.rb index a955bbbd..0eae17f6 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -6,14 +6,6 @@ # and recreated between test runs. Don't rely on the data there! Rails.application.configure do - # Before filter for Flipflop dashboard. Replace with a lambda or method name - # defined in ApplicationController to implement access control. - config.flipflop.dashboard_access_filter = nil - - # By default, when set to `nil`, strategy loading errors are suppressed in test - # mode. Set to `true` to always raise errors, or `false` to always warn. - config.flipflop.raise_strategy_errors = nil - # Settings specified here will take precedence over those in config/application.rb. # While tests run files are not watched, reloading is not necessary. diff --git a/config/features.rb b/config/features.rb deleted file mode 100644 index fb551ec2..00000000 --- a/config/features.rb +++ /dev/null @@ -1,13 +0,0 @@ -Flipflop.configure do - # Strategies will be used in the order listed here. - strategy :session - strategy :default - - feature :gdt, - default: ENV.fetch('GDT', false), - description: "Enable geodata discovery features." - - feature :boolean_picker, - default: ENV.fetch('BOOLEAN_PICKER', false), - description: "Enable user configurable boolean type selection." -end diff --git a/config/routes.rb b/config/routes.rb index e1c2acf6..82746036 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,4 @@ Rails.application.routes.draw do - mount Flipflop::Engine => "/flipflop" root "basic_search#index" get 'analyze', to: 'tacos#analyze' diff --git a/db/migrate/20251023203259_drop_flipflip_features.rb b/db/migrate/20251023203259_drop_flipflip_features.rb new file mode 100644 index 00000000..6a3b4ade --- /dev/null +++ b/db/migrate/20251023203259_drop_flipflip_features.rb @@ -0,0 +1,10 @@ +class DropFlipflipFeatures < ActiveRecord::Migration[7.2] + def change + drop_table :flipflop_features do |t| + t.string :key, null: false + t.boolean :enabled, null: false, default: false + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 0064da22..18a4a3ba 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,12 +10,5 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_02_28_201656) do - create_table "flipflop_features", force: :cascade do |t| - t.string "key", null: false - t.boolean "enabled", default: false, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - +ActiveRecord::Schema[7.2].define(version: 2025_10_23_203259) do end From 778e80ab30075777fbbed6c75022a0802e267d66 Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Thu, 23 Oct 2025 16:29:52 -0400 Subject: [PATCH 2/6] Replace FlipFlip with Feature flag system https://mitlibraries.atlassian.net/browse/USE-77 --- README.md | 2 +- app/controllers/search_controller.rb | 6 +++--- app/helpers/search_helper.rb | 2 +- app/models/enhancer.rb | 4 ++-- app/models/query_builder.rb | 4 ++-- app/views/basic_search/index.html.erb | 2 +- app/views/layouts/_site_header.html.erb | 6 +++--- app/views/record/_sidebar.html.erb | 6 +++--- app/views/record/view.html.erb | 2 +- app/views/search/_filter.html.erb | 2 +- app/views/search/_form.html.erb | 2 +- app/views/search/_form_geo.html.erb | 2 +- app/views/search/_search_summary_geo.html.erb | 2 +- app/views/shared/_ask.html.erb | 2 +- app/views/shared/_site_title.html.erb | 2 +- app/views/tacos/analyze.html.erb | 2 +- 16 files changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index b225d095..289f1b8b 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ See `Optional Environment Variables` for more information. - `BOOLEAN_OPTIONS`: comma separated list of values to present to testers on instances where `BOOLEAN_PICKER` feature is enabled. - `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_GDT`: Enables features related to geospatial data discovery. Setting this variable to `true` will trigger geodata +- `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. diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 6de03e29..3604cf25 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,7 +1,7 @@ class SearchController < ApplicationController before_action :validate_q!, only: %i[results] - if Flipflop.enabled?(:gdt) + if Feature.enabled?(:geodata) before_action :validate_geobox_presence!, only: %i[results] before_action :validate_geobox_range!, only: %i[results] before_action :validate_geobox_values!, only: %i[results] @@ -16,7 +16,7 @@ def results 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 +24,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' 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) %>