feat: delete gh app

This commit is contained in:
Andras Bacsai 2023-05-09 10:01:57 +02:00
parent bba8b25b48
commit db92dc3636
8 changed files with 17 additions and 46 deletions

View File

@ -58,46 +58,13 @@ class Change extends Component
$this->parameters = getParameters(); $this->parameters = getParameters();
$this->is_system_wide = $this->github_app->is_system_wide; $this->is_system_wide = $this->github_app->is_system_wide;
} }
public function createGithubApp() public function delete()
{ {
$settings = InstanceSettings::first(); try {
$fqdn = $settings->fqdn; $this->github_app->delete();
if (!$fqdn) { redirect()->route('dashboard');
$fqdn = $this->host; } catch (\Exception $e) {
return generalErrorHandlerLivewire($e, $this);
} }
if ($this->github_app->organization) {
$url = 'organizations/' . $this->github_app->organization . '/settings/apps/new';
} else {
$url = 'settings/apps/new';
}
$name = Str::kebab('coolify' . $this->github_app->name);
$data = [
"name" => $name,
"url" => $fqdn,
"hook_attributes" => [
"url" => "$fqdn/webhooks/github/events"
],
"redirect_url" => "$fqdn/webhooks/github",
"callback_url" => [
"$fqdn/login/github/app",
],
"public" => false,
"request_oauth_on_install" => false,
"setup_url" => "$fqdn/webhooks/github/install?source_id=" . $this->github_app->uuid,
"setup_on_update" => true,
"default_permissions" => [
"contents" => 'read',
"metadata" => 'read',
"pull_requests" => 'read',
"emails" => 'read'
],
"default_events" => ['pull_request', 'push']
];
$response = Http::asForm()->post("{$this->github_app->html_url}/{$url}?state={$this->github_app->uuid}", [
'id' => 'manifest',
'name' => 'manifest',
'data' => json_encode($data),
]);
dd($response);
} }
} }

View File

@ -10,7 +10,7 @@
<x-inputs.button> <x-inputs.button>
Submit Submit
</x-inputs.button> </x-inputs.button>
<x-inputs.button isWarning x-on:click="deleteDestination = true"> <x-inputs.button isWarning x-on:click.prevent="deleteDestination = true">
Delete Delete
</x-inputs.button> </x-inputs.button>
</div> </div>

View File

@ -7,7 +7,7 @@
<x-inputs.button type="submit"> <x-inputs.button type="submit">
Submit Submit
</x-inputs.button> </x-inputs.button>
<x-inputs.button isWarning x-on:click="deletePrivateKey = true"> <x-inputs.button isWarning x-on:click.prevent="deletePrivateKey = true">
Delete Delete
</x-inputs.button> </x-inputs.button>
</form> </form>

View File

@ -8,7 +8,7 @@
<x-inputs.button wire:click='start'>Start</x-inputs.button> <x-inputs.button wire:click='start'>Start</x-inputs.button>
<x-inputs.button wire:click='forceRebuild'>Start (no cache)</x-inputs.button> <x-inputs.button wire:click='forceRebuild'>Start (no cache)</x-inputs.button>
@endif @endif
<x-inputs.button isWarning x-on:click="deleteApplication = true"> <x-inputs.button isWarning x-on:click.prevent="deleteApplication = true">
Delete</x-inputs.button> Delete</x-inputs.button>
<span wire:poll.5000ms='pollingStatus'> <span wire:poll.5000ms='pollingStatus'>
@if ($application->status === 'running') @if ($application->status === 'running')

View File

@ -10,7 +10,7 @@
<x-inputs.button type="submit"> <x-inputs.button type="submit">
Update Update
</x-inputs.button> </x-inputs.button>
<x-inputs.button x-on:click="deleteEnvironment = true" isWarning> <x-inputs.button x-on:click.prevent="deleteEnvironment = true" isWarning>
Delete Delete
</x-inputs.button> </x-inputs.button>
</form> </form>

View File

@ -7,7 +7,7 @@
<x-inputs.button type="submit"> <x-inputs.button type="submit">
Update Update
</x-inputs.button> </x-inputs.button>
<x-inputs.button x-on:click="deleteStorage = true" isWarning> <x-inputs.button x-on:click.prevent="deleteStorage = true" isWarning>
Delete Delete
</x-inputs.button> </x-inputs.button>
</form> </form>

View File

@ -22,7 +22,7 @@
<x-inputs.button type="submit">Submit</x-inputs.button> <x-inputs.button type="submit">Submit</x-inputs.button>
<x-inputs.button wire:click.prevent='checkServer'>Check Server</x-inputs.button> <x-inputs.button wire:click.prevent='checkServer'>Check Server</x-inputs.button>
<x-inputs.button wire:click.prevent='installDocker'>Install Docker</x-inputs.button> <x-inputs.button wire:click.prevent='installDocker'>Install Docker</x-inputs.button>
<x-inputs.button isWarning x-on:click="deleteServer = true"> <x-inputs.button isWarning x-on:click.prevent="deleteServer = true">
Delete Delete
</x-inputs.button> </x-inputs.button>
</div> </div>

View File

@ -1,4 +1,5 @@
<div> <div x-data="{ deleteSource: false }">
<x-naked-modal show="deleteSource" message='Are you sure you would like to delete this source?' />
<h3>Change Github App</h3> <h3>Change Github App</h3>
<form wire:submit.prevent='submit'> <form wire:submit.prevent='submit'>
<x-inputs.input id="github_app.name" label="App Name" required /> <x-inputs.input id="github_app.name" label="App Name" required />
@ -23,6 +24,9 @@
@else @else
<div class="py-2"> <div class="py-2">
<x-inputs.button type="submit">Save</x-inputs.button> <x-inputs.button type="submit">Save</x-inputs.button>
<x-inputs.button isWarning x-on:click.prevent="deleteSource = true">
Delete
</x-inputs.button>
</div> </div>
@endif @endif
</form> </form>