Skip to content

Commit

Permalink
Rename flipper feature flag to better reflect purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Aug 28, 2024
1 parent 628bb02 commit 4e91955
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/controllers/api_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ def index
sig { void }
def create
user = T.must(current_user)
redirect_url = if Flipper.enabled?(:api_keys_in_profile, current_user)
redirect_url = if Flipper.enabled?(:trial_api_keys, current_user)
api_keys_url
else
api_howto_url
end

# For the time being limit users to only creating one API key
if user.api_keys.empty?
if Flipper.enabled?(:api_keys_in_profile, current_user)
if Flipper.enabled?(:trial_api_keys, current_user)
# Create a trial key which automatically expires and has a low daily limit
# TODO: Extract this
user.api_keys.create!(daily_limit: ApiKey.default_daily_limit_trial, expires_at: ApiKey.default_trial_duration_days.days.from_now)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/documentation_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def faq; end
def api_howto
# If feature flag is enabled show a new landing page instead
# with a link to an extracted "API Developer Documentation" page
return unless Flipper.enabled?(:api_keys_in_profile, current_user)
return unless Flipper.enabled?(:trial_api_keys, current_user)

render "api_landing"
end

sig { void }
def api_developer
raise ActiveRecord::RecordNotFound unless Flipper.enabled?(:api_keys_in_profile, current_user)
raise ActiveRecord::RecordNotFound unless Flipper.enabled?(:trial_api_keys, current_user)
end

# rubocop:disable Naming/AccessorMethodName
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_menu_desktop.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%= render NavItemComponent.new(href: root_path, selected: current_page?(root_path)).with_content("Home") %>
<%= render NavItemComponent.new(href: address_applications_path, selected: current_page?(address_applications_path)).with_content("Search") %>
<%= render NavItemComponent.new(href: api_howto_path, selected: current_page?(api_howto_path)) do %>
<% if Flipper.enabled?(:api_keys_in_profile, current_user) %>
<% if Flipper.enabled?(:trial_api_keys, current_user) %>
Planning Alerts API
<% else %>
Get the Data
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_menu_mobile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<li><%= link_to "Search", address_applications_path, class: class_names("decoration-fuchsia", "decoration-4", "focus:outline-none", "focus:bg-sun-yellow", "underline" => current_page?(address_applications_path)) %></li>
<li>
<%= link_to api_howto_path, class: class_names("decoration-fuchsia", "decoration-4", "focus:outline-none", "focus:bg-sun-yellow", "underline" => current_page?(api_howto_path)) do %>
<% if Flipper.enabled?(:api_keys_in_profile, current_user) %>
<% if Flipper.enabled?(:trial_api_keys, current_user) %>
Planning Alerts API
<% else %>
Get the Data
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_profile_menu.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<li><div class="pl-4"><%= pa_link_to_unless_current "Your alerts", alerts_path %></div></li>
<li><div class="pl-4"><%= pa_link_to_unless_current "Create new alert", new_alert_path %></div></li>
<li><div class="pl-4"><%= pa_link_to_unless_current "Your comments", personal_comments_path %></div></li>
<% if Flipper.enabled?(:api_keys_in_profile, current_user) %>
<% if Flipper.enabled?(:trial_api_keys, current_user) %>
<li><div class="pl-4"><%= pa_link_to_unless_current "Your API keys", api_keys_path %></div></li>
<% end %>
<li><div class="pl-4"><%= pa_link_to_unless_current "Edit account", edit_user_registration_path %></div></li>
Expand Down
2 changes: 1 addition & 1 deletion app/views/documentation/api_developer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
You need an API key to try out the examples below and use the API for yourself.
</p>
<div class="mt-8 mb-4">
<% if Flipper.enabled?(:api_keys_in_profile, current_user) %>
<% if Flipper.enabled?(:trial_api_keys, current_user) %>
<%= render ButtonComponent.new(tag: :a, size: "xl", type: :primary, href: confirm_api_keys_path).with_content("Create API key") %>
<% else %>
<%= pa_button_to "Create API key", api_keys_path, method: :post %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/documentation/api_howto.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
You need an API key to try out the examples below and use the API for yourself.
</p>
<div class="mt-8 mb-4">
<% if Flipper.enabled?(:api_keys_in_profile, current_user) %>
<% if Flipper.enabled?(:trial_api_keys, current_user) %>
<%= render ButtonComponent.new(tag: :a, size: "xl", type: :primary, href: confirm_api_keys_path).with_content("Create API key") %>
<% else %>
<%= pa_button_to "Create API key", api_keys_path, method: :post %>
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/flipper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"full_text_search" => "Allow searching for all applications containing the word 'tree', for example",
"view_application_versions" => "Can view the update history of an application",
"request_api_keys" => "Allow a new experimental flow for requesting API keys",
"api_keys_in_profile" => "Show and manage API keys inside your user profile and new API landing page"
"trial_api_keys" => "New API keys expire, new API landing page and user can show and manage API keys inside their profile"
}
end

Expand Down

0 comments on commit 4e91955

Please sign in to comment.