This commit is contained in:
Andras Bacsai 2023-06-19 10:58:00 +02:00
parent 7bcbfc13b0
commit 448182497f
11 changed files with 59 additions and 17 deletions

View File

@ -12,7 +12,8 @@ class Change extends Component
protected $rules = [
'private_key.name' => 'required|string',
'private_key.description' => 'nullable|string',
'private_key.private_key' => 'required|string'
'private_key.private_key' => 'required|string',
'private_key.is_git_related' => 'nullable|boolean'
];
protected $validationAttributes = [
'private_key.name' => 'name',

View File

@ -46,6 +46,7 @@ public function instantSave()
public function test_email()
{
Notification::send($this->settings, new TestEmail);
$this->emit('success', 'Test email sent.');
}
public function submit()
{

View File

@ -9,6 +9,7 @@ class PrivateKey extends BaseModel
'name',
'description',
'private_key',
'is_git_related',
'team_id',
];
static public function ownedByCurrentTeam(array $select = ['*'])

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('private_keys', function (Blueprint $table) {
$table->boolean('is_git_related')->default(false);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('private_keys', function (Blueprint $table) {
$table->dropColumn('is_git_related');
});
}
};

View File

@ -60,7 +60,8 @@ public function run(): void
oV2PBC0CgYAXOm08kFOQA+bPBdLAte8Ga89frh6asH/Z8ucfsz9/zMMG/hhq5nF3
7TItY9Pblc2Fp805J13G96zWLX4YGyLwXXkYs+Ae7QoqjonTw7/mUDARY1Zxs9m/
a1C8EDKapCw5hAhizEFOUQKOygL8Ipn+tmEUkORYdZ8Q8cWFCv9nIw==
-----END RSA PRIVATE KEY-----"
-----END RSA PRIVATE KEY-----",
"is_git_related" => true
]);
PrivateKey::create([
"team_id" => $team_1->id,

View File

@ -15,13 +15,13 @@ .main {
@apply pl-24 pr-10 mx-auto max-w-screen-xl pt-4;
}
input {
@apply input input-sm h-7 outline-none placeholder:text-neutral-700 text-white rounded bg-coolgray-200 w-full read-only:bg-coolgray-200/50 read-only:text-opacity-25 disabled:border-none;
@apply input input-sm h-7 outline-none placeholder:text-neutral-700 text-white rounded bg-coolgray-200 w-full read-only:bg-coolgray-200/50 read-only:text-opacity-25;
}
input && :not(input[type="checkbox"]) {
@apply border-none;
:not(input[type="checkbox"]) {
@apply border-none disabled:border-none;
}
input[type="checkbox"] {
@apply toggle toggle-warning toggle-xs rounded;
@apply toggle toggle-warning toggle-xs rounded disabled:toggle-warning;
}
textarea {

View File

@ -8,7 +8,7 @@
'noDirty' => $attributes->has('noDirty'),
'disabled' => null,
])
<div {{ $attributes->merge(['class' => 'flex cursor-pointer w-96 label']) }}>
<div {{ $attributes->merge(['class' => 'flex cursor-pointer label']) }}>
<div class="flex gap-1 label-text">
@if ($label)
{{ $label }}

View File

@ -11,7 +11,7 @@
Delete
</x-forms.button>
</div>
<div class="pb-8 ">Private Key used for SSH connection</div>
<div class="pb-8">Private Key used for SSH connection</div>
<x-forms.input id="private_key.name" label="Name" required />
<x-forms.input id="private_key.description" label="Description" />
<div>
@ -26,6 +26,11 @@
Hide
</div>
</div>
@if ($private_key->is_git_related)
<div class="w-48">
<x-forms.checkbox id="private_key.is_git_related" disabled label="Is used by a Git App?" />
</div>
@endif
<div x-cloak x-show="!showPrivateKey">
<x-forms.input cannotPeakPassword type="password" rows="10" id="private_key.private_key" required
disabled />
@ -34,6 +39,5 @@
<x-forms.textarea rows="10" id="private_key.private_key" required />
</div>
</div>
</form>
</div>

View File

@ -98,11 +98,11 @@
Route::middleware(['auth'])->group(function () {
Route::get('/private-keys', fn () => view('private-key.all', [
'privateKeys' => PrivateKey::ownedByCurrentTeam(['name', 'uuid'])->get()
'privateKeys' => PrivateKey::ownedByCurrentTeam(['name', 'uuid', 'is_git_related'])->where('is_git_related', false)->get()
]))->name('private-key.all');
Route::get('/private-key/new', fn () => view('private-key.new'))->name('private-key.new');
Route::get('/private-key/{private_key_uuid}', fn () => view('private-key.show', [
'private_key' => PrivateKey::ownedByCurrentTeam(['name', 'description', 'private_key'])->whereUuid(request()->private_key_uuid)->firstOrFail()
'private_key' => PrivateKey::ownedByCurrentTeam(['name', 'description', 'private_key', 'is_git_related'])->whereUuid(request()->private_key_uuid)->firstOrFail()
]))->name('private-key.show');
});

View File

@ -27,7 +27,8 @@
$private_key = PrivateKey::create([
'name' => $slug,
'private_key' => $private_key,
'team_id' => $github_app->team_id
'team_id' => $github_app->team_id,
'is_git_related' => true,
]);
$github_app->name = $slug;
$github_app->app_id = $id;

View File

@ -44,8 +44,12 @@ function db:reset {
bash vendor/bin/spin exec -u webuser coolify php artisan migrate:fresh --seed
}
function mfs {
db:reset
function db {
bash vendor/bin/spin exec -u webuser coolify php artisan db
}
function db:migrate {
bash vendor/bin/spin exec -u webuser coolify php artisan migrate
}
function db:reset-prod {
@ -53,6 +57,10 @@ function db:reset-prod {
php artisan migrate:fresh --force --seed --seeder=ProductionSeeder
}
function mfs {
db:reset
}
function coolify {
bash vendor/bin/spin exec -u webuser coolify bash
}
@ -76,9 +84,6 @@ function tinker {
bash vendor/bin/spin exec -u webuser coolify php artisan tinker
}
function db {
bash vendor/bin/spin exec -u webuser coolify php artisan db
}
function build:builder {
act -W .github/workflows/coolify-builder.yml --secret-file .env.secrets