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

181 lines
9.4 KiB
PHP
Raw Normal View History

2023-07-28 11:31:47 +00:00
<div>
<x-modal yesOrNo modalId="deleteSource" modalTitle="Delete Source">
<x-slot:modalBody>
<p>This source will be deleted. It is not reversible. <br>Please think again.</p>
</x-slot:modalBody>
</x-modal>
2023-05-08 11:36:49 +00:00
<form wire:submit.prevent='submit'>
2023-05-18 11:26:35 +00:00
<div class="flex items-center gap-2">
<h1>GitHub App</h1>
2023-06-12 20:02:10 +00:00
<div class="flex gap-2">
2023-05-18 11:26:35 +00:00
@if ($github_app->app_id)
2023-05-25 12:05:44 +00:00
<x-forms.button type="submit">Save</x-forms.button>
2023-06-14 09:03:54 +00:00
<a href="{{ get_installation_path($github_app) }}">
2023-05-25 12:05:44 +00:00
<x-forms.button>
2023-05-18 11:26:35 +00:00
@if ($github_app->installation_id)
Update Repositories
2023-08-11 18:19:42 +00:00
<x-external-link />
2023-05-18 11:26:35 +00:00
@else
Install Repositories
2023-08-11 18:19:42 +00:00
<x-external-link />
2023-05-18 11:26:35 +00:00
@endif
2023-05-25 12:05:44 +00:00
</x-forms.button>
2023-05-18 11:26:35 +00:00
</a>
@else
2023-05-25 12:05:44 +00:00
<x-forms.button disabled type="submit">Save</x-forms.button>
2023-05-18 11:26:35 +00:00
@endif
2023-07-28 11:31:47 +00:00
<x-forms.button isError isModal modalId="deleteSource">
Delete
</x-forms.button>
2023-05-18 11:26:35 +00:00
</div>
</div>
2023-06-16 10:35:40 +00:00
<div class="pt-2 pb-10 ">Your Private GitHub App for private repositories.</div>
2023-05-08 11:36:49 +00:00
@if ($github_app->app_id)
2023-07-04 11:08:27 +00:00
<div class="w-48">
2023-07-13 11:16:24 +00:00
<x-forms.checkbox label="System Wide?"
2023-08-11 18:19:42 +00:00
helper="If checked, this GitHub App will be available for everyone in this Coolify instance."
instantSave id="is_system_wide" />
2023-07-04 11:08:27 +00:00
</div>
2023-06-14 07:44:40 +00:00
<div class="flex gap-2">
2023-08-11 18:19:42 +00:00
<x-forms.input id="github_app.name" label="App Name" disabled />
2023-06-14 07:44:40 +00:00
<x-forms.input id="github_app.organization" label="Organization" disabled
2023-08-11 18:19:42 +00:00
placeholder="If empty, personal user will be used" />
2023-06-14 07:44:40 +00:00
</div>
<div class="flex gap-2">
2023-08-11 18:19:42 +00:00
<x-forms.input id="github_app.html_url" label="HTML Url" disabled />
<x-forms.input id="github_app.api_url" label="API Url" disabled />
2023-06-14 07:44:40 +00:00
</div>
<div class="flex gap-2">
@if ($github_app->html_url === 'https://github.com')
2023-08-11 18:19:42 +00:00
<x-forms.input id="github_app.custom_user" label="User" disabled />
<x-forms.input type="number" id="github_app.custom_port" label="Port" disabled />
2023-06-14 07:44:40 +00:00
@else
2023-08-11 18:19:42 +00:00
<x-forms.input id="github_app.custom_user" label="User" required />
<x-forms.input type="number" id="github_app.custom_port" label="Port" required />
2023-06-14 07:44:40 +00:00
@endif
</div>
2023-06-12 20:02:10 +00:00
<div class="flex gap-2">
2023-08-11 18:19:42 +00:00
<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 />
2023-06-12 20:02:10 +00:00
</div>
<div class="flex gap-2">
2023-08-11 18:19:42 +00:00
<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" />
2023-05-08 11:36:49 +00:00
</div>
2023-06-12 20:02:10 +00:00
@else
2023-06-14 11:07:58 +00:00
<form class="flex gap-4">
<div class="flex items-end gap-2">
<h3>Register a GitHub App</h3>
<x-forms.button
x-on:click.prevent="createGithubApp('{{ $webhook_endpoint }}','{{ $preview_deployment_permissions }}')">
Register a
GitHub
2023-06-14 07:44:40 +00:00
Application
</x-forms.button>
2023-06-14 11:07:58 +00:00
</div>
2023-06-16 10:35:40 +00:00
<div class="pt-1 pb-2 ">You need to register a GitHub App before using this source.</div>
2023-06-14 11:07:58 +00:00
<div class="pt-2 pb-10">
<div class="flex items-end gap-2">
<x-forms.select wire:model='webhook_endpoint' label="Webhook Endpoint"
2023-08-11 18:19:42 +00: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.">
2023-06-14 11:07:58 +00:00
@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
</x-forms.select>
</div>
<div class="flex flex-col gap-2 pt-4">
<x-forms.checkbox disabled instantSave id="default_permissions" label="Default Permissions"
2023-08-11 18:19:42 +00:00
helper="Contents: read<br>Metadata: read<br>Email: read" />
2023-06-14 11:07:58 +00:00
<x-forms.checkbox instantSave id="preview_deployment_permissions"
2023-08-11 18:19:42 +00:00
label="Preview Deployments Permission"
helper="Necessary for updating pull requests with useful comments (deployment status, links, etc.)<br><br>Pull Request: read & write" />
2023-06-14 11:07:58 +00:00
</div>
</div>
</form>
2023-06-14 07:44:40 +00:00
<div class="flex gap-2">
2023-08-11 18:19:42 +00:00
<x-forms.input id="github_app.name" label="App Name" disabled />
2023-06-14 07:44:40 +00:00
<x-forms.input id="github_app.organization" label="Organization"
2023-08-11 18:19:42 +00:00
placeholder="If empty, personal user will be used" disabled />
2023-06-14 07:44:40 +00:00
</div>
<div class="flex gap-2">
2023-08-11 18:19:42 +00:00
<x-forms.input id="github_app.html_url" label="HTML Url" disabled />
<x-forms.input id="github_app.api_url" label="API Url" disabled />
2023-06-14 07:44:40 +00:00
</div>
<div class="flex gap-2">
@if ($github_app->html_url === 'https://github.com')
2023-08-11 18:19:42 +00:00
<x-forms.input id="github_app.custom_user" label="User" disabled />
<x-forms.input type="number" id="github_app.custom_port" label="Port" disabled />
2023-06-14 07:44:40 +00:00
@else
2023-08-11 18:19:42 +00:00
<x-forms.input id="github_app.custom_user" label="User" required />
<x-forms.input type="number" id="github_app.custom_port" label="Port" required />
2023-06-14 07:44:40 +00:00
@endif
</div>
2023-06-12 20:02:10 +00:00
<x-forms.checkbox
2023-07-13 11:16:24 +00:00
helper="If checked, this GitHub App will be available for everyone in this Coolify instance."
2023-08-11 18:19:42 +00:00
label="System Wide?" disabled id="is_system_wide" />
2023-06-14 07:44:40 +00:00
<script>
2023-06-14 11:07:58 +00:00
function createGithubApp(webhook_endpoint, preview_deployment_permissions) {
2023-06-14 07:44:40 +00:00
const {
organization,
uuid,
html_url
} = @json($github_app);
let baseUrl = webhook_endpoint;
const name = @js($name);
const isDev = @js(config('app.env')) ===
2023-08-11 18:19:42 +00:00
'local';
2023-06-14 07:44:40 +00:00
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';
2023-06-14 11:07:58 +00:00
const default_permissions = {
contents: 'read',
metadata: 'read',
emails: 'read'
};
if (preview_deployment_permissions) {
default_permissions.pull_requests = 'write';
}
2023-06-14 07:44:40 +00: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,
2023-06-14 11:07:58 +00:00
default_permissions,
2023-06-14 07:44:40 +00:00
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>
2023-05-08 11:36:49 +00:00
@endif
</form>
</div>