Skip to content

Commit 778e80a

Browse files
committed
Replace FlipFlip with Feature flag system
https://mitlibraries.atlassian.net/browse/USE-77
1 parent 98fc2fc commit 778e80a

File tree

16 files changed

+24
-24
lines changed

16 files changed

+24
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ See `Optional Environment Variables` for more information.
9393
- `BOOLEAN_OPTIONS`: comma separated list of values to present to testers on instances where `BOOLEAN_PICKER` feature is enabled.
9494
- `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_GDT`: Enables features related to geospatial data discovery. Setting this variable to `true` will trigger geodata
96+
- `FEATURE_GEODATA`: Enables features related to geospatial data discovery. Setting this variable to `true` will trigger geodata
9797
mode. Note that this is currently intended _only_ for the geodata app and
9898
may have unexpected consequences if applied to other TIMDEX UI apps.
9999
- `FILTER_ACCESS_TO_FILES`: The name to use instead of "Access to files" for that filter / aggregation.

app/controllers/search_controller.rb

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

4-
if Flipflop.enabled?(:gdt)
4+
if Feature.enabled?(:geodata)
55
before_action :validate_geobox_presence!, only: %i[results]
66
before_action :validate_geobox_range!, only: %i[results]
77
before_action :validate_geobox_values!, only: %i[results]
@@ -16,15 +16,15 @@ def results
1616
params[:booleanType] = cookies[:boolean_type] || 'AND'
1717

1818
# Determine which tab to load - default to primo unless gdt is enabled
19-
@active_tab = if Flipflop.enabled?(:gdt)
19+
@active_tab = if Feature.enabled?(:geodata)
2020
'gdt' # Keep existing GDT behavior unchanged
2121
else
2222
params[:tab] || 'primo' # Default to primo for new tabbed interface
2323
end
2424
@enhanced_query = Enhancer.new(params).enhanced_query
2525

2626
# Route to appropriate search based on active tab
27-
if Flipflop.enabled?(:gdt)
27+
if Feature.enabled?(:geodata)
2828
# Keep existing GDT behavior unchanged
2929
load_gdt_results
3030
render 'results_geo'

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>

app/views/record/_sidebar.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<% if Flipflop.enabled?(:gdt) %>
1+
<% if Feature.enabled?(:geodata) %>
22
<div role="region" aria-label="Access and help links" class="col1q-r sidebar access-sidebar">
33
<% else %>
44
<aside class="col1q-r sidebar">
55
<% end %>
6-
<% if Flipflop.enabled?(:gdt) && access_type(@record) && gis_access_link(@record) %>
6+
<% if Feature.enabled?(:geodata) && access_type(@record) && gis_access_link(@record) %>
77
<h2 class="hd-3">Access links</h2>
88
<%= render partial: 'access_buttons' %>
99
<% end %>
1010

1111
<%= render partial: 'shared/ask', locals: { display: '' } %>
12-
<% if Flipflop.enabled?(:gdt) %>
12+
<% if Feature.enabled?(:geodata) %>
1313
</div>
1414
<% else %>
1515
</aside>

app/views/record/view.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<% if @record.nil? %>
1414
<%= render('record_empty') %>
15-
<% elsif Flipflop.enabled?(:gdt) %>
15+
<% elsif Feature.enabled?(:geodata) %>
1616
<%= render('record_geo') %>
1717
<% else %>
1818
<%= render('record') %>

app/views/search/_filter.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<a href="<%= results_path(add_filter(@enhanced_query, category, term['key'])) %>">
1616
<span class="sr">Apply filter:</span>
1717
<% end %>
18-
<% if Flipflop.enabled?(:gdt) %>
18+
<% if Feature.enabled?(:geodata) %>
1919
<span class="name"><%= gdt_sources(term['key'], category) %></span>
2020
<% else %>
2121
<span class="name"><%= term['key'] %></span>

0 commit comments

Comments
 (0)