mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-25 06:02:57 +08:00
Continued work on moderate flags UI. In this PR admins are allowed to change the order of flags. The notify user flag is always on top but all other flags can be moved.
37 lines
1.2 KiB
Ruby
Vendored
37 lines
1.2 KiB
Ruby
Vendored
# 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
|
|
|
|
def reorder
|
|
with_service(ReorderFlag) 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_policy(:invalid_move) { render_json_error(I18n.t("flags.errors.wrong_move")) }
|
|
on_failed_contract do |contract|
|
|
render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)
|
|
end
|
|
end
|
|
end
|
|
end
|