Skip to content

Commit da85230

Browse files
authored
Merge pull request #111 from MITLibraries/gdt-157-feature-flag
Add GDT feature flag
2 parents 2d835a1 + a128c20 commit da85230

File tree

11 files changed

+64
-4
lines changed

11 files changed

+64
-4
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/db/*.sqlite3
2-
/db/*.sqlite3-journal
3-
/db/*.sqlite3-[0-9]*
1+
/db/*.sqlite3*
42
/coverage/
53

64
# Ignore all logfiles and tempfiles.

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ group :test do
4848
gem 'vcr'
4949
gem 'webmock'
5050
end
51+
52+
gem 'flipflop', '~> 2.7'

Gemfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ GEM
135135
ffi-compiler (1.0.1)
136136
ffi (>= 1.0.0)
137137
rake
138+
flipflop (2.7.1)
139+
activesupport (>= 4.0)
140+
terminal-table (>= 1.8)
138141
globalid (1.2.1)
139142
activesupport (>= 6.1)
140143
graphql (2.0.27)
@@ -315,6 +318,8 @@ GEM
315318
stimulus-rails (1.3.3)
316319
railties (>= 6.0.0)
317320
stringio (3.1.0)
321+
terminal-table (3.0.2)
322+
unicode-display_width (>= 1.1.1, < 3)
318323
thor (1.3.0)
319324
tilt (2.3.0)
320325
timeout (0.4.1)
@@ -361,6 +366,7 @@ DEPENDENCIES
361366
climate_control
362367
debug
363368
dotenv-rails
369+
flipflop (~> 2.7)
364370
graphql (~> 2.0.27)
365371
graphql-client
366372
http

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ change as part of the work.
5151

5252
- `ABOUT_APP`: If populated, an 'about' partial containing the contents of this variable will render on
5353
`basic_search#index`.
54+
- `GDT`: Enables features related to geospatial data discovery. Setting this variable with any value will trigger GDT
55+
mode (e.g., `GDT=false` will still enable GDT features). Note that this is currently intended _only_ for the GDT app and
56+
may have unexpected consequences if applied to other TIMDEX UI apps.
5457
- `GLOBAL_ALERT`: The main functionality for this comes from our theme gem, but when set the value will be rendered as
5558
safe html above the main header of the site.
5659
- `SENTRY_DSN`: Client key for Sentry exception logging.

config/application.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99

1010
module TimdexUi
1111
class Application < Rails::Application
12+
# Before filter for Flipflop dashboard. Replace with a lambda or method name
13+
# defined in ApplicationController to implement access control.
14+
config.flipflop.dashboard_access_filter = -> { head :forbidden }
15+
16+
# By default, when set to `nil`, strategy loading errors are suppressed in test
17+
# mode. Set to `true` to always raise errors, or `false` to always warn.
18+
config.flipflop.raise_strategy_errors = nil
19+
1220
# Initialize configuration defaults for originally generated Rails version.
1321
config.load_defaults 7.0
1422

config/environments/development.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
require "active_support/core_ext/integer/time"
22

33
Rails.application.configure do
4+
# Before filter for Flipflop dashboard. Replace with a lambda or method name
5+
# defined in ApplicationController to implement access control.
6+
config.flipflop.dashboard_access_filter = nil
7+
8+
# By default, when set to `nil`, strategy loading errors are suppressed in test
9+
# mode. Set to `true` to always raise errors, or `false` to always warn.
10+
config.flipflop.raise_strategy_errors = nil
11+
412
# Settings specified here will take precedence over those in config/application.rb.
513

614
# In the development environment your application's code is reloaded any time

config/environments/test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
# and recreated between test runs. Don't rely on the data there!
77

88
Rails.application.configure do
9+
# Before filter for Flipflop dashboard. Replace with a lambda or method name
10+
# defined in ApplicationController to implement access control.
11+
config.flipflop.dashboard_access_filter = nil
12+
13+
# By default, when set to `nil`, strategy loading errors are suppressed in test
14+
# mode. Set to `true` to always raise errors, or `false` to always warn.
15+
config.flipflop.raise_strategy_errors = nil
16+
917
# Settings specified here will take precedence over those in config/application.rb.
1018

1119
# Turn false under Spring and add config.action_view.cache_template_loading = true.

config/features.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Flipflop.configure do
2+
# Strategies will be used in the order listed here.
3+
strategy :session
4+
strategy :default
5+
6+
feature :gdt,
7+
default: ENV.fetch('GDT', false),
8+
description: "Enable geodata discovery features."
9+
end

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Rails.application.routes.draw do
2+
mount Flipflop::Engine => "/flipflop"
23
root "basic_search#index"
34

45
get 'doi', to: 'fact#doi'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class CreateFeatures < ActiveRecord::Migration[7.1]
2+
def change
3+
create_table :flipflop_features do |t|
4+
t.string :key, null: false
5+
t.boolean :enabled, null: false, default: false
6+
7+
t.timestamps null: false
8+
end
9+
end
10+
end

0 commit comments

Comments
 (0)