feat(acl): Change views/backend code to able to use proper ACL's later on. Currently it is not enabled.
This commit is contained in:
@@ -3,12 +3,15 @@
|
||||
namespace App\Livewire\Project\Shared\ScheduledTask;
|
||||
|
||||
use App\Models\ScheduledTask;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Component;
|
||||
|
||||
class Add extends Component
|
||||
{
|
||||
use AuthorizesRequests;
|
||||
|
||||
public $parameters;
|
||||
|
||||
#[Locked]
|
||||
@@ -20,6 +23,9 @@ class Add extends Component
|
||||
#[Locked]
|
||||
public Collection $containerNames;
|
||||
|
||||
#[Locked]
|
||||
public $resource;
|
||||
|
||||
public string $name;
|
||||
|
||||
public string $command;
|
||||
@@ -45,6 +51,22 @@ class Add extends Component
|
||||
public function mount()
|
||||
{
|
||||
$this->parameters = get_route_parameters();
|
||||
|
||||
// Get the resource based on type and id
|
||||
switch ($this->type) {
|
||||
case 'application':
|
||||
$this->resource = \App\Models\Application::findOrFail($this->id);
|
||||
break;
|
||||
case 'service':
|
||||
$this->resource = \App\Models\Service::findOrFail($this->id);
|
||||
break;
|
||||
case 'standalone-postgresql':
|
||||
$this->resource = \App\Models\StandalonePostgresql::findOrFail($this->id);
|
||||
break;
|
||||
default:
|
||||
throw new \Exception('Invalid resource type');
|
||||
}
|
||||
|
||||
if ($this->containerNames->count() > 0) {
|
||||
$this->container = $this->containerNames->first();
|
||||
}
|
||||
@@ -53,6 +75,7 @@ class Add extends Component
|
||||
public function submit()
|
||||
{
|
||||
try {
|
||||
$this->authorize('update', $this->resource);
|
||||
$this->validate();
|
||||
$isValid = validate_cron_expression($this->frequency);
|
||||
if (! $isValid) {
|
||||
|
||||
Reference in New Issue
Block a user