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;
|
|
|
|
|
2024-07-12 09:52:32 +00:00
|
|
|
// Refactored ✅
|
2023-10-25 08:43:07 +00:00
|
|
|
class Webhooks extends Component
|
|
|
|
{
|
|
|
|
public $resource;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-07-12 11:54:12 +00:00
|
|
|
public ?string $deploywebhook;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-07-12 11:54:12 +00:00
|
|
|
public ?string $githubManualWebhook;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-07-12 11:54:12 +00:00
|
|
|
public ?string $gitlabManualWebhook;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-07-12 11:54:12 +00:00
|
|
|
public ?string $bitbucketManualWebhook;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-07-12 11:54:12 +00:00
|
|
|
public ?string $giteaManualWebhook;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-07-12 09:52:32 +00:00
|
|
|
public ?string $githubManualWebhookSecret = null;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-07-12 09:52:32 +00:00
|
|
|
public ?string $gitlabManualWebhookSecret = null;
|
|
|
|
|
|
|
|
public ?string $bitbucketManualWebhookSecret = null;
|
|
|
|
|
|
|
|
public ?string $giteaManualWebhookSecret = null;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-10-25 08:43:07 +00:00
|
|
|
public function mount()
|
|
|
|
{
|
2024-07-12 10:51:55 +00:00
|
|
|
// ray()->clearAll();
|
|
|
|
// ray()->showQueries();
|
2023-10-25 08:43:07 +00:00
|
|
|
$this->deploywebhook = generateDeployWebhook($this->resource);
|
2024-07-12 09:52:32 +00:00
|
|
|
|
|
|
|
$this->githubManualWebhookSecret = data_get($this->resource, 'manual_webhook_secret_github');
|
2023-11-14 12:26:14 +00:00
|
|
|
$this->githubManualWebhook = generateGitManualWebhook($this->resource, 'github');
|
2024-07-12 09:52:32 +00:00
|
|
|
|
|
|
|
$this->gitlabManualWebhookSecret = data_get($this->resource, 'manual_webhook_secret_gitlab');
|
2023-11-14 12:26:14 +00:00
|
|
|
$this->gitlabManualWebhook = generateGitManualWebhook($this->resource, 'gitlab');
|
2024-07-12 09:52:32 +00:00
|
|
|
|
|
|
|
$this->bitbucketManualWebhookSecret = data_get($this->resource, 'manual_webhook_secret_bitbucket');
|
2024-01-23 10:34:25 +00:00
|
|
|
$this->bitbucketManualWebhook = generateGitManualWebhook($this->resource, 'bitbucket');
|
2024-07-12 09:52:32 +00:00
|
|
|
|
|
|
|
$this->giteaManualWebhookSecret = data_get($this->resource, 'manual_webhook_secret_gitea');
|
2024-05-23 09:30:18 +00:00
|
|
|
$this->giteaManualWebhook = generateGitManualWebhook($this->resource, 'gitea');
|
2023-10-25 08:43:07 +00:00
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-07-12 09:52:32 +00:00
|
|
|
public function submit()
|
2023-10-25 08:43:07 +00:00
|
|
|
{
|
2024-07-12 09:52:32 +00:00
|
|
|
try {
|
|
|
|
$this->authorize('update', $this->resource);
|
|
|
|
$this->resource->update([
|
|
|
|
'manual_webhook_secret_github' => $this->githubManualWebhookSecret,
|
|
|
|
'manual_webhook_secret_gitlab' => $this->gitlabManualWebhookSecret,
|
|
|
|
'manual_webhook_secret_bitbucket' => $this->bitbucketManualWebhookSecret,
|
|
|
|
'manual_webhook_secret_gitea' => $this->giteaManualWebhookSecret,
|
|
|
|
]);
|
|
|
|
$this->dispatch('success', 'Secret Saved.');
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
return handleError($e, $this);
|
|
|
|
}
|
2023-10-25 08:43:07 +00:00
|
|
|
}
|
|
|
|
}
|