FEATURE: admin can disable flags (#27171)

UI for admins to disable system flags.
This commit is contained in:
Krzysztof Kotlarek
2024-05-29 14:39:58 +10:00
committed by GitHub
parent e9c8e182d3
commit 963b9fd157
31 changed files with 350 additions and 7 deletions

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class Admin::AdminController < ApplicationController
include WithServiceHelper
requires_login
before_action :ensure_admin

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
class Admin::Config::FlagsController < Admin::AdminController
def toggle
with_service(ToggleFlag) do
on_success do
Discourse.request_refresh!
render(json: success_json)
end
on_failure { render(json: failed_json, status: 422) }
on_model_not_found(:message) { raise Discourse::NotFound }
on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }
on_failed_contract do |contract|
render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)
end
end
end
def index
end
end

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class Admin::StaffController < ApplicationController
include WithServiceHelper
requires_login
before_action :ensure_staff
end