UX: logs when an automation is destroyed (#29565)
Some checks are pending
Licenses / run (push) Waiting to run
Linting / run (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (frontend, themes) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (system, chat) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (system, core) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (system, plugins) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (system, themes) (push) Waiting to run
Tests / core frontend (${{ matrix.browser }}) (Chrome) (push) Waiting to run
Tests / core frontend (${{ matrix.browser }}) (Firefox ESR) (push) Waiting to run
Tests / core frontend (${{ matrix.browser }}) (Firefox Evergreen) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (annotations, core) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (backend, core) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (backend, plugins) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (frontend, plugins) (push) Waiting to run

A `UserHistory` entry will now be created when an automation is destroyed. This is visible in `/admin/logs/staff_action_logs`. id, name, trigger and script will be logged.

This commit also creates a service `DestroyAutomation` to hold all the destroy automation logic.

---------
Co-authored-by: Martin Brennan <mjrbrennan@gmail.com>
This commit is contained in:
Joffrey JAFFEUX
2024-11-04 11:12:18 +09:00
committed by GitHub
parent a43bd24c67
commit 932bd6ba85
6 changed files with 109 additions and 4 deletions

View File

@ -81,9 +81,11 @@ module DiscourseAutomation
end
def destroy
automation = DiscourseAutomation::Automation.find(params[:id])
automation.destroy!
render json: success_json
DiscourseAutomation::DestroyAutomation.call(service_params) do
on_success { render(json: success_json) }
on_model_not_found(:automation) { raise Discourse::NotFound }
on_failed_policy(:can_destroy_automation) { raise Discourse::InvalidAccess }
end
end
private