## Summary - introduce a shared enterprise-detail composition layer for Filament detail pages - migrate BackupSet, BaselineSnapshot, EntraGroup, and OperationRun detail screens to the shared summary-first layout - add regression and unit coverage for section hierarchy, related context, degraded states, and duplicate fact/badge presentation ## Scope - adds shared support classes under `app/Support/Ui/EnterpriseDetail` - adds shared enterprise detail Blade partials under `resources/views/filament/infolists/entries/enterprise-detail` - updates touched Filament resources/pages to use the shared detail shell - includes Spec 133 artifacts under `specs/133-detail-page-template` ## Notes - branch: `133-detail-page-template` - base: `dev` - commit: `fd294c7` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #162
191 lines
5.5 KiB
PHP
191 lines
5.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Ui\EnterpriseDetail;
|
|
|
|
final class EnterpriseDetailSectionFactory
|
|
{
|
|
/**
|
|
* @param array{label: string, color?: string, icon?: ?string, iconColor?: ?string}|null $badge
|
|
* @return array{label: string, value: string, hint?: ?string, badge?: ?array{label: string, color?: string, icon?: ?string, iconColor?: ?string}}
|
|
*/
|
|
public function keyFact(string $label, mixed $value, ?string $hint = null, ?array $badge = null): array
|
|
{
|
|
$displayValue = match (true) {
|
|
is_bool($value) => $value ? 'Yes' : 'No',
|
|
$value === null => '—',
|
|
is_scalar($value) => trim((string) $value) !== '' ? (string) $value : '—',
|
|
default => '—',
|
|
};
|
|
|
|
return array_filter([
|
|
'label' => $label,
|
|
'value' => $displayValue,
|
|
'hint' => $hint,
|
|
'badge' => $badge,
|
|
], static fn (mixed $item): bool => $item !== null);
|
|
}
|
|
|
|
/**
|
|
* @return array{label: string, color?: string, icon?: ?string, iconColor?: ?string}
|
|
*/
|
|
public function statusBadge(string $label, string $color = 'gray', ?string $icon = null, ?string $iconColor = null): array
|
|
{
|
|
return array_filter([
|
|
'label' => $label,
|
|
'color' => $color,
|
|
'icon' => $icon,
|
|
'iconColor' => $iconColor,
|
|
], static fn (mixed $item): bool => $item !== null);
|
|
}
|
|
|
|
/**
|
|
* @return array{title: string, description?: ?string, icon?: ?string}
|
|
*/
|
|
public function emptyState(string $title, ?string $description = null, ?string $icon = null): array
|
|
{
|
|
return array_filter([
|
|
'title' => $title,
|
|
'description' => $description,
|
|
'icon' => $icon,
|
|
], static fn (mixed $item): bool => $item !== null);
|
|
}
|
|
|
|
/**
|
|
* @param list<array<string, mixed>> $items
|
|
*/
|
|
public function factsSection(
|
|
string $id,
|
|
string $kind,
|
|
string $title,
|
|
array $items,
|
|
?array $emptyState = null,
|
|
?PageActionData $action = null,
|
|
?string $description = null,
|
|
bool $visible = true,
|
|
bool $collapsible = false,
|
|
bool $collapsed = false,
|
|
): DetailSectionData {
|
|
return new DetailSectionData(
|
|
id: $id,
|
|
kind: $kind,
|
|
title: $title,
|
|
items: $items,
|
|
emptyState: $emptyState,
|
|
action: $action,
|
|
visible: $visible,
|
|
description: $description,
|
|
collapsible: $collapsible,
|
|
collapsed: $collapsed,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $viewData
|
|
*/
|
|
public function viewSection(
|
|
string $id,
|
|
string $kind,
|
|
string $title,
|
|
string $view,
|
|
array $viewData = [],
|
|
?array $emptyState = null,
|
|
?PageActionData $action = null,
|
|
?string $description = null,
|
|
bool $visible = true,
|
|
bool $collapsible = false,
|
|
bool $collapsed = false,
|
|
): DetailSectionData {
|
|
return new DetailSectionData(
|
|
id: $id,
|
|
kind: $kind,
|
|
title: $title,
|
|
emptyState: $emptyState,
|
|
action: $action,
|
|
visible: $visible,
|
|
description: $description,
|
|
view: $view,
|
|
viewData: $viewData,
|
|
collapsible: $collapsible,
|
|
collapsed: $collapsed,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param list<array<string, mixed>> $items
|
|
*/
|
|
public function supportingFactsCard(
|
|
string $kind,
|
|
string $title,
|
|
array $items,
|
|
?PageActionData $action = null,
|
|
?string $description = null,
|
|
bool $visible = true,
|
|
?array $emptyState = null,
|
|
): SupportingCardData {
|
|
return new SupportingCardData(
|
|
kind: $kind,
|
|
title: $title,
|
|
items: $items,
|
|
visible: $visible,
|
|
action: $action,
|
|
description: $description,
|
|
emptyState: $emptyState,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $viewData
|
|
*/
|
|
public function supportingViewCard(
|
|
string $kind,
|
|
string $title,
|
|
string $view,
|
|
array $viewData = [],
|
|
?PageActionData $action = null,
|
|
?string $description = null,
|
|
bool $visible = true,
|
|
?array $emptyState = null,
|
|
): SupportingCardData {
|
|
return new SupportingCardData(
|
|
kind: $kind,
|
|
title: $title,
|
|
visible: $visible,
|
|
action: $action,
|
|
description: $description,
|
|
view: $view,
|
|
viewData: $viewData,
|
|
emptyState: $emptyState,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param list<array<string, mixed>> $entries
|
|
* @param array<string, mixed> $viewData
|
|
*/
|
|
public function technicalDetail(
|
|
string $title,
|
|
array $entries = [],
|
|
?string $description = null,
|
|
?string $view = null,
|
|
array $viewData = [],
|
|
?array $emptyState = null,
|
|
bool $visible = true,
|
|
bool $collapsible = true,
|
|
bool $collapsed = true,
|
|
): TechnicalDetailData {
|
|
return new TechnicalDetailData(
|
|
title: $title,
|
|
entries: $entries,
|
|
collapsible: $collapsible,
|
|
collapsed: $collapsed,
|
|
visible: $visible,
|
|
description: $description,
|
|
view: $view,
|
|
viewData: $viewData,
|
|
emptyState: $emptyState,
|
|
);
|
|
}
|
|
}
|