Skip to content

Commit

Permalink
Add feature flag for adhoc
Browse files Browse the repository at this point in the history
  • Loading branch information
cguess committed Mar 29, 2024
1 parent f533c1d commit 155c362
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,7 @@ gem "mechanize"
# Better logging printing
gem "amazing_print"
# gem "rails_semantic_logger"

gem "flipper", "~> 1.2"

gem "flipper-active_record", "~> 1.2"
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ GEM
ffi (1.16.3)
figaro (1.2.0)
thor (>= 0.14.0, < 2)
flipper (1.2.2)
concurrent-ruby (< 2)
flipper-active_record (1.2.2)
activerecord (>= 4.2, < 8)
flipper (~> 1.2.2)
globalid (1.1.0)
activesupport (>= 5.0)
hana (1.3.7)
Expand Down Expand Up @@ -678,6 +683,8 @@ DEPENDENCIES
eikon
ferrum (~> 0.11)
figaro
flipper (~> 1.2)
flipper-active_record (~> 1.2)
forki!
hiredis
honeybadger (~> 5.2)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/media_vault/archive_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def index
end

# Here we need to see if we're on a personal archive page, and limit if so to the one's this person owns.
if params[:myvault].present?
if params[:myvault].present? && Flipper.enabled?(:adhoc, current_user)
archive_items = current_user.archive_items
@myvault = true
else
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/media_vault/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<ol id="site-nav__primary" class="site-nav__links">
<% if current_user.can_access_media_vault? %>
<li><%= link_to media_vault_dashboard_path, class: "btn btn--naked" do %><span>Dashboard</span><% end %></li>
<li><%= link_to media_vault_myvault_path, class: "btn btn--naked" do %><span>MyVault</span><% end %></li>
<% if Flipper.enabled?(:adhoc, current_user) %><li><%= link_to media_vault_myvault_path, class: "btn btn--naked" do %><span>MyVault</span><% end %></li><% end %>
<li><%= link_to media_vault_guide_path, class: "btn btn--naked" do %><span>Guide<span class="hideable"> to MediaVault</span></span><% end %></li>
<li class="site-nav__search">
<%= render partial: "media_vault/search/search_box", locals: { myvault: @myvault } %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/media_vault/archive/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
<div>
<h2><%= @myvault ? "MyVault:" : "Recently-archived media:" %></h2>
</div>
<% if Flipper.enabled?(:adhoc, current_user) %>
<div>
<%= link_to media_vault_archive_add_path, class: "btn btn--naked icon-prefixed", data: { turbo_stream: 'modal' } do %>
<%= use_svg "plus", svg_attrs: { class: "icon icon--lg", aria: { hidden: true } } %>
<span>Save A Post</span>
<% end %>
</div>
<% end %>
</div>

<% show = !@organization.nil? || !@from_date.nil? || !@to_date.nil? %>
Expand Down
22 changes: 22 additions & 0 deletions db/migrate/20240329133544_create_flipper_tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class CreateFlipperTables < ActiveRecord::Migration[7.0]
def up
create_table :flipper_features do |t|
t.string :key, null: false
t.timestamps null: false
end
add_index :flipper_features, :key, unique: true

create_table :flipper_gates do |t|
t.string :feature_key, null: false
t.string :key, null: false
t.text :value
t.timestamps null: false
end
add_index :flipper_gates, [:feature_key, :key, :value], unique: true, length: { value: 255 }
end

def down
drop_table :flipper_gates
drop_table :flipper_features
end
end
18 changes: 17 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 155c362

Please sign in to comment.