diff --git a/Gemfile b/Gemfile index fc00335..3445c32 100644 --- a/Gemfile +++ b/Gemfile @@ -42,6 +42,7 @@ gem 'rails-settings-cached', '~> 2.8.3' gem 'pagy', '~> 6.0', '>= 6.0.2' gem 'flipper' gem 'flipper-active_record' +gem 'flipper-ui' # HTTP requests gem 'faraday' diff --git a/Gemfile.lock b/Gemfile.lock index 24d410b..9a37e04 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -133,6 +133,12 @@ GEM flipper-active_record (0.28.0) activerecord (>= 4.2, < 8) flipper (~> 0.28.0) + flipper-ui (0.28.0) + erubi (>= 1.0.0, < 2.0.0) + flipper (~> 0.28.0) + rack (>= 1.4, < 3) + rack-protection (>= 1.5.3, <= 4.0.0) + sanitize (< 7) fugit (1.7.2) et-orbi (~> 1, >= 1.2.7) raabro (~> 1.4) @@ -204,6 +210,8 @@ GEM raabro (1.4.0) racc (1.6.0) rack (2.2.4) + rack-protection (3.0.6) + rack rack-test (2.0.2) rack (>= 1.3) rails (7.0.4) @@ -288,6 +296,9 @@ GEM ruby2_keywords (0.0.5) rufus-scheduler (3.8.2) fugit (~> 1.1, >= 1.1.6) + sanitize (6.0.1) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) sentry-rails (5.8.0) railties (>= 5.0) sentry-ruby (~> 5.8.0) @@ -381,6 +392,7 @@ DEPENDENCIES faraday flipper flipper-active_record + flipper-ui importmap-rails jbuilder (~> 2.7) letter_opener diff --git a/README.md b/README.md index 90fec7f..df1a1e9 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,10 @@ command: * [Sidekiq](https://github.com/mperham/sidekiq/wiki/) * [ActiveJob](https://github.com/mperham/sidekiq/wiki/Active-Job) +### Feature Flags + +* [Flipper](https://www.flippercloud.io/docs/get-started/self-hosted) + ## License [GNU Affero General Public License v3.0](https://choosealicense.com/licenses/agpl-3.0/) diff --git a/app/controllers/services/remotestorage_controller.rb b/app/controllers/services/remotestorage_controller.rb new file mode 100644 index 0000000..231e359 --- /dev/null +++ b/app/controllers/services/remotestorage_controller.rb @@ -0,0 +1,30 @@ +class Services::RemotestorageController < ApplicationController + before_action :require_user_signed_in + before_action :require_service_enabled + before_action :require_feature_enabled + before_action :set_current_section + + def dashboard + # unless current_user.services_enabled.include?(:remotestorage) + # redirect_to service_remotestorage_info_path + # end + end + + private + + def require_feature_enabled + unless Flipper.enabled?(:remotestorage, current_user) + http_status :forbidden + end + end + + def require_service_enabled + unless Setting.remotestorage_enabled? + http_status :not_found + end + end + + def set_current_section + @current_section = :services + end +end diff --git a/app/views/admin/users/show.html.erb b/app/views/admin/users/show.html.erb index 42c7963..9a95e23 100644 --- a/app/views/admin/users/show.html.erb +++ b/app/views/admin/users/show.html.erb @@ -6,6 +6,10 @@
ID | +<%= @user.id %> | +
---|---|
Created at | <%= @user.created_at.strftime("%Y-%m-%d (%H:%M UTC)") %> | diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index 8b90fc0..8ebbec3 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -73,6 +73,17 @@ <% end %> + <% if Setting.remotestorage_enabled? && Flipper.enabled?(:remotestorage, current_user) %> +