mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-21 23:20:24 +00:00
update
This commit is contained in:
parent
733f6ca2eb
commit
4818c9d37e
10 changed files with 204 additions and 16 deletions
|
@ -21,14 +21,10 @@ class GitRepositoryResource extends Resource
|
|||
|
||||
protected static ?string $navigationIcon = 'phyre-git';
|
||||
|
||||
protected static ?string $navigationGroup = 'Hosting';
|
||||
protected static ?string $navigationGroup = 'Git';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
|
||||
$branches = [];
|
||||
$tags = [];
|
||||
|
||||
return $form
|
||||
->schema([
|
||||
|
||||
|
@ -38,13 +34,9 @@ class GitRepositoryResource extends Resource
|
|||
->columnSpanFull()
|
||||
->live()
|
||||
->afterStateUpdated(function ($state, Forms\Set $set) use (&$branches, &$tags) {
|
||||
$state = trim($state);
|
||||
|
||||
$repoDetails = GitClient::getRepoDetailsByUrl($state);
|
||||
if ($repoDetails['name']) {
|
||||
if (isset($repoDetails['name'])) {
|
||||
$set('name', $repoDetails['owner'] .'/'. $repoDetails['name']);
|
||||
$branches = $repoDetails['branches'];
|
||||
$tags = $repoDetails['tags'];
|
||||
}
|
||||
})
|
||||
->placeholder('Enter the URL of the repository'),
|
||||
|
@ -59,7 +51,13 @@ class GitRepositoryResource extends Resource
|
|||
Forms\Components\Select::make('branch')
|
||||
->label('Branch')
|
||||
->required()
|
||||
->options($branches)
|
||||
->options(function (Forms\Get $get) {
|
||||
$url = $get('url');
|
||||
$repoDetails = GitClient::getRepoDetailsByUrl($url);
|
||||
if (isset($repoDetails['name'])) {
|
||||
return $repoDetails['branches'];
|
||||
}
|
||||
})
|
||||
->live()
|
||||
->columnSpanFull()
|
||||
->placeholder('Enter the branch of the repository'),
|
||||
|
@ -67,7 +65,13 @@ class GitRepositoryResource extends Resource
|
|||
Forms\Components\Select::make('tag')
|
||||
->label('Tag')
|
||||
->live()
|
||||
->options($tags)
|
||||
->options(function (Forms\Get $get) {
|
||||
$url = $get('url');
|
||||
$repoDetails = GitClient::getRepoDetailsByUrl($url);
|
||||
if (isset($repoDetails['name'])) {
|
||||
return $repoDetails['tags'];
|
||||
}
|
||||
})
|
||||
->columnSpanFull()
|
||||
->placeholder('Enter the tag of the repository'),
|
||||
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Customer\App\Filament\Resources;
|
||||
|
||||
use App\Models\Domain;
|
||||
use App\Models\GitSshKey;
|
||||
use Modules\Customer\App\Filament\Resources\GitSshKeyResource\Pages;
|
||||
use Modules\Customer\App\Filament\Resources\GitSshKeyResource\RelationManagers;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class GitSshKeyResource extends Resource
|
||||
{
|
||||
protected static ?string $model = GitSshKey::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-key';
|
||||
|
||||
protected static ?string $navigationGroup = 'Git';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
|
||||
Forms\Components\Select::make('domain_id')
|
||||
->label('Domain')
|
||||
->options([])
|
||||
->columnSpanFull()
|
||||
->required(),
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
//
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListGitSshKeys::route('/'),
|
||||
'create' => Pages\CreateGitSshKey::route('/create'),
|
||||
'edit' => Pages\EditGitSshKey::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Customer\App\Filament\Resources\GitSshKeyResource\Pages;
|
||||
|
||||
use Modules\Customer\App\Filament\Resources\GitSshKeyResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateGitSshKey extends CreateRecord
|
||||
{
|
||||
protected static string $resource = GitSshKeyResource::class;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Customer\App\Filament\Resources\GitSshKeyResource\Pages;
|
||||
|
||||
use Modules\Customer\App\Filament\Resources\GitSshKeyResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditGitSshKey extends EditRecord
|
||||
{
|
||||
protected static string $resource = GitSshKeyResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Customer\App\Filament\Resources\GitSshKeyResource\Pages;
|
||||
|
||||
use Modules\Customer\App\Filament\Resources\GitSshKeyResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListGitSshKeys extends ListRecords
|
||||
{
|
||||
protected static string $resource = GitSshKeyResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -52,11 +52,15 @@ class CustomerPanelProvider extends PanelProvider
|
|||
->colors([
|
||||
'primary'=>$defaultColor,
|
||||
])
|
||||
->navigationGroups([
|
||||
'Hosting',
|
||||
'Git'
|
||||
])
|
||||
->discoverResources(in: module_path($this->module, 'App/Filament/Resources'), for: "$moduleNamespace\\App\\Filament\\Resources")
|
||||
->discoverPages(in: module_path($this->module, 'App/Filament/Pages'), for: "$moduleNamespace\\App\Filament\\Pages")
|
||||
->pages([
|
||||
Pages\Dashboard::class,
|
||||
])
|
||||
// ->pages([
|
||||
// Pages\Dashboard::class,
|
||||
// ])
|
||||
->discoverWidgets(in: module_path($this->module, 'App/Filament/Widgets'), for: "$moduleNamespace\\App\Filament\\Widgets")
|
||||
->widgets([
|
||||
Widgets\AccountWidget::class,
|
||||
|
|
|
@ -58,6 +58,11 @@ class GitClient
|
|||
|
||||
public static function getRepoDetailsByUrl($url)
|
||||
{
|
||||
$url = trim($url);
|
||||
|
||||
if (empty($url)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
shell_exec('GIT_TERMINAL_PROMPT=0');
|
||||
$outputBranches = shell_exec('git ls-remote --heads '.$url);
|
||||
|
|
16
web/app/Models/GitSshKey.php
Normal file
16
web/app/Models/GitSshKey.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class GitSshKey extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
|
||||
];
|
||||
}
|
|
@ -28,7 +28,6 @@ return new class extends Migration
|
|||
|
||||
$table->unsignedBigInteger('domain_id');
|
||||
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?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::create('git_ssh_keys', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->string('name');
|
||||
$table->longText('private_key');
|
||||
$table->longText('public_key');
|
||||
$table->string('passphrase')->nullable();
|
||||
$table->string('status')->nullable();
|
||||
$table->string('status_message')->nullable();
|
||||
|
||||
$table->unsignedBigInteger('domain_id');
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('git_ssh_keys');
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue