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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
refactored: webhooks view
Andras Bacsai39a733234302
diff --git a/app/Livewire/Project/Shared/Webhooks.php b/app/Livewire/Project/Shared/Webhooks.phpindex e96bd888e7..40e7cdd49b 100644--- a/app/Livewire/Project/Shared/Webhooks.php+++ b/app/Livewire/Project/Shared/Webhooks.php@@ -4,49 +4,59 @@ namespace App\Livewire\Project\Shared;use Livewire\Component;+// Refactored ✅class Webhooks extends Component{public $resource;- public ?string $deploywebhook = null;+ public string $deploywebhook;- public ?string $githubManualWebhook = null;+ public string $githubManualWebhook;- public ?string $gitlabManualWebhook = null;+ public string $gitlabManualWebhook;- public ?string $bitbucketManualWebhook = null;+ public string $bitbucketManualWebhook;- public ?string $giteaManualWebhook = null;+ public string $giteaManualWebhook;- protected $rules = [- 'resource.manual_webhook_secret_github' => 'nullable|string',- 'resource.manual_webhook_secret_gitlab' => 'nullable|string',- 'resource.manual_webhook_secret_bitbucket' => 'nullable|string',- 'resource.manual_webhook_secret_gitea' => 'nullable|string',- ];+ public ?string $githubManualWebhookSecret = null;- public function saveSecret()- {- try {- $this->validate();- $this->resource->save();- $this->dispatch('success', 'Secret Saved.');- } catch (\Exception $e) {- return handleError($e, $this);- }- }+ public ?string $gitlabManualWebhookSecret = null;++ public ?string $bitbucketManualWebhookSecret = null;++ public ?string $giteaManualWebhookSecret = null;public function mount(){$this->deploywebhook = generateDeployWebhook($this->resource);++ $this->githubManualWebhookSecret = data_get($this->resource, 'manual_webhook_secret_github');$this->githubManualWebhook = generateGitManualWebhook($this->resource, 'github');++ $this->gitlabManualWebhookSecret = data_get($this->resource, 'manual_webhook_secret_gitlab');$this->gitlabManualWebhook = generateGitManualWebhook($this->resource, 'gitlab');++ $this->bitbucketManualWebhookSecret = data_get($this->resource, 'manual_webhook_secret_bitbucket');$this->bitbucketManualWebhook = generateGitManualWebhook($this->resource, 'bitbucket');++ $this->giteaManualWebhookSecret = data_get($this->resource, 'manual_webhook_secret_gitea');$this->giteaManualWebhook = generateGitManualWebhook($this->resource, 'gitea');}- public function render()+ public function submit(){- return view('livewire.project.shared.webhooks');+ 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);+ }}}diff --git a/resources/views/livewire/project/shared/webhooks.blade.php b/resources/views/livewire/project/shared/webhooks.blade.phpindex 9390082c98..6b9e1c86d1 100644--- a/resources/views/livewire/project/shared/webhooks.blade.php+++ b/resources/views/livewire/project/shared/webhooks.blade.php@@ -13,13 +13,13 @@<div><h3>Manual Git Webhooks</h3>@if ($githubManualWebhook && $gitlabManualWebhook)- <form wire:submit='saveSecret' class="flex flex-col gap-2">+ <form wire:submit='submit' class="flex flex-col gap-2"><div class="flex items-end gap-2"><x-forms.input helper="Content Type in GitHub configuration could be json or form-urlencoded."readonly label="GitHub" id="githubManualWebhook"></x-forms.input><x-forms.input type="password"helper="Need to set a secret to be able to use this webhook. It should match with the secret in GitHub."- label="GitHub Webhook Secret" id="resource.manual_webhook_secret_github"></x-forms.input>+ label="GitHub Webhook Secret" id="githubManualWebhookSecret"></x-forms.input></div><a target="_blank" class="flex hover:no-underline" href="{{ $resource?->gitWebhook }}">@@ -31,21 +31,19 @@<x-forms.input readonly label="GitLab" id="gitlabManualWebhook"></x-forms.input><x-forms.input type="password"helper="Need to set a secret to be able to use this webhook. It should match with the secret in GitLab."- label="GitLab Webhook Secret" id="resource.manual_webhook_secret_gitlab"></x-forms.input>+ label="GitLab Webhook Secret" id="gitlabManualWebhookSecret"></x-forms.input></div><div class="flex gap-2"><x-forms.input readonly label="Bitbucket" id="bitbucketManualWebhook"></x-forms.input><x-forms.input type="password"helper="Need to set a secret to be able to use this webhook. It should match with the secret in Bitbucket."- label="Bitbucket Webhook Secret"- id="resource.manual_webhook_secret_bitbucket"></x-forms.input>+ label="Bitbucket Webhook Secret" id="bitbucketManualWebhookSecret"></x-forms.input></div><div class="flex gap-2"><x-forms.input readonly label="Gitea" id="giteaManualWebhook"></x-forms.input><x-forms.input type="password"helper="Need to set a secret to be able to use this webhook. It should match with the secret in Gitea."- label="Gitea Webhook Secret"- id="resource.manual_webhook_secret_gitea"></x-forms.input>+ label="Gitea Webhook Secret" id="giteaManualWebhookSecret"></x-forms.input></div><x-forms.button type="submit">Save</x-forms.button></form>