2023-10-25 08:43:07 +00:00
|
|
|
<?php
|
|
|
|
|
2023-12-07 18:06:32 +00:00
|
|
|
namespace App\Livewire\Project\Shared;
|
2023-10-25 08:43:07 +00:00
|
|
|
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class Webhooks extends Component
|
|
|
|
{
|
|
|
|
public $resource;
|
|
|
|
public ?string $deploywebhook = null;
|
2023-11-14 12:26:14 +00:00
|
|
|
public ?string $githubManualWebhook = null;
|
|
|
|
public ?string $gitlabManualWebhook = null;
|
2024-01-23 10:34:25 +00:00
|
|
|
public ?string $bitbucketManualWebhook = null;
|
2024-05-23 09:30:18 +00:00
|
|
|
public ?string $giteaManualWebhook = null;
|
2023-11-14 12:26:14 +00:00
|
|
|
protected $rules = [
|
|
|
|
'resource.manual_webhook_secret_github' => 'nullable|string',
|
|
|
|
'resource.manual_webhook_secret_gitlab' => 'nullable|string',
|
2024-01-23 10:34:25 +00:00
|
|
|
'resource.manual_webhook_secret_bitbucket' => 'nullable|string',
|
2024-05-23 09:30:18 +00:00
|
|
|
'resource.manual_webhook_secret_gitea' => 'nullable|string',
|
2023-11-14 12:26:14 +00:00
|
|
|
];
|
|
|
|
public function saveSecret()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$this->validate();
|
|
|
|
$this->resource->save();
|
2023-12-07 18:06:32 +00:00
|
|
|
$this->dispatch('success','Secret Saved.');
|
2023-11-14 12:26:14 +00:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
return handleError($e, $this);
|
|
|
|
}
|
|
|
|
}
|
2023-10-25 08:43:07 +00:00
|
|
|
public function mount()
|
|
|
|
{
|
|
|
|
$this->deploywebhook = generateDeployWebhook($this->resource);
|
2023-11-14 12:26:14 +00:00
|
|
|
$this->githubManualWebhook = generateGitManualWebhook($this->resource, 'github');
|
|
|
|
$this->gitlabManualWebhook = generateGitManualWebhook($this->resource, 'gitlab');
|
2024-01-23 10:34:25 +00:00
|
|
|
$this->bitbucketManualWebhook = generateGitManualWebhook($this->resource, 'bitbucket');
|
2024-05-23 09:30:18 +00:00
|
|
|
$this->giteaManualWebhook = generateGitManualWebhook($this->resource, 'gitea');
|
2023-10-25 08:43:07 +00:00
|
|
|
}
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('livewire.project.shared.webhooks');
|
|
|
|
}
|
|
|
|
}
|