mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 03:32:18 -05:00
swap flipper checks for SiteSettings checks
This commit is contained in:
22 files changed
+34
-46
No files matched your search
@@ -14,7 +14,7 @@ class FollowButtonComponent < ViewComponent::Base
|
||||
end
|
||||
|
||||
def render?
|
||||
Flipper.enabled? :multiuser
|
||||
SiteSettings.multiuser_enabled?
|
||||
end
|
||||
|
||||
erb_template <<-ERB
|
||||
|
||||
@@ -36,7 +36,7 @@ class Users::SessionsController < Devise::SessionsController
|
||||
create_admin_user if User.with_role(:administrator).empty?
|
||||
# If in single user mode, or on first run,
|
||||
# automatically log in with an admin account
|
||||
if !Flipper.enabled?(:multiuser) || User.with_role(:administrator).first.reset_password_token == "first_use"
|
||||
if !SiteSettings.multiuser_enabled? || User.with_role(:administrator).first.reset_password_token == "first_use"
|
||||
sign_in(:user, User.with_role(:administrator).first)
|
||||
flash.discard
|
||||
redirect_back_or_to root_path, alert: nil
|
||||
|
||||
@@ -36,7 +36,7 @@ class ApplicationPolicy
|
||||
all_of(
|
||||
user&.is_editor?,
|
||||
none_of(
|
||||
Flipper.enabled?(:demo_mode)
|
||||
SiteSettings.demo_mode_enabled?
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
class Federails::FollowingPolicy < ApplicationPolicy
|
||||
def create?
|
||||
all_of(
|
||||
Flipper.enabled?(:multiuser)
|
||||
SiteSettings.multiuser_enabled?
|
||||
)
|
||||
end
|
||||
|
||||
def destroy?
|
||||
all_of(
|
||||
Flipper.enabled?(:multiuser)
|
||||
SiteSettings.multiuser_enabled?
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ class LibraryPolicy < ApplicationPolicy
|
||||
all_of(
|
||||
user&.is_administrator?,
|
||||
none_of(
|
||||
Flipper.enabled?(:demo_mode)
|
||||
SiteSettings.demo_mode_enabled?
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class ModelPolicy < ApplicationPolicy
|
||||
all_of(
|
||||
user&.is_editor?,
|
||||
none_of(
|
||||
Flipper.enabled?(:demo_mode)
|
||||
SiteSettings.demo_mode_enabled?
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ class UploadPolicy < ApplicationPolicy
|
||||
all_of(
|
||||
user&.is_contributor?,
|
||||
none_of(
|
||||
Flipper.enabled?(:demo_mode)
|
||||
SiteSettings.demo_mode_enabled?
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ class UserPolicy < ApplicationPolicy
|
||||
all_of(
|
||||
user&.is_administrator?,
|
||||
none_of(
|
||||
Flipper.enabled?(:demo_mode)
|
||||
SiteSettings.demo_mode_enabled?
|
||||
)
|
||||
)
|
||||
end
|
||||
@@ -19,13 +19,13 @@ class UserPolicy < ApplicationPolicy
|
||||
|
||||
def create?
|
||||
all_of(
|
||||
Flipper.enabled?(:multiuser),
|
||||
SiteSettings.multiuser_enabled?,
|
||||
one_of(
|
||||
SiteSettings.registration_enabled,
|
||||
SiteSettings.registration_enabled?,
|
||||
user&.is_administrator?
|
||||
),
|
||||
none_of(
|
||||
Flipper.enabled?(:demo_mode)
|
||||
SiteSettings.demo_mode_enabled?
|
||||
)
|
||||
)
|
||||
end
|
||||
@@ -43,9 +43,9 @@ class UserPolicy < ApplicationPolicy
|
||||
user == record,
|
||||
user&.is_administrator?
|
||||
),
|
||||
Flipper.enabled?(:multiuser),
|
||||
SiteSettings.multiuser_enabled?,
|
||||
none_of(
|
||||
Flipper.enabled?(:demo_mode)
|
||||
SiteSettings.demo_mode_enabled?
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
class Users::PasswordsPolicy < ApplicationPolicy
|
||||
def create?
|
||||
Flipper.enabled?(:multiuser) && SiteSettings.email_configured
|
||||
SiteSettings.multiuser_enabled? && SiteSettings.email_configured?
|
||||
end
|
||||
|
||||
def update?
|
||||
Flipper.enabled?(:multiuser) && SiteSettings.email_configured
|
||||
SiteSettings.multiuser_enabled? && SiteSettings.email_configured?
|
||||
end
|
||||
end
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
class Users::RegistrationsPolicy < ApplicationPolicy
|
||||
def cancel?
|
||||
Flipper.enabled?(:multiuser)
|
||||
SiteSettings.multiuser_enabled?
|
||||
end
|
||||
end
|
||||
@@ -6,10 +6,10 @@ class Users::SessionsPolicy < ApplicationPolicy
|
||||
end
|
||||
|
||||
def create?
|
||||
Flipper.enabled?(:multiuser)
|
||||
SiteSettings.multiuser_enabled?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
Flipper.enabled?(:multiuser)
|
||||
SiteSettings.multiuser_enabled?
|
||||
end
|
||||
end
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class='col col-auto'>
|
||||
<%= t ".description", retention_period: distance_of_time_in_words(ActiveJob::Status.options[:expires_in]) %>
|
||||
</div>
|
||||
<% if !Flipper.enabled?(:demo_mode) %>
|
||||
<% if !SiteSettings.demo_mode_enabled? %>
|
||||
<div class='col text-end'>
|
||||
<%= link_to safe_join([icon("activity", t(".sidekiq")), t(".sidekiq")], " "),
|
||||
"/sidekiq",
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
<%= f.search_field :q, class: "form-control ms-1 me-3", placeholder: translate(".search"), aria_label: translate(".search"), aria_describedby: "button-search", value: params[:q] %>
|
||||
<% end %>
|
||||
</li>
|
||||
<%- if Flipper.enabled? :multiuser %>
|
||||
<%- if SiteSettings.multiuser_enabled? %>
|
||||
<%- if current_user %>
|
||||
<li class="nav-item">
|
||||
<%= nav_link "person", t(".account"), edit_user_registration_path, text_style: "d-lg-none" %>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
nil %>
|
||||
</div>
|
||||
</div>
|
||||
<%- if Flipper.enabled? :multiuser %>
|
||||
<%- if SiteSettings.multiuser_enabled? %>
|
||||
<div class="card border-danger mt-3">
|
||||
<h4 class="card-header text-bg-danger"><%= t ".danger_zone" %></h4>
|
||||
<div class="card-body">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<%= render "application/content_header" %>
|
||||
<h1 class="d-none d-lg-block"><%= t "application.title" %></h1>
|
||||
<p class='lead'><%= t "application.tagline" %></p>
|
||||
<% if Flipper.enabled? :demo_mode %>
|
||||
<% if SiteSettings.demo_mode_enabled? %>
|
||||
<div class="alert alert-info">
|
||||
<%= t "application.demo_mode" %>
|
||||
</div>
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
<h3 class="card-header"><%= t(".heading") %></h3>
|
||||
<div class="card-body">
|
||||
<p class='lead'>
|
||||
<%= Flipper.enabled?(:multiuser) ? t(".multiuser_mode") : t(".single_user_mode") %>
|
||||
<%= SiteSettings.multiuser_enabled? ? t(".multiuser_mode") : t(".single_user_mode") %>
|
||||
</p>
|
||||
<% if Flipper.enabled?(:multiuser) %>
|
||||
<% if SiteSettings.multiuser_enabled? %>
|
||||
<p>
|
||||
<%= SiteSettings.registration_enabled ? t(".registrations_open") : t(".registrations_closed") %>
|
||||
<%= SiteSettings.registration_enabled? ? t(".registrations_open") : t(".registrations_closed") %>
|
||||
</p>
|
||||
<% end %>
|
||||
<p>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<div class='col'>
|
||||
<button type="submit" class="btn btn-primary"><%= icon("save", t(".submit")) %> <%= t(".submit") %></button>
|
||||
</div>
|
||||
<% if current_user.is_administrator? && !Flipper.enabled?(:demo_mode) %>
|
||||
<% if current_user.is_administrator? && !SiteSettings.demo_mode_enabled? %>
|
||||
<div class='col text-end'>
|
||||
<%= link_to safe_join([icon("tools", t(".advanced_admin")), t(".advanced_admin")], " "),
|
||||
"/admin",
|
||||
|
||||
@@ -140,7 +140,7 @@ ActiveAdmin.setup do |config|
|
||||
# Active Admin resources and pages from here.
|
||||
#
|
||||
config.before_action do
|
||||
raise Pundit::NotAuthorizedError, I18n.t("active_admin.demo_mode") if Flipper.enabled? :demo_mode
|
||||
raise Pundit::NotAuthorizedError, I18n.t("active_admin.demo_mode") if SiteSettings.demo_mode_enabled?
|
||||
end
|
||||
|
||||
# == Attribute Filters
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
federation_enabled = begin
|
||||
Flipper.enabled?(:federation)
|
||||
rescue ActiveRecord::StatementInvalid
|
||||
false
|
||||
end
|
||||
|
||||
Federails.configure do |conf|
|
||||
conf.app_name = "Manyfold"
|
||||
conf.app_version = Rails.application.config.app_version
|
||||
@@ -14,7 +8,7 @@ Federails.configure do |conf|
|
||||
conf.site_port = Rails.application.default_url_options[:port]
|
||||
conf.force_ssl = Rails.application.config.force_ssl
|
||||
|
||||
conf.enable_discovery = federation_enabled
|
||||
conf.enable_discovery = Rails.application.config.manyfold_features[:federation]
|
||||
conf.server_routes_path = "federation"
|
||||
conf.client_routes_path = "client"
|
||||
|
||||
|
||||
+2
-8
@@ -18,11 +18,7 @@ Rails.application.routes.draw do
|
||||
resources :activity
|
||||
end
|
||||
|
||||
begin
|
||||
mount Federails::Engine => "/" if Flipper.enabled?(:multiuser)
|
||||
rescue ActiveRecord::StatementInvalid
|
||||
nil
|
||||
end
|
||||
mount Federails::Engine => "/" if Rails.application.config.manyfold_features[:multiuser]
|
||||
|
||||
resources :users, only: [] do
|
||||
resource :settings, only: [:show, :update]
|
||||
@@ -40,15 +36,13 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
concern :followable do |options|
|
||||
if Flipper.enabled?(:multiuser)
|
||||
if Rails.application.config.manyfold_features[:multiuser]
|
||||
resources :follows, {only: [:create]}.merge(options) do
|
||||
collection do
|
||||
delete "/", action: "destroy"
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue ActiveRecord::StatementInvalid
|
||||
nil
|
||||
end
|
||||
|
||||
resources :models do
|
||||
|
||||
@@ -4,7 +4,7 @@ require "rails_helper"
|
||||
|
||||
RSpec.describe FollowButtonComponent, type: :component do
|
||||
before do
|
||||
allow(Flipper).to receive(:enabled?).with(:multiuser).and_return true
|
||||
allow(SiteSettings).to receive(:multiuser_enabled?).and_return(true)
|
||||
end
|
||||
|
||||
let(:follower) { create(:user) }
|
||||
|
||||
@@ -138,7 +138,7 @@ RSpec.describe "Users::Registrations" do
|
||||
|
||||
context "when in multiuser mode with closed registrations", :multiuser do
|
||||
before do
|
||||
allow(SiteSettings).to receive(:registration_enabled).and_return(false)
|
||||
allow(SiteSettings).to receive(:registration_enabled?).and_return(false)
|
||||
end
|
||||
|
||||
context "when signed out" do
|
||||
@@ -258,7 +258,7 @@ RSpec.describe "Users::Registrations" do
|
||||
|
||||
context "when in multiuser mode with open registrations", :multiuser do
|
||||
before do
|
||||
allow(SiteSettings).to receive(:registration_enabled).and_return(true)
|
||||
allow(SiteSettings).to receive(:registration_enabled?).and_return(true)
|
||||
end
|
||||
|
||||
context "when signed out" do
|
||||
|
||||
Reference in new issue
Block a user