This commit is contained in:
Andras Bacsai
2023-06-14 11:03:54 +02:00
parent f43ca07f33
commit 767824f2f7
6 changed files with 21 additions and 10 deletions

View File

@@ -14,7 +14,6 @@ class Change extends Component
public string|null $fqdn; public string|null $fqdn;
public $parameters; public $parameters;
public GithubApp $github_app; public GithubApp $github_app;
public string $installation_url;
public string $name; public string $name;
public bool $is_system_wide; public bool $is_system_wide;

View File

@@ -2,7 +2,7 @@
use App\Models\GithubApp; use App\Models\GithubApp;
use App\Models\GitlabApp; use App\Models\GitlabApp;
use Illuminate\Support\Collection; use Illuminate\Support\Str;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Lcobucci\JWT\Encoding\ChainedFormatter; use Lcobucci\JWT\Encoding\ChainedFormatter;
use Lcobucci\JWT\Encoding\JoseEncoder; use Lcobucci\JWT\Encoding\JoseEncoder;
@@ -71,3 +71,10 @@ function git_api(GithubApp|GitlabApp $source, string $endpoint, string $method =
'data' => collect($json) 'data' => collect($json)
]; ];
} }
function get_installation_path(GithubApp $source)
{
$github = GithubApp::where('uuid', $source->uuid)->first();
$name = Str::of(Str::kebab($github->name));
$installation_path = $github->html_url === 'https://github.com' ? 'apps' : 'github-apps';
return "$github->html_url/$installation_path/$name/installations/new";
}

View File

@@ -5,15 +5,23 @@
<x-forms.button type="submit">Save</x-forms.button> <x-forms.button type="submit">Save</x-forms.button>
<a target="_blank" class="hover:no-underline" href="{{ $application?->gitBranchLocation }}"> <a target="_blank" class="hover:no-underline" href="{{ $application?->gitBranchLocation }}">
<x-forms.button> <x-forms.button>
<x-git-icon git="{{ $application->source?->getMorphClass() }}" />Open Repository on Git Open Repository
<x-external-link /> <x-external-link />
</x-forms.button> </x-forms.button>
</a> </a>
@if (!$application->source->is_public)
<a target="_blank" class="hover:no-underline" href="{{ get_installation_path($application->source) }}">
<x-forms.button>
Open Git App
<x-external-link />
</x-forms.button>
</a>
@endif
</div> </div>
<div class="text-sm">Code source of your application.</div> <div class="text-sm">Code source of your application.</div>
<x-forms.input placeholder="coollabsio/coolify-example" id="application.git_repository" label="Repository" /> <x-forms.input placeholder="coollabsio/coolify-example" id="application.git_repository" label="Repository" />
<x-forms.input placeholder="main" id="application.git_branch" label="Branch" /> <x-forms.input placeholder="main" id="application.git_branch" label="Branch" />
<div class="flex items-end gap-2 w-96"> <div class="flex items-end gap-2">
<x-forms.input placeholder="HEAD" id="application.git_commit_sha" placeholder="HEAD" label="Commit SHA" /> <x-forms.input placeholder="HEAD" id="application.git_commit_sha" placeholder="HEAD" label="Commit SHA" />
<a target="_blank" class="flex hover:no-underline" href="{{ $application?->gitCommits }}"> <a target="_blank" class="flex hover:no-underline" href="{{ $application?->gitCommits }}">
<x-forms.button><svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24" <x-forms.button><svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24"

View File

@@ -9,7 +9,7 @@
<x-forms.button x-on:click.prevent="deleteSource = true"> <x-forms.button x-on:click.prevent="deleteSource = true">
Delete Delete
</x-forms.button> </x-forms.button>
<a href="{{ $installation_url }}"> <a href="{{ get_installation_path($github_app) }}">
<x-forms.button> <x-forms.button>
@if ($github_app->installation_id) @if ($github_app->installation_id)
Update Repositories Update Repositories

View File

@@ -1,4 +1,4 @@
<x-layout> <x-layout>
<livewire:source.github.change :github_app="$github_app" :installation_url="$installation_url" :name="$name" :ipv4="$ipv4" <livewire:source.github.change :github_app="$github_app" :name="$name" :ipv4="$ipv4" :ipv6="$ipv6"
:ipv6="$ipv6" :fqdn="$fqdn" /> :fqdn="$fqdn" />
</x-layout> </x-layout>

View File

@@ -103,8 +103,6 @@ Route::middleware(['auth'])->group(function () {
$github_app = GithubApp::where('uuid', request()->github_app_uuid)->first(); $github_app = GithubApp::where('uuid', request()->github_app_uuid)->first();
$settings = InstanceSettings::get(); $settings = InstanceSettings::get();
$name = Str::of(Str::kebab($github_app->name)); $name = Str::of(Str::kebab($github_app->name));
$installation_path = $github_app->html_url === 'https://github.com' ? 'apps' : 'github-apps';
$installation_url = "$github_app->html_url/$installation_path/$name/installations/new";
if ($settings->public_ipv4) { if ($settings->public_ipv4) {
$ipv4 = 'http://' . $settings->public_ipv4 . ':' . config('app.port'); $ipv4 = 'http://' . $settings->public_ipv4 . ':' . config('app.port');
} }
@@ -117,7 +115,6 @@ Route::middleware(['auth'])->group(function () {
'ipv4' => $ipv4 ?? null, 'ipv4' => $ipv4 ?? null,
'ipv6' => $ipv6 ?? null, 'ipv6' => $ipv6 ?? null,
'fqdn' => $settings->fqdn, 'fqdn' => $settings->fqdn,
'installation_url' => $installation_url,
]); ]);
})->name('source.github.show'); })->name('source.github.show');