From bac46aa01cee4c993dfc34e6db4c20ede0520c2d Mon Sep 17 00:00:00 2001 From: Peter Jaap Blaakmeer Date: Thu, 28 Dec 2023 10:55:22 +0100 Subject: [PATCH] Improve UI to enable/disable cronjobs (#202) --- .../Adminhtml/Config/Job/MassDisableJobs.php | 62 +++++++++++++++++++ Ui/Component/Listing/Column/Frequency.php | 29 +++++++++ .../cronjobmanager_config_grid.xml | 15 ++++- 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 Controller/Adminhtml/Config/Job/MassDisableJobs.php create mode 100644 Ui/Component/Listing/Column/Frequency.php diff --git a/Controller/Adminhtml/Config/Job/MassDisableJobs.php b/Controller/Adminhtml/Config/Job/MassDisableJobs.php new file mode 100644 index 00000000..d8ca3f20 --- /dev/null +++ b/Controller/Adminhtml/Config/Job/MassDisableJobs.php @@ -0,0 +1,62 @@ +getRequest()->getParam('selected'); + if (!isset($params)) { + $this->getMessageManager()->addErrorMessage("Something went wrong when receiving the request"); + $this->_redirect('*/config/index'); + return; + } + + try { + foreach ($params as $jobCode) { + $path = $this->helper->constructFrequencyPath($jobCode); + // Empty frequency disables the job + $this->helper->saveJobFrequencyConfig($path, ''); + } + + // Clear the config cache + $this->cache->clean([ConfigCache::CACHE_TAG]); + } catch (Exception $e) { + $this->getMessageManager()->addErrorMessage($e->getMessage()); + $this->_redirect('*/config/index/'); + + return; + } + + $this->getMessageManager()->addSuccessMessage("Successfully disabled " . count($params) . " jobs"); + $this->_redirect("*/config/index/"); + } +} diff --git a/Ui/Component/Listing/Column/Frequency.php b/Ui/Component/Listing/Column/Frequency.php new file mode 100644 index 00000000..e4fc0e2d --- /dev/null +++ b/Ui/Component/Listing/Column/Frequency.php @@ -0,0 +1,29 @@ + + + + + + Disable Jobs + Are you sure you want to disable these cron jobs (use Restore to re-enable them)? + + disable_jobs + Disable Jobs + + + + @@ -138,7 +151,7 @@ - + text