mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: admin can disable flags (#27171)
UI for admins to disable system flags.
This commit is contained in:
committed by
GitHub
parent
e9c8e182d3
commit
963b9fd157
@@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Admin::AdminController < ApplicationController
|
||||
include WithServiceHelper
|
||||
|
||||
requires_login
|
||||
before_action :ensure_admin
|
||||
|
||||
|
||||
21
app/controllers/admin/config/flags_controller.rb
Normal file
21
app/controllers/admin/config/flags_controller.rb
Normal 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
|
||||
@@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Admin::StaffController < ApplicationController
|
||||
include WithServiceHelper
|
||||
|
||||
requires_login
|
||||
before_action :ensure_staff
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user