diff --git a/app/assets/stylesheets/sufia/_form.scss b/app/assets/stylesheets/sufia/_form.scss
index 753087a75c..2ecadce3f9 100644
--- a/app/assets/stylesheets/sufia/_form.scss
+++ b/app/assets/stylesheets/sufia/_form.scss
@@ -1,3 +1,25 @@
.form-tab-content {
margin: 15px 10px;
}
+
+/* For the admin page */
+td.status {
+ width: 2rem;
+ font-size: 1.1rem;
+
+ span {
+ @extend .label;
+ @extend .badge;
+ &.on { @extend .label-success; }
+ &.off { @extend .label-default; }
+ }
+}
+
+td.toggle {
+ input[type=submit] {
+ @extend .btn;
+ @extend .btn-sm;
+ &.active { @extend .btn-primary; }
+ &:not(.active) { @extend .btn-default; }
+ }
+}
diff --git a/app/assets/stylesheets/sufia/admin.scss b/app/assets/stylesheets/sufia/admin.scss
index d126da97c1..177d9b7eb0 100644
--- a/app/assets/stylesheets/sufia/admin.scss
+++ b/app/assets/stylesheets/sufia/admin.scss
@@ -17,6 +17,7 @@ $header-height: 35px !default;
$title-text-color: #4e4a42 !default;
$content-background-color: #f5f5f5 !default;
+
.page-title {
float: left;
padding: 5px 10px;
diff --git a/app/controllers/sufia/admin/features_controller.rb b/app/controllers/sufia/admin/features_controller.rb
index ea62149d9e..79865c735b 100644
--- a/app/controllers/sufia/admin/features_controller.rb
+++ b/app/controllers/sufia/admin/features_controller.rb
@@ -1,6 +1,6 @@
module Sufia
module Admin
- class FeaturesController < Flip::FeaturesController
+ class FeaturesController < Flipflop::FeaturesController
layout 'admin'
before_action do
authorize! :manage, Sufia::Feature
diff --git a/app/controllers/sufia/admin/strategies_controller.rb b/app/controllers/sufia/admin/strategies_controller.rb
index 4127ca364b..c402253ae4 100644
--- a/app/controllers/sufia/admin/strategies_controller.rb
+++ b/app/controllers/sufia/admin/strategies_controller.rb
@@ -1,8 +1,8 @@
module Sufia
module Admin
- class StrategiesController < Flip::StrategiesController
+ class StrategiesController < Flipflop::StrategiesController
before_action do
- authorize! :manage, Feature
+ authorize! :manage, Sufia::Feature
end
# TODO: we could remove this if we used an isolated engine
diff --git a/app/models/sufia/feature.rb b/app/models/sufia/feature.rb
index 230385c8b0..dc5d8bda17 100644
--- a/app/models/sufia/feature.rb
+++ b/app/models/sufia/feature.rb
@@ -1,15 +1,5 @@
module Sufia
class Feature < ActiveRecord::Base
self.table_name = 'sufia_features'
- extend Flip::Declarable
-
- strategy Flip::CookieStrategy
- strategy Flip::DatabaseStrategy
- strategy Flip::DeclarationStrategy
- default false
-
- feature :assign_admin_set,
- default: true,
- description: "Ability to assign uploaded items to an admin set"
end
end
diff --git a/app/views/curation_concerns/base/_form_relationships.html.erb b/app/views/curation_concerns/base/_form_relationships.html.erb
index 1665967ee5..2e6fcc4f79 100644
--- a/app/views/curation_concerns/base/_form_relationships.html.erb
+++ b/app/views/curation_concerns/base/_form_relationships.html.erb
@@ -1,4 +1,4 @@
-<% if Flip.assign_admin_set? %>
+<% if Flipflop.assign_admin_set? %>
<%= f.input :admin_set_id, as: :select,
collection: CurationConcerns::AdminSetService.new(controller).select_options,
include_blank: true,
diff --git a/app/views/flip/features/index.html.erb b/app/views/flip/features/index.html.erb
deleted file mode 100644
index 2996277c40..0000000000
--- a/app/views/flip/features/index.html.erb
+++ /dev/null
@@ -1,51 +0,0 @@
-<% content_for :page_header do %>
-
Settings
-<% end %>
-
-
-
-
-
-
-
- Feature Name |
- Description |
- Status |
- Action |
-
-
- <% @p.definitions.each do |definition| %>
-
- <%= definition.name %> |
-
- <%= definition.description %> |
-
- <%= content_tag :td, class: @p.status(definition) do %>
- <%= @p.status definition %>
- <% end %>
-
- <% @p.strategies.each do |strategy| %>
- <% next unless strategy.name == 'database' %>
- <%= content_tag :td, class: @p.strategy_status(strategy, definition) || "pass" do %>
- <% if strategy.switchable? %>
- <% # set the status to the current or default status %>
- <%= form_tag(sufia.admin_feature_strategy_path(definition, strategy.name.underscore), method: :put) do %>
- <% unless @p.status(definition) == "on" %>
- <%= submit_tag "Switch On", class: 'btn btn-default' %>
- <% else %>
- <%= submit_tag "Switch Off", class: 'btn btn-default' %>
- <% end %>
- <% end %>
- <% end %>
-
- <% end %>
- <% end %>
-
- <% end %>
-
-
-
-
-
-
-
diff --git a/app/views/sufia/admin/features/index.html.erb b/app/views/sufia/admin/features/index.html.erb
new file mode 100644
index 0000000000..6adaa291c1
--- /dev/null
+++ b/app/views/sufia/admin/features/index.html.erb
@@ -0,0 +1,57 @@
+<% content_for :page_header do %>
+ Settings
+<% end %>
+
+
+
+
+
+
+
+
+ |
+ Feature |
+ Description |
+ Action |
+
+
+
+ <% @feature_set.features.each do |feature| -%>
+
+
+ <%= @feature_set.status(feature) -%>
+ |
+ <%= feature.name.humanize -%> |
+ <%= feature.description -%> |
+
+ <% @feature_set.strategies.each do |strategy| -%>
+ <% next unless strategy.is_a? Flipflop::Strategies::ActiveRecordStrategy %>
+
+
+ |
+ <% end -%>
+
+ <% end -%>
+
+
+
+
+
+
+
diff --git a/config/features.rb b/config/features.rb
new file mode 100644
index 0000000000..37eb9b6a50
--- /dev/null
+++ b/config/features.rb
@@ -0,0 +1,10 @@
+Flipflop.configure do
+ # Strategies will be used in the order listed here.
+ strategy :cookie
+ strategy :active_record, class: Sufia::Feature
+ strategy :default
+
+ feature :assign_admin_set,
+ default: true,
+ description: "Ability to assign uploaded items to an admin set"
+end
diff --git a/config/initializers/flip.rb b/config/initializers/flip.rb
deleted file mode 100644
index 2cb12bf9b7..0000000000
--- a/config/initializers/flip.rb
+++ /dev/null
@@ -1 +0,0 @@
-require 'sufia/feature'
diff --git a/lib/sufia/engine.rb b/lib/sufia/engine.rb
index 7c30787f8d..f3c04ad74a 100644
--- a/lib/sufia/engine.rb
+++ b/lib/sufia/engine.rb
@@ -7,8 +7,8 @@ class Engine < ::Rails::Engine
require 'jquery-ui-rails'
require 'flot-rails'
require 'almond-rails'
- require 'flip'
require 'jquery-datatables-rails'
+ require 'flipflop'
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
@@ -34,6 +34,9 @@ class Engine < ::Rails::Engine
end
initializer 'configure' do
+ # Set the path for the flipflop config:
+ Flipflop::Engine.config_file = Sufia::Engine.root + "config/features.rb"
+
Sufia.config.tap do |c|
Hydra::Derivatives.ffmpeg_path = c.ffmpeg_path
Hydra::Derivatives.temp_file_base = c.temp_file_base
diff --git a/spec/models/flip_spec.rb b/spec/models/flipflop_spec.rb
similarity index 84%
rename from spec/models/flip_spec.rb
rename to spec/models/flipflop_spec.rb
index 531993d8c0..7ae95e7933 100644
--- a/spec/models/flip_spec.rb
+++ b/spec/models/flipflop_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-RSpec.describe Flip do
+RSpec.describe Flipflop do
describe "assign_admin_set?" do
subject { described_class.assign_admin_set? }
it { is_expected.to be true }
diff --git a/spec/test_app_templates/Gemfile.extra b/spec/test_app_templates/Gemfile.extra
index 0c78e76d5c..8d3f773867 100644
--- a/spec/test_app_templates/Gemfile.extra
+++ b/spec/test_app_templates/Gemfile.extra
@@ -1,6 +1,6 @@
# Use this file to reference specific commits of gems.
gem 'acts_as_follower', git: 'https://github.com/awjecc/acts_as_follower.git', branch: 'rails5-fix-parent_class_name'
-gem 'flip', git: 'https://github.com/jcoyne/flip.git', branch: 'alternate_classes'
+gem 'flipflop', git: 'https://github.com/jcoyne/flipflop.git', branch: 'hydra'
group :development do
gem 'better_errors'
diff --git a/spec/views/curation_concerns/base/_form_relationships.html.erb_spec.rb b/spec/views/curation_concerns/base/_form_relationships.html.erb_spec.rb
index 97017e7200..e80813a91e 100644
--- a/spec/views/curation_concerns/base/_form_relationships.html.erb_spec.rb
+++ b/spec/views/curation_concerns/base/_form_relationships.html.erb_spec.rb
@@ -28,7 +28,7 @@
context 'with assign_admin_set turned on' do
before do
- allow(Flip).to receive(:assign_admin_set?).and_return(true)
+ allow(Flipflop).to receive(:assign_admin_set?).and_return(true)
end
it "draws the page" do
@@ -39,7 +39,7 @@
context 'with assign_admin_set disabled' do
before do
- allow(Flip).to receive(:assign_admin_set?).and_return(false)
+ allow(Flipflop).to receive(:assign_admin_set?).and_return(false)
end
it 'draws the page, but not the admin set widget' do
expect(page).not_to have_content('administrative set')
diff --git a/sufia.gemspec b/sufia.gemspec
index 034c40f47c..1ad562e00c 100644
--- a/sufia.gemspec
+++ b/sufia.gemspec
@@ -46,7 +46,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'flot-rails', '~> 0.0.6'
spec.add_dependency 'almond-rails', '~> 0.0.1'
spec.add_dependency 'qa', '~> 0.8' # questioning_authority
- spec.add_dependency 'flip', '~> 1.1'
+ spec.add_dependency 'flipflop', '~> 2.2'
spec.add_dependency 'jquery-datatables-rails', '~> 3.3.0'
spec.add_development_dependency 'engine_cart', '~> 1.0'