Skip to content

Commit 22f5b1c

Browse files
authored
Merge pull request #254 from MITLibraries/use-77-remove-flipflip
Replace FlipFlip usage with Feature class
2 parents 5478181 + a15478d commit 22f5b1c

33 files changed

+824
-817
lines changed

.env.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ALMA_OPENURL=https://na06.alma.exlibrisgroup.com/view/uresolver/01MIT_INST/openurl?
2-
GDT=false
2+
FEATURE_GEODATA=false
33
MIT_PRIMO_URL=https://mit.primo.exlibrisgroup.com
44
PRIMO_API_KEY=FAKE_PRIMO_API_KEY
55
PRIMO_API_URL=https://api-na.hosted.exlibrisgroup.com/primo/v1
@@ -12,4 +12,4 @@ TACOS_URL=http://FAKE_TACOS_HOST/graphql
1212
TACOS_SOURCE=FAKE_TACOS_SOURCE
1313
TIMDEX_GRAPHQL=https://FAKE_TIMDEX_HOST/graphql
1414
TIMDEX_HOST=FAKE_TIMDEX_HOST
15-
TIMDEX_INDEX=FAKE_TIMDEX_INDEX
15+
TIMDEX_INDEX=FAKE_TIMDEX_INDEX

Gemfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,3 @@ group :test do
5252
gem 'vcr'
5353
gem 'webmock'
5454
end
55-
56-
gem 'flipflop', '~> 2.7'

Gemfile.lock

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ GEM
139139
ffi (>= 1.15.5)
140140
rake
141141
fiber-storage (1.0.1)
142-
flipflop (2.8.0)
143-
activesupport (>= 4.0)
144-
terminal-table (>= 1.8)
145142
globalid (1.3.0)
146143
activesupport (>= 6.1)
147144
graphql (2.5.14)
@@ -359,8 +356,6 @@ GEM
359356
stimulus-rails (1.3.4)
360357
railties (>= 6.0.0)
361358
stringio (3.1.7)
362-
terminal-table (4.0.0)
363-
unicode-display_width (>= 1.1.1, < 4)
364359
thor (1.4.0)
365360
tilt (2.6.0)
366361
timeout (0.4.3)
@@ -415,7 +410,6 @@ DEPENDENCIES
415410
climate_control
416411
debug
417412
dotenv-rails
418-
flipflop (~> 2.7)
419413
graphql
420414
graphql-client
421415
http

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ requires testing against an index that contains geospatial records.)
6363
3. Confirm that filters from multiple categories can be applied and removed, both on the sidebar
6464
and the panel beneath the search form.
6565

66-
If the `flipflop` gem has been updated, check that the `:gdt` feature is working by ensuring that
66+
Check that the `:geodata` feature is working by ensuring that
6767
UI elements specific to GDT (e.g., geospatial search fields or the 'Ask GIS' link) appear with the
6868
feature flag enabled, and do not when it is disabled.
6969

