mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
Add Intro UI feature flag
This commit is contained in:
@@ -10,10 +10,10 @@
|
|||||||
|
|
||||||
<%= form.select :role,
|
<%= form.select :role,
|
||||||
options_for_select([
|
options_for_select([
|
||||||
|
(Flipper.enabled?(:intro_ui) ? [t(".role_guest"), "guest"] : nil),
|
||||||
[t(".role_member"), "member"],
|
[t(".role_member"), "member"],
|
||||||
[t(".role_guest", default: "Guest"), "guest"],
|
|
||||||
[t(".role_admin"), "admin"]
|
[t(".role_admin"), "admin"]
|
||||||
]),
|
].compact),
|
||||||
{},
|
{},
|
||||||
{ label: t(".role_label") } %>
|
{ label: t(".role_label") } %>
|
||||||
|
|
||||||
|
|||||||
@@ -27,15 +27,23 @@ unless Rails.env.test?
|
|||||||
auth_source = ENV.fetch("AUTH_PROVIDERS_SOURCE") do
|
auth_source = ENV.fetch("AUTH_PROVIDERS_SOURCE") do
|
||||||
Rails.configuration.app_mode.self_hosted? ? "db" : "yaml"
|
Rails.configuration.app_mode.self_hosted? ? "db" : "yaml"
|
||||||
end.downcase
|
end.downcase
|
||||||
|
default_ui_layout = ENV.fetch("DEFAULT_UI_LAYOUT", "").downcase
|
||||||
|
|
||||||
# Ensure feature exists before enabling/disabling
|
# Ensure feature exists before enabling/disabling
|
||||||
Flipper.add(:db_sso_providers) unless Flipper.exist?(:db_sso_providers)
|
Flipper.add(:db_sso_providers) unless Flipper.exist?(:db_sso_providers)
|
||||||
|
if default_ui_layout.in?(%w[intro])
|
||||||
|
Flipper.add(:intro_ui, tags: [ :intro_ui ]) unless Flipper.exist?(:intro_ui)
|
||||||
|
end
|
||||||
|
|
||||||
if auth_source == "db"
|
if auth_source == "db"
|
||||||
Flipper.enable(:db_sso_providers)
|
Flipper.enable(:db_sso_providers)
|
||||||
else
|
else
|
||||||
Flipper.disable(:db_sso_providers)
|
Flipper.disable(:db_sso_providers)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if default_ui_layout.in?(%w[intro])
|
||||||
|
default_ui_layout == "intro" ? Flipper.enable(:intro_ui) : Flipper.disable(:intro_ui)
|
||||||
|
end
|
||||||
rescue ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid
|
rescue ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid
|
||||||
# Database not ready yet (e.g., during initial setup or migrations)
|
# Database not ready yet (e.g., during initial setup or migrations)
|
||||||
# This is expected during db:create or initial setup
|
# This is expected during db:create or initial setup
|
||||||
|
|||||||
Reference in New Issue
Block a user