source-controls (#193)

* edit source control
* assign project after creation
* global and project scoped source controls
This commit is contained in:
Saeed Vaziry
2024-05-08 00:07:11 +02:00
committed by GitHub
parent e704a13d6b
commit 179aefefac
15 changed files with 362 additions and 10 deletions

View File

@ -131,6 +131,15 @@ class="text-primary-500"
</div>
</div>
<div class="mt-6">
<x-checkbox id="global" name="global" :checked="old('global')" value="1">
Is Global (Accessible in all projects)
</x-checkbox>
@error("global")
<x-input-error class="mt-2" :messages="$message" />
@enderror
</div>
<div class="mt-6 flex justify-end">
<x-secondary-button type="button" x-on:click="$dispatch('close')">
{{ __("Cancel") }}

View File

@ -0,0 +1,130 @@
<x-modal name="edit-source-control" :show="true">
<form
id="edit-source-control-form"
hx-post="{{ route("settings.source-controls.update", ["sourceControl" => $sourceControl->id]) }}"
hx-swap="outerHTML"
hx-select="#edit-source-control-form"
hx-ext="disable-element"
hx-disable-element="#btn-edit-source-control"
class="p-6"
>
@csrf
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __("Edit Source Control") }}
</h2>
<div class="mt-6">
<x-input-label for="name" value="Name" />
<x-text-input value="{{ $sourceControl->profile }}" id="name" name="name" type="text" class="mt-1 w-full" />
@error("name")
<x-input-error class="mt-2" :messages="$message" />
@enderror
</div>
@if ($sourceControl->provider == \App\Enums\SourceControl::GITLAB)
<div class="mt-6">
<x-input-label for="url" value="Url (optional)" />
<x-text-input
value="{{ old('url', $sourceControl->url) }}"
id="url"
name="url"
type="text"
class="mt-1 w-full"
placeholder="e.g. https://gitlab.example.com/"
/>
<x-input-help>
If you run a self-managed gitlab enter the url here, leave empty to use gitlab.com
</x-input-help>
@error("url")
<x-input-error class="mt-2" :messages="$message" />
@enderror
</div>
@endif
@if (in_array($sourceControl->provider, [\App\Enums\SourceControl::GITLAB, \App\Enums\SourceControl::GITHUB]))
<div class="mt-6">
<x-input-label for="token" value="API Key" />
<x-text-input
value="{{ old('token', $sourceControl->provider()->data()['token']) }}"
id="token"
name="token"
type="text"
class="mt-1 w-full"
/>
@error("token")
<x-input-error class="mt-2" :messages="$message" />
@enderror
</div>
@endif
@if ($sourceControl->provider == \App\Enums\SourceControl::BITBUCKET)
<div>
<div class="mt-6">
<x-input-label for="username" value="Username" />
<x-text-input
value="{{ old('username', $sourceControl->provider()->data()['username']) }}"
id="username"
name="username"
type="text"
class="mt-1 w-full"
/>
<x-input-help>Your Bitbucket username</x-input-help>
@error("username")
<x-input-error class="mt-2" :messages="$message" />
@enderror
</div>
<div class="mt-6">
<x-input-label for="password" value="Password" />
<x-text-input
value="{{ old('password', $sourceControl->provider()->data()['password']) }}"
id="password"
name="password"
type="text"
class="mt-1 w-full"
/>
<x-input-help>
Create a new
<a
class="text-primary-500"
href="https://bitbucket.org/account/settings/app-passwords/new"
target="_blank"
>
App Password
</a>
in your Bitbucket account with write and admin access to Workspaces, Projects, Repositories and
Webhooks
</x-input-help>
@error("password")
<x-input-error class="mt-2" :messages="$message" />
@enderror
</div>
</div>
@endif
<div class="mt-6">
<x-checkbox
id="global"
name="global"
:checked="old('global', $sourceControl->project_id === null ? 1 : null)"
value="1"
>
Is Global (Accessible in all projects)
</x-checkbox>
@error("global")
<x-input-error class="mt-2" :messages="$message" />
@enderror
</div>
<div class="mt-6 flex justify-end">
<x-secondary-button type="button" x-on:click="$dispatch('close')">
{{ __("Cancel") }}
</x-secondary-button>
<x-primary-button id="btn-edit-source-control" class="ml-3">
{{ __("Save") }}
</x-primary-button>
</div>
</form>
</x-modal>

View File

@ -14,13 +14,26 @@
@include("settings.source-controls.partials.icons." . $sourceControl->provider . "-icon")
</div>
<div class="ml-3 flex flex-grow flex-col items-start justify-center">
<span class="mb-1">{{ $sourceControl->profile }}</span>
<div class="mb-1 flex items-center">
{{ $sourceControl->profile }}
@if (! $sourceControl->project_id)
<x-status status="disabled" class="ml-2">GLOBAL</x-status>
@endif
</div>
<span class="text-sm text-gray-400">
<x-datetime :value="$sourceControl->created_at" />
</span>
</div>
<div class="flex items-center">
<div class="inline">
<x-icon-button
hx-get="{{ route('settings.source-controls', ['edit' => $sourceControl->id]) }}"
hx-replace-url="true"
hx-select="#edit"
hx-target="#edit"
>
<x-heroicon name="o-pencil" class="h-5 w-5" />
</x-icon-button>
<x-icon-button
x-on:click="deleteAction = '{{ route('settings.source-controls.delete', $sourceControl->id) }}'; $dispatch('open-modal', 'delete-source-control')"
>
@ -32,6 +45,12 @@
@endforeach
@include("settings.source-controls.partials.delete-source-control")
<div id="edit">
@if (isset($editSourceControl))
@include("settings.source-controls.partials.edit-source-control", ["sourceControl" => $editSourceControl])
@endif
</div>
@else
<x-simple-card>
<div class="text-center">