coolify/resources/views/livewire/source/github/change.blade.php

263 lines
15 KiB
PHP
Raw Normal View History

2023-07-28 13:31:47 +02:00
<div>
2023-11-07 09:44:47 +01:00
@if (data_get($github_app, 'app_id'))
2023-12-07 19:06:32 +01:00
<form wire:submit='submit'>
2023-11-07 09:44:47 +01:00
<div class="flex items-center gap-2">
<h1>GitHub App</h1>
<div class="flex gap-2">
2023-08-30 14:46:51 +02:00
@if (data_get($github_app, 'installation_id'))
2023-12-07 19:06:32 +01:00
<x-forms.button type="submit">Save</x-forms.button>
2023-08-30 14:46:51 +02:00
<a href="{{ get_installation_path($github_app) }}">
<x-forms.button>
2023-05-18 13:26:35 +02:00
Update Repositories
2023-08-11 20:19:42 +02:00
<x-external-link />
2023-08-30 14:46:51 +02:00
</x-forms.button>
</a>
@endif
2024-03-20 12:54:06 +01:00
<x-modal-confirmation isErrorButton buttonTitle="Delete">
2024-01-31 16:14:12 +01:00
This source will be deleted. It is not reversible. <br>Please think again.
2024-03-20 12:54:06 +01:00
</x-modal-confirmation>
2023-11-07 09:44:47 +01:00
</div>
2023-05-18 13:26:35 +02:00
</div>
2023-11-07 09:44:47 +01:00
<div class="subtitle">Your Private GitHub App for private repositories.</div>
2023-08-30 14:46:51 +02:00
@if (!data_get($github_app, 'installation_id'))
2024-03-20 12:54:06 +01:00
<div class="mb-10 rounded alert-error">
2023-08-30 14:46:51 +02:00
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 stroke-current shrink-0" fill="none"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg>
<span>You must complete this step before you can use this source!</span>
</div>
2023-11-07 09:44:47 +01:00
<a class="items-center justify-center box" href="{{ get_installation_path($github_app) }}">
2023-08-30 14:46:51 +02:00
Install Repositories on GitHub
</a>
@else
<div class="flex flex-col gap-2">
<div class="flex gap-2">
<x-forms.input id="github_app.name" label="App Name" disabled />
<x-forms.input id="github_app.organization" label="Organization" disabled
placeholder="If empty, personal user will be used" />
</div>
@if (!isCloud())
<div class="w-48">
<x-forms.checkbox label="System Wide?"
helper="If checked, this GitHub App will be available for everyone in this Coolify instance."
instantSave id="github_app.is_system_wide" />
</div>
@endif
<div class="flex gap-2">
<x-forms.input id="github_app.html_url" label="HTML Url" disabled />
<x-forms.input id="github_app.api_url" label="API Url" disabled />
</div>
<div class="flex gap-2">
@if ($github_app->html_url === 'https://github.com')
<x-forms.input id="github_app.custom_user" label="User" disabled />
<x-forms.input type="number" id="github_app.custom_port" label="Port" disabled />
@else
<x-forms.input id="github_app.custom_user" label="User" required />
<x-forms.input type="number" id="github_app.custom_port" label="Port" required />
@endif
</div>
<div class="flex gap-2">
<x-forms.input type="number" id="github_app.app_id" label="App Id" disabled />
<x-forms.input type="number" id="github_app.installation_id" label="Installation Id"
disabled />
</div>
<div class="flex gap-2">
<x-forms.input id="github_app.client_id" label="Client Id" type="password" disabled />
<x-forms.input id="github_app.client_secret" label="Client Secret" type="password" />
<x-forms.input id="github_app.webhook_secret" label="Webhook Secret" type="password" />
</div>
<div class="flex items-end gap-2 ">
2024-03-13 14:55:44 +01:00
<h2 class="pt-4">Permissions</h2>
<x-forms.button wire:click.prevent="checkPermissions">Refetch</x-forms.button>
<a href="{{ get_permissions_path($github_app) }}">
<x-forms.button>
Update
<x-external-link />
</x-forms.button>
</a>
</div>
<div class="flex gap-2">
<x-forms.input id="github_app.contents" helper="read - mandatory." label="Content" readonly
placeholder="N/A" />
<x-forms.input id="github_app.metadata" helper="read - mandatory." label="Metadata" readonly
placeholder="N/A" />
{{-- <x-forms.input id="github_app.administration"
helper="read:write access needed to setup servers as GitHub Runner." label="Administration"
readonly placeholder="N/A" /> --}}
<x-forms.input id="github_app.pull_requests"
helper="write access needed to use deployment status update in previews."
label="Pull Request" readonly placeholder="N/A" />
</div>
</div>
2023-08-30 14:46:51 +02:00
@endif
2023-11-07 09:44:47 +01:00
</form>
2024-03-13 14:55:44 +01:00
<div class="w-full pt-10">
<div class="h-full">
<div class="flex flex-col">
<div class="flex gap-2">
<h2>Resources</h2>
</div>
<div class="pb-4 title">Here you can find all resources that are used by this source.</div>
</div>
<div class="flex flex-col">
<div class="flex flex-col">
<div class="overflow-x-auto">
<div class="inline-block min-w-full">
<div class="overflow-hidden">
<table class="min-w-full divide-y divide-coolgray-400">
<thead>
2024-03-21 12:44:32 +01:00
<tr>
2024-03-13 14:55:44 +01:00
<th class="px-5 py-3 text-xs font-medium text-left uppercase">Project
</th>
<th class="px-5 py-3 text-xs font-medium text-left uppercase">
Environment</th>
<th class="px-5 py-3 text-xs font-medium text-left uppercase">Name</th>
<th class="px-5 py-3 text-xs font-medium text-left uppercase">Type</th>
</tr>
</thead>
<tbody class="divide-y divide-coolgray-400">
@forelse ($applications->sortBy('name',SORT_NATURAL) as $resource)
<tr class="text-white bg-coolblack hover:bg-coolgray-100">
<td class="px-5 py-4 text-sm whitespace-nowrap">
{{ data_get($resource->project(), 'name') }}
</td>
<td class="px-5 py-4 text-sm whitespace-nowrap">
{{ data_get($resource, 'environment.name') }}
</td>
<td class="px-5 py-4 text-sm whitespace-nowrap"><a class=""
href="{{ $resource->link() }}">{{ $resource->name }}
<x-internal-link /></a>
</td>
<td class="px-5 py-4 text-sm whitespace-nowrap">
{{ str($resource->type())->headline() }}</td>
</tr>
@empty
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
2023-11-07 09:44:47 +01:00
@else
<div class="flex items-center gap-2 pb-4">
<h1>GitHub App</h1>
<div class="flex gap-2">
2024-03-20 12:54:06 +01:00
<x-modal-confirmation isErrorButton buttonTitle="Delete">
2024-01-31 16:14:12 +01:00
This source will be deleted. It is not reversible. <br>Please think again.
2024-03-20 12:54:06 +01:00
</x-modal-confirmation>
2023-08-30 14:46:51 +02:00
</div>
2023-11-07 09:44:47 +01:00
</div>
2024-03-20 12:54:06 +01:00
<div class="mb-10 rounded alert-error">
2023-11-07 09:44:47 +01:00
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 stroke-current shrink-0" fill="none"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg>
<span>You must complete this step before you can use this source!</span>
</div>
<div class="flex flex-col">
2024-01-25 15:26:23 +01:00
<div class="flex gap-2">
<h2>Register a GitHub App</h2>
<x-forms.button class="bg-coollabs hover:bg-coollabs-100"
x-on:click.prevent="createGithubApp('{{ $webhook_endpoint }}','{{ $preview_deployment_permissions }}',{{ $administration }})">
2024-01-25 15:26:23 +01:00
Register Now
</x-forms.button>
</div>
2023-12-07 19:06:32 +01:00
<div>You need to register a GitHub App before using this source.</div>
2023-11-07 09:44:47 +01:00
<div class="py-10">
@if (!isCloud() || isDev())
<div class="flex items-end gap-2">
2023-12-11 09:36:21 +01:00
<x-forms.select wire:model.live='webhook_endpoint' label="Webhook Endpoint"
2023-11-07 09:44:47 +01:00
helper="All Git webhooks will be sent to this endpoint. <br><br>If you would like to use domain instead of IP address, set your Coolify instance's FQDN in the Settings menu.">
@if ($ipv4)
<option value="{{ $ipv4 }}">Use {{ $ipv4 }}</option>
@endif
@if ($ipv6)
<option value="{{ $ipv6 }}">Use {{ $ipv6 }}</option>
@endif
@if ($fqdn)
<option value="{{ $fqdn }}">Use {{ $fqdn }}</option>
@endif
@if (config('app.url'))
<option value="{{ config('app.url') }}">Use {{ config('app.url') }}</option>
@endif
</x-forms.select>
2023-06-14 13:07:58 +02:00
</div>
2023-11-07 09:44:47 +01:00
@endif
<div class="flex flex-col gap-2 pt-4 w-96">
<x-forms.checkbox disabled instantSave id="default_permissions" label="Mandatory"
2023-11-07 09:44:47 +01:00
helper="Contents: read<br>Metadata: read<br>Email: read" />
<x-forms.checkbox instantSave id="preview_deployment_permissions" label="Preview Deployments "
2023-11-07 09:44:47 +01:00
helper="Necessary for updating pull requests with useful comments (deployment status, links, etc.)<br><br>Pull Request: read & write" />
{{-- <x-forms.checkbox instantSave id="administration" label="Administration (for Github Runners)"
helper="Necessary for adding Github Runners to repositories.<br><br>Administration: read & write" /> --}}
2023-06-14 13:07:58 +02:00
</div>
2023-11-07 09:44:47 +01:00
</div>
</div>
<script>
function createGithubApp(webhook_endpoint, preview_deployment_permissions, administration) {
2023-11-07 09:44:47 +01:00
const {
organization,
uuid,
html_url
} = @json($github_app);
let baseUrl = webhook_endpoint;
const name = @js($name);
const isDev = @js(config('app.env')) ===
'local';
const devWebhook = @js(config('coolify.dev_webhook'));
if (isDev && devWebhook) {
baseUrl = devWebhook;
}
const webhookBaseUrl = `${baseUrl}/webhooks`;
const path = organization ? `organizations/${organization}/settings/apps/new` : 'settings/apps/new';
const default_permissions = {
contents: 'read',
metadata: 'read',
emails: 'read',
administration: 'read'
2023-11-07 09:44:47 +01:00
};
if (preview_deployment_permissions) {
default_permissions.pull_requests = 'write';
2023-06-14 09:44:40 +02:00
}
if (administration) {
default_permissions.administration = 'write';
}
2023-11-07 09:44:47 +01:00
const data = {
name,
url: baseUrl,
hook_attributes: {
url: `${webhookBaseUrl}/source/github/events`,
active: true,
},
redirect_url: `${webhookBaseUrl}/source/github/redirect`,
callback_urls: [`${baseUrl}/login/github/app`],
public: false,
request_oauth_on_install: false,
setup_url: `${webhookBaseUrl}/source/github/install?source=${uuid}`,
setup_on_update: true,
default_permissions,
default_events: ['pull_request', 'push']
};
const form = document.createElement('form');
form.setAttribute('method', 'post');
form.setAttribute('action', `${html_url}/${path}?state=${uuid}`);
const input = document.createElement('input');
input.setAttribute('id', 'manifest');
input.setAttribute('name', 'manifest');
input.setAttribute('type', 'hidden');
input.setAttribute('value', JSON.stringify(data));
form.appendChild(input);
document.getElementsByTagName('body')[0].appendChild(form);
form.submit();
}
</script>
@endif
2023-05-08 13:36:49 +02:00
</div>