(Admin) UI Consistency (#824)

* update phpdocs

* replace deprecated $label and $pluralLabel

* update record title attributes and labels

* update create pages

* run pint
This commit is contained in:
Boy132 2024-12-12 18:26:37 +01:00 committed by GitHub
parent 771eece01e
commit d43b99792f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 92 additions and 25 deletions

View File

@ -5,13 +5,16 @@ namespace App\Filament\Admin\Resources;
use App\Filament\Admin\Resources\ApiKeyResource\Pages;
use App\Models\ApiKey;
use Filament\Resources\Resource;
use Illuminate\Database\Eloquent\Model;
class ApiKeyResource extends Resource
{
protected static ?string $model = ApiKey::class;
protected static ?string $label = 'API Key';
protected static ?string $modelLabel = 'Application API Key';
protected static ?string $pluralModelLabel = 'Application API Keys';
protected static ?string $navigationLabel = 'API Keys';
protected static ?string $navigationIcon = 'tabler-key';
@ -22,11 +25,6 @@ class ApiKeyResource extends Resource
return static::getModel()::where('key_type', ApiKey::TYPE_APPLICATION)->count() ?: null;
}
public static function canEdit(Model $record): bool
{
return false;
}
public static function getPages(): array
{
return [

View File

@ -17,7 +17,19 @@ class CreateApiKey extends CreateRecord
{
protected static string $resource = ApiKeyResource::class;
protected ?string $heading = 'Create Application API Key';
protected static bool $canCreateAnother = false;
protected function getHeaderActions(): array
{
return [
$this->getCreateFormAction()->formId('form'),
];
}
protected function getFormActions(): array
{
return [];
}
public function form(Form $form): Form
{

View File

@ -10,12 +10,12 @@ class DatabaseHostResource extends Resource
{
protected static ?string $model = DatabaseHost::class;
protected static ?string $label = 'Database Host';
protected static ?string $navigationIcon = 'tabler-database';
protected static ?string $navigationGroup = 'Advanced';
protected static ?string $recordTitleAttribute = 'name';
public static function getNavigationBadge(): ?string
{
return static::getModel()::count() ?: null;

View File

@ -17,15 +17,11 @@ use PDOException;
class CreateDatabaseHost extends CreateRecord
{
private HostCreationService $service;
protected static string $resource = DatabaseHostResource::class;
protected ?string $heading = 'Database Hosts';
protected static bool $canCreateAnother = false;
protected ?string $subheading = '(database servers that can have individual databases)';
private HostCreationService $service;
public function boot(HostCreationService $service): void
{

View File

@ -14,8 +14,6 @@ class EggResource extends Resource
protected static ?string $recordTitleAttribute = 'name';
protected static ?string $recordRouteKeyName = 'id';
public static function getNavigationBadge(): ?string
{
return static::getModel()::count() ?: null;

View File

@ -28,6 +28,18 @@ class CreateEgg extends CreateRecord
protected static bool $canCreateAnother = false;
protected function getHeaderActions(): array
{
return [
$this->getCreateFormAction()->formId('form'),
];
}
protected function getFormActions(): array
{
return [];
}
public function form(Form $form): Form
{
return $form

View File

@ -14,6 +14,8 @@ class MountResource extends Resource
protected static ?string $navigationGroup = 'Advanced';
protected static ?string $recordTitleAttribute = 'name';
public static function getNavigationBadge(): ?string
{
return static::getModel()::count() ?: null;

View File

@ -21,6 +21,18 @@ class CreateMount extends CreateRecord
protected static bool $canCreateAnother = false;
protected function getHeaderActions(): array
{
return [
$this->getCreateFormAction()->formId('form'),
];
}
protected function getFormActions(): array
{
return [];
}
public function form(Form $form): Form
{
return $form

View File

@ -23,8 +23,6 @@ class CreateNode extends CreateRecord
protected static bool $canCreateAnother = false;
protected ?string $subheading = 'which is a machine that runs your Servers';
public function form(Forms\Form $form): Forms\Form
{
return $form

View File

@ -14,11 +14,23 @@ use Spatie\Permission\Models\Permission;
*/
class CreateRole extends CreateRecord
{
public Collection $permissions;
protected static string $resource = RoleResource::class;
protected static bool $canCreateAnother = false;
public Collection $permissions;
protected function getHeaderActions(): array
{
return [
$this->getCreateFormAction()->formId('form'),
];
}
protected function getFormActions(): array
{
return [];
}
protected function mutateFormDataBeforeCreate(array $data): array
{

View File

@ -10,11 +10,15 @@ class WebhookResource extends Resource
{
protected static ?string $model = WebhookConfiguration::class;
protected static ?string $modelLabel = 'Webhook';
protected static ?string $pluralModelLabel = 'Webhooks';
protected static ?string $navigationIcon = 'tabler-webhook';
protected static ?string $navigationGroup = 'Advanced';
protected static ?string $label = 'Webhooks';
protected static ?string $recordTitleAttribute = 'description';
public static function getNavigationBadge(): ?string
{

View File

@ -13,6 +13,20 @@ class CreateWebhookConfiguration extends CreateRecord
{
protected static string $resource = WebhookResource::class;
protected static bool $canCreateAnother = false;
protected function getHeaderActions(): array
{
return [
$this->getCreateFormAction()->formId('form'),
];
}
protected function getFormActions(): array
{
return [];
}
public function form(Form $form): Form
{
return $form

View File

@ -17,9 +17,9 @@ class ActivityResource extends Resource
{
protected static ?string $model = ActivityLog::class;
protected static ?string $label = 'Activity';
protected static ?string $modelLabel = 'Activity';
protected static ?string $pluralLabel = 'Activity';
protected static ?string $pluralModelLabel = 'Activity';
protected static ?int $navigationSort = 8;

View File

@ -14,9 +14,9 @@ class AllocationResource extends Resource
{
protected static ?string $model = Allocation::class;
protected static ?string $label = 'Network';
protected static ?string $modelLabel = 'Network';
protected static ?string $pluralLabel = 'Network';
protected static ?string $pluralModelLabel = 'Network';
protected static ?int $navigationSort = 7;

View File

@ -16,6 +16,10 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
* @property int|null $node_id
* @property \Carbon\CarbonImmutable $created_at
* @property \Carbon\CarbonImmutable $updated_at
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\Node[] $nodes
* @property int|null $nodes_count
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\Database[] $databases
* @property int|null $databases_count
*/
class DatabaseHost extends Model
{

View File

@ -43,7 +43,9 @@ use Illuminate\Support\Str;
* @property string $inherit_file_denylist
* @property array|null $inherit_features
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\Server[] $servers
* @property int|null $servers_count
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\EggVariable[] $variables
* @property int|null $variables_count
* @property \App\Models\Egg|null $scriptFrom
* @property \App\Models\Egg|null $configFrom
*/

View File

@ -41,8 +41,11 @@ use Symfony\Component\Yaml\Yaml;
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property \App\Models\Mount[]|\Illuminate\Database\Eloquent\Collection $mounts
* @property int|null $mounts_count
* @property \App\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers
* @property int|null $servers_count
* @property \App\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations
* @property int|null $allocations_count
*/
class Node extends Model
{