feat: installation/update github apps

This commit is contained in:
Andras Bacsai
2023-05-09 11:33:50 +02:00
parent db92dc3636
commit 19ad184cd6
20 changed files with 179 additions and 35 deletions

View File

@@ -1,19 +1,25 @@
@props([
'isWarning' => null,
'disabled' => null,
'defaultClass' => 'text-white bg-neutral-800 hover:bg-violet-600 h-8',
'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600 h-8',
'disabledClass' => 'text-neutral-400 bg-neutral-900 h-8',
'loadingClass' => 'text-black bg-green-500 h-8',
'confirm' => null,
'confirmAction' => null,
])
<button {{ $attributes }} @class([
$defaultClass => !$confirm && !$isWarning,
$defaultWarningClass => $confirm || $isWarning,
]) @if ($attributes->whereStartsWith('wire:click'))
$defaultClass => !$confirm && !$isWarning && !$disabled,
$defaultWarningClass => ($confirm || $isWarning) && !$disabled,
$disabledClass => $disabled,
]) @if ($attributes->whereStartsWith('wire:click') && !$disabled)
wire:target="{{ explode('(', $attributes->whereStartsWith('wire:click')->first())[0] }}"
wire:loading.delay.class="{{ $loadingClass }}" wire:loading.delay.attr="disabled"
wire:loading.delay.class.remove="{{ $defaultClass }} {{ $attributes->whereStartsWith('class')->first() }}"
@endif
@if ($disabled !== null)
disabled title="{{ $disabled }}"
@endif
@isset($confirm)
x-on:click="toggleConfirmModal('{{ $confirm }}', '{{ explode('(', $confirmAction)[0] }}')"
@endisset

View File

@@ -0,0 +1,13 @@
<div x-data="{ deleteProject: false }">
<x-naked-modal show="deleteProject" message='Are you sure you would like to delete this project?' />
@if ($resource_count > 0)
<x-inputs.button isWarning disabled="First delete all resources.">
Delete
</x-inputs.button>
@else
<x-inputs.button isWarning x-on:click.prevent="deleteProject = true">
Delete
</x-inputs.button>
@endif
</div>

View File

@@ -2,7 +2,9 @@
@if ($github_apps->count() > 0)
<h1>Choose a GitHub App</h1>
@foreach ($github_apps as $ghapp)
<x-inputs.button wire:click="loadRepositories({{ $ghapp->id }})">{{ $ghapp->name }}</x-inputs.button>
<x-inputs.button wire:key="{{ $ghapp->id }}" wire:click="loadRepositories({{ $ghapp->id }})">
{{ $ghapp->name }}
</x-inputs.button>
@endforeach
<div>
@if ($repositories->count() > 0)

View File

@@ -21,6 +21,9 @@
<x-inputs.input id="github_app.client_secret" label="Client Secret" type="password" disabled />
<x-inputs.input id="github_app.webhook_secret" label="Webhook Secret" type="password" disabled />
<x-inputs.button type="submit">Save</x-inputs.button>
<x-inputs.button isWarning x-on:click.prevent="deleteSource = true">
Delete
</x-inputs.button>
@else
<div class="py-2">
<x-inputs.button type="submit">Save</x-inputs.button>
@@ -30,6 +33,4 @@
</div>
@endif
</form>
</div>

View File

@@ -18,7 +18,7 @@
<livewire:project.new.public-git-repository :type="$type" />
</div>
<div x-cloak x-show="activeTab === 'github-private-repo'">
<livewire:project.new.github-private-repository />
<livewire:project.new.github-private-repository :type="$type" />
</div>
</div>
</x-layout>

View File

@@ -1,8 +1,14 @@
<x-layout>
<h1>Resources <a href="{{ route('project.resources.new', Route::current()->parameters()) }}">
<div class="flex items-center gap-2">
<h1>Resources</h1>
<a href="{{ route('project.resources.new', Route::current()->parameters()) }}">
<x-inputs.button>New</x-inputs.button>
</a>
</h1>
<livewire:project.delete :project_id="$project->id" :resource_count="$project->applications->count()" />
</div>
@if ($environment->applications->count() === 0)
<p>No resources yet.</p>
@endif
<div>
@foreach ($environment->applications as $application)
<p>

View File

@@ -25,13 +25,14 @@
name,
url: baseUrl,
hook_attributes: {
url: `${webhookBaseUrl}/github/events`
url: `${webhookBaseUrl}/source/github/events`,
active: true,
},
redirect_url: `${webhookBaseUrl}/github`,
redirect_url: `${webhookBaseUrl}/source/github/redirect`,
callback_urls: [`${baseUrl}/login/github/app`],
public: false,
request_oauth_on_install: false,
setup_url: `${webhookBaseUrl}/github/install?source=${uuid}`,
setup_url: `${webhookBaseUrl}/source/github/install?source=${uuid}`,
setup_on_update: true,
default_permissions: {
contents: 'read',
@@ -54,5 +55,14 @@
form.submit();
}
</script>
@elseif($github_app->app_id && !$github_app->installation_id)
<a href="{{ $installation_url }}">
<x-inputs.button>Install Repositories</x-inputs.button>
</a>
@elseif($github_app->app_id && $github_app->installation_id)
<a href="{{ $installation_url }}">
<x-inputs.button>Update Repositories</x-inputs.button>
</a>
@endif
</x-layout>