2023-05-08 13:36:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire\Source\Github;
|
|
|
|
|
|
|
|
use App\Models\GithubApp;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class Change extends Component
|
|
|
|
{
|
2023-06-14 09:44:40 +02:00
|
|
|
public string $webhook_endpoint;
|
|
|
|
public string|null $ipv4;
|
|
|
|
public string|null $ipv6;
|
|
|
|
public string|null $fqdn;
|
2023-06-14 13:07:58 +02:00
|
|
|
|
|
|
|
public bool|null $default_permissions = true;
|
|
|
|
public bool|null $preview_deployment_permissions = true;
|
|
|
|
|
2023-05-08 13:36:49 +02:00
|
|
|
public $parameters;
|
|
|
|
public GithubApp $github_app;
|
2023-05-18 13:26:35 +02:00
|
|
|
public string $name;
|
2023-05-08 13:36:49 +02:00
|
|
|
public bool $is_system_wide;
|
|
|
|
|
|
|
|
protected $rules = [
|
|
|
|
'github_app.name' => 'required|string',
|
|
|
|
'github_app.organization' => 'nullable|string',
|
|
|
|
'github_app.api_url' => 'required|string',
|
|
|
|
'github_app.html_url' => 'required|string',
|
|
|
|
'github_app.custom_user' => 'required|string',
|
|
|
|
'github_app.custom_port' => 'required|int',
|
|
|
|
'github_app.app_id' => 'required|int',
|
2023-06-14 09:44:40 +02:00
|
|
|
'github_app.installation_id' => 'nullable',
|
|
|
|
'github_app.client_id' => 'nullable',
|
|
|
|
'github_app.client_secret' => 'nullable',
|
|
|
|
'github_app.webhook_secret' => 'nullable',
|
2023-05-08 13:36:49 +02:00
|
|
|
'github_app.is_system_wide' => 'required|bool',
|
|
|
|
];
|
2023-08-08 11:51:36 +02:00
|
|
|
|
2023-06-14 09:44:40 +02:00
|
|
|
public function mount()
|
|
|
|
{
|
2023-08-31 09:56:37 +02:00
|
|
|
if (isCloud() && !isDev()) {
|
2023-08-28 21:03:07 +02:00
|
|
|
$this->webhook_endpoint = config('app.url');
|
|
|
|
} else {
|
|
|
|
$this->webhook_endpoint = $this->ipv4;
|
|
|
|
$this->is_system_wide = $this->github_app->is_system_wide;
|
|
|
|
}
|
2023-08-09 15:57:53 +02:00
|
|
|
$this->parameters = get_route_parameters();
|
2023-06-14 09:44:40 +02:00
|
|
|
}
|
2023-08-08 11:51:36 +02:00
|
|
|
|
2023-05-08 13:36:49 +02:00
|
|
|
public function submit()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$this->validate();
|
|
|
|
$this->github_app->save();
|
2023-09-11 17:36:30 +02:00
|
|
|
} catch (\Throwable $e) {
|
2023-09-15 15:34:25 +02:00
|
|
|
return handleError($e, $this);
|
2023-05-08 13:36:49 +02:00
|
|
|
}
|
|
|
|
}
|
2023-08-08 11:51:36 +02:00
|
|
|
|
2023-05-08 13:36:49 +02:00
|
|
|
public function instantSave()
|
|
|
|
{
|
|
|
|
}
|
2023-06-14 09:44:40 +02:00
|
|
|
|
2023-05-09 10:01:57 +02:00
|
|
|
public function delete()
|
2023-05-08 13:36:49 +02:00
|
|
|
{
|
2023-05-09 10:01:57 +02:00
|
|
|
try {
|
|
|
|
$this->github_app->delete();
|
2023-06-19 09:44:39 +02:00
|
|
|
redirect()->route('source.all');
|
2023-09-11 17:36:30 +02:00
|
|
|
} catch (\Throwable $e) {
|
2023-09-15 15:34:25 +02:00
|
|
|
return handleError($e, $this);
|
2023-05-08 13:36:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|