Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat(ui): add enable/disable button for scheduled task

ShadowArcanist5037497ada07
diff --git a/app/Livewire/Project/Shared/ScheduledTask/Show.php b/app/Livewire/Project/Shared/ScheduledTask/Show.php
index d99cd97271..882737f09b 100644
--- a/app/Livewire/Project/Shared/ScheduledTask/Show.php
+++ b/app/Livewire/Project/Shared/ScheduledTask/Show.php
@@ -111,6 +111,19 @@ class Show extends Component
}
}
+ public function toggleEnabled()
+ {
+ try {
+ $this->authorize('update', $this->resource);
+ $this->isEnabled = ! $this->isEnabled;
+ $this->task->enabled = $this->isEnabled;
+ $this->task->save();
+ $this->dispatch('success', $this->isEnabled ? 'Scheduled task enabled.' : 'Scheduled task disabled.');
+ } catch (\Exception $e) {
+ return handleError($e);
+ }
+ }
+
public function instantSave()
{
try {
diff --git a/resources/views/livewire/project/shared/scheduled-task/show.blade.php b/resources/views/livewire/project/shared/scheduled-task/show.blade.php
index 635b6c14b6..1e727f6c31 100644
--- a/resources/views/livewire/project/shared/scheduled-task/show.blade.php
+++ b/resources/views/livewire/project/shared/scheduled-task/show.blade.php
@@ -11,6 +11,11 @@
Execute Now
</x-forms.button>
@endif
+ @if (!$isEnabled)
+ <x-forms.button wire:click="toggleEnabled" isHighlighted>Enable Task</x-forms.button>
+ @else
+ <x-forms.button wire:click="toggleEnabled">Disable Task</x-forms.button>
+ @endif
<x-modal-confirmation title="Confirm Scheduled Task Deletion?" isErrorButton buttonTitle="Delete"
submitAction="delete({{ $task->id }})" :actions="['The selected scheduled task will be permanently deleted.']" confirmationText="{{ $task->name }}"
confirmationLabel="Please confirm the execution of the actions by entering the Scheduled Task Name below"
@@ -18,9 +23,6 @@
step2ButtonText="Permanently Delete" />
</div>
- <div class="w-48">
- <x-forms.checkbox instantSave id="isEnabled" label="Enabled" />
- </div>
<div class="flex gap-2 w-full">
<x-forms.input placeholder="Name" id="name" label="Name" required />
<x-forms.input placeholder="php artisan schedule:run" id="command" label="Command" required />