@@ -91,8 +91,11 @@ See `Optional Environment Variables` for more information.
9191
`basic_search#index`.
9292
- `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.
9393
- `BOOLEAN_OPTIONS`: comma separated list of values to present to testers on instances where `BOOLEAN_PICKER` feature is enabled.
94-
- `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
94+
- `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
9595
testing and should never be enabled in production (mostly because the UI is a mess more than it would cause harm).
96+
- `FEATURE_GEODATA`: Enables features related to geospatial data discovery. Setting this variable to `true` will trigger geodata
97+
mode. Note that this is currently intended _only_ for the geodata app and
98+
may have unexpected consequences if applied to other TIMDEX UI apps.
9699
- `FILTER_ACCESS_TO_FILES`: The name to use instead of "Access to files" for that filter / aggregation.
97100
- `FILTER_CONTENT_TYPE`: The name to use instead of "Content type" for that filter / aggregation.
98101
- `FILTER_CONTRIBUTOR`: The name to use instead of "Contributor" for that filter / aggregation.
@@ -102,9 +105,6 @@ See `Optional Environment Variables` for more information.
102105
- `FILTER_PLACE`: The name to use instead of "Place" for that filter / aggregation.
103106
- `FILTER_SOURCE`: The name to use instead of "Source" for that filter / aggregation.
104107
- `FILTER_SUBJECT`: The name to use instead of "Subject" for that filter / aggregation.
105-
- `GDT`: Enables features related to geospatial data discovery. Setting this variable with any value will trigger GDT
106-
mode (e.g., `GDT=false` will still enable GDT features). Note that this is currently intended _only_ for the GDT app and
107-
may have unexpected consequences if applied to other TIMDEX UI apps.
108108
- `GLOBAL_ALERT`: The main functionality for this comes from our theme gem, but when set the value will be rendered as
109109
safe html above the main header of the site.
110110
- `ORIGINS`: sets origins for CORS (currently used only for TACOS API calls).

app/controllers/search_controller.rb

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
class SearchController < ApplicationController
22
before_action :validate_q!, only: %i[results]
33

4-
if Flipflop.enabled?(:gdt)
5-
before_action :validate_geobox_presence!, only: %i[results]
6-
before_action :validate_geobox_range!, only: %i[results]
7-
before_action :validate_geobox_values!, only: %i[results]
8-
before_action :validate_geodistance_presence!, only: %i[results]
9-
before_action :validate_geodistance_range!, only: %i[results]
10-
before_action :validate_geodistance_value!, only: %i[results]
11-
before_action :validate_geodistance_units!, only: %i[results]
12-
end
4+
before_action :validate_geobox_presence!, only: %i[results]
5+
before_action :validate_geobox_range!, only: %i[results]
6+
before_action :validate_geobox_values!, only: %i[results]
7+
before_action :validate_geodistance_presence!, only: %i[results]
8+
before_action :validate_geodistance_range!, only: %i[results]
9+
before_action :validate_geodistance_value!, only: %i[results]
10+
before_action :validate_geodistance_units!, only: %i[results]
1311

1412
def results
1513
# inject session preference for boolean type if it is present
1614
params[:booleanType] = cookies[:boolean_type] || 'AND'
1715

1816
# Determine which tab to load - default to primo unless gdt is enabled
19-
@active_tab = if Flipflop.enabled?(:gdt)
17+
@active_tab = if Feature.enabled?(:geodata)
2018
'gdt' # Keep existing GDT behavior unchanged
2119
else
2220
params[:tab] || 'primo' # Default to primo for new tabbed interface
2321
end
2422
@enhanced_query = Enhancer.new(params).enhanced_query
2523

2624
# Route to appropriate search based on active tab
27-
if Flipflop.enabled?(:gdt)
25+
if Feature.enabled?(:geodata)
2826
# Keep existing GDT behavior unchanged
2927
load_gdt_results
3028
render 'results_geo'
@@ -185,6 +183,8 @@ def validate_q!
185183
end
186184

187185
def validate_geodistance_presence!
186+
return unless Feature.enabled?(:geodata)
187+
188188
return unless params[:geodistance]&.strip == 'true'
189189

190190
geodistance_params = [params[:geodistanceLatitude]&.strip, params[:geodistanceLongitude]&.strip,
@@ -196,6 +196,8 @@ def validate_geodistance_presence!
196196
end
197197

198198
def validate_geobox_presence!
199+
return unless Feature.enabled?(:geodata)
200+
199201
return unless params[:geobox]&.strip == 'true'
200202

201203
geobox_params = [params[:geoboxMinLatitude]&.strip, params[:geoboxMinLongitude]&.strip,
@@ -207,6 +209,8 @@ def validate_geobox_presence!
207209
end
208210

209211
def validate_geodistance_range!
212+
return unless Feature.enabled?(:geodata)
213+
210214
return unless params[:geodistance]&.strip == 'true'
211215

212216
invalid_range = false
@@ -222,6 +226,8 @@ def validate_geodistance_range!
222226
end
223227

224228
def validate_geobox_range!
229+
return unless Feature.enabled?(:geodata)
230+
225231
return unless params[:geobox]&.strip == 'true'
226232

227233
invalid_range = false
@@ -237,6 +243,8 @@ def validate_geobox_range!
237243
end
238244

239245
def validate_geodistance_value!
246+
return unless Feature.enabled?(:geodata)
247+
240248
return unless params[:geodistance]&.strip == 'true'
241249

242250
distance = params[:geodistanceDistance]&.strip.to_i
@@ -247,6 +255,8 @@ def validate_geodistance_value!
247255
end
248256

249257
def validate_geodistance_units!
258+
return unless Feature.enabled?(:geodata)
259+
250260
return unless params[:geodistance]&.strip == 'true'
251261

252262
distance = params[:geodistanceDistance]&.strip
@@ -265,6 +275,8 @@ def validate_geodistance_units!
265275
end
266276

267277
def validate_geobox_values!
278+
return unless Feature.enabled?(:geodata)
279+
268280
return unless params[:geobox]&.strip == 'true'
269281

270282
geobox_lat = [params[:geoboxMinLatitude]&.strip.to_f, params[:geoboxMaxLatitude]&.strip.to_f]

app/helpers/search_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def applied_advanced_terms(query)
7777
# Query params need some treatment to look decent in the search summary panel.
7878
def readable_param(param)
7979
return 'Keyword anywhere' if param == 'q'
80-
return 'Authors' if param == 'contributors' && Flipflop.enabled?(:gdt)
80+
return 'Authors' if param == 'contributors' && Feature.enabled?(:geodata)
8181

8282
if param.starts_with?('geodistance')
8383
param = param.gsub('geodistance', '')

app/models/enhancer.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def initialize(params)
1414
@enhanced_query[:advanced] = 'true' if params[:advanced].present?
1515
@enhanced_query[:booleanType] = params[:booleanType] || 'AND'
1616

17-
if Flipflop.enabled?(:gdt)
17+
if Feature.enabled?(:geodata)
1818
@enhanced_query[:geobox] = 'true' if params[:geobox] == 'true'
1919
@enhanced_query[:geodistance] = 'true' if params[:geodistance] == 'true'
2020
end
@@ -38,7 +38,7 @@ def extract_query(params)
3838
end
3939

4040
def extract_geosearch(params)
41-
return unless Flipflop.enabled?(:gdt)
41+
return unless Feature.enabled?(:geodata)
4242

4343
GEO_PARAMS.each do |gp|
4444
@enhanced_query[gp] = params[gp] if params[gp].present?

app/models/query_builder.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def initialize(enhanced_query)
1212
@query = {}
1313
@query['from'] = calculate_from(enhanced_query[:page])
1414

15-
if Flipflop.enabled?(:gdt)
15+
if Feature.enabled?(:geodata)
1616
@query['geobox'] = 'true' if enhanced_query[:geobox] == 'true'
1717
@query['geodistance'] = 'true' if enhanced_query[:geodistance] == 'true'
1818
end
@@ -40,7 +40,7 @@ def extract_query(enhanced_query)
4040
end
4141

4242
def extract_geosearch(enhanced_query)
43-
return unless Flipflop.enabled?(:gdt)
43+
return unless Feature.enabled?(:geodata)
4444

4545
GEO_PARAMS.each do |gp|
4646
if coerce_to_float?(gp)

app/views/basic_search/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
<main class="space-wrap">
44
<%= render partial: "shared/site_title" %>
5-
<%= render partial: "search/form_geo" if Flipflop.enabled?(:gdt) %>
5+
<%= render partial: "search/form_geo" if Feature.enabled?(:geodata) %>
66
<%= render partial: "static/about" if ENV.fetch('ABOUT_APP', nil) %>
77
</main>

app/views/layouts/_site_header.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
</h1>
2121
<nav class="main-navigation" aria-label="Main navigation">
2222
<%= nav_link_to("Home", root_path) %>
23-
<% if Flipflop.enabled?(:gdt) %>
23+
<% if Feature.enabled?(:geodata) %>
2424
<%= nav_link_to("GIS at MIT", "https://libraries.mit.edu/gis") %>
2525
<%= nav_link_to("Ask GIS", "https://libraries.mit.edu/ask-gis") %>
2626
<% end %>
2727
</nav>
2828
</header>
29-
<%= render partial: 'search/form' unless Flipflop.enabled?(:gdt) %>
29+
<%= render partial: 'search/form' unless Feature.enabled?(:geodata) %>
3030
</div>
31-
</div>
31+
</div>

0 commit comments

Comments
 (0)