Skip to content

Commit

Permalink
Add feature flipper to the admin menu
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Aug 30, 2016
1 parent d7dd049 commit da414ac
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/controllers/sufia/admin/features_controller.rb
@@ -1,8 +1,12 @@
module Sufia
module Admin
class FeaturesController < Flip::FeaturesController
layout 'admin'
before_action do
authorize! :manage, Sufia::Feature
add_breadcrumb 'Home', root_path
add_breadcrumb 'Repository Dashboard', sufia.admin_path
add_breadcrumb 'Settings', sufia.admin_features_path
end
end
end
Expand Down
51 changes: 51 additions & 0 deletions app/views/flip/features/index.html.erb
@@ -0,0 +1,51 @@
<% content_for :page_header do %>
<h1><span class="fa fa-cog"></span> Settings</h1>
<% end %>
<div class="flip row">
<div class="col-md-12">
<div class="panel">
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped datatable">
<thead>
<th>Feature Name</th>
<th>Description</th>
<th>Status</th>
<th>Action</th>
</thead>
<tbody>
<% @p.definitions.each do |definition| %>
<tr>
<td class="name"><%= definition.name %></td>

<td class="description"><%= definition.description %></td>

<%= 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 %>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
15 changes: 10 additions & 5 deletions app/views/layouts/admin.html.erb
Expand Up @@ -32,6 +32,10 @@
<span class="fa fa-bar-chart"></span> Statistics
<% end %>
</li>
<li><%= link_to sufia.admin_features_path do %>
<span class="fa fa-cog"></span> Settings
<% end %>
</li>
</ul>
</div>
<!-- END PAGE SIDEBAR -->
Expand Down Expand Up @@ -63,13 +67,14 @@
</ul>
<!-- START BREADCRUMB -->
<%= render_breadcrumbs builder: Sufia::BootstrapBreadcrumbsBuilder %>
<%# <ul class="breadcrumb"> %>
<%# <li><a href="sdr-home">Repository Home</a></li> %>
<%# <li><a href="#">Administration</a></li> %>
<%# <li class="active">Repository Dashboard</li> %>
<%# </ul> %>
<!-- END BREADCRUMB -->

<% if content_for?(:page_header) %>
<div class="page-title">
<%= yield(:page_header) %>
</div>
<% end %>

<!-- PAGE CONTENT WRAPPER -->
<div class="page-content-wrap">
<%= yield %>
Expand Down

0 comments on commit da414ac

Please sign in to comment.