## 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
113 lines
2.8 KiB
PHP
113 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Ui\EnterpriseDetail;
|
|
|
|
use LogicException;
|
|
|
|
final class EnterpriseDetailBuilder
|
|
{
|
|
private ?SummaryHeaderData $header = null;
|
|
|
|
/**
|
|
* @var list<DetailSectionData>
|
|
*/
|
|
private array $mainSections = [];
|
|
|
|
/**
|
|
* @var list<SupportingCardData>
|
|
*/
|
|
private array $supportingCards = [];
|
|
|
|
/**
|
|
* @var list<TechnicalDetailData>
|
|
*/
|
|
private array $technicalSections = [];
|
|
|
|
/**
|
|
* @var list<array{title: string, description?: ?string, icon?: ?string}>
|
|
*/
|
|
private array $emptyStateNotes = [];
|
|
|
|
public function __construct(
|
|
private readonly string $resourceType,
|
|
private readonly string $scope,
|
|
) {}
|
|
|
|
public static function make(string $resourceType, string $scope): self
|
|
{
|
|
return new self($resourceType, $scope);
|
|
}
|
|
|
|
public function header(SummaryHeaderData $header): self
|
|
{
|
|
$this->header = $header;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function addSection(DetailSectionData ...$sections): self
|
|
{
|
|
foreach ($sections as $section) {
|
|
$this->mainSections[] = $section;
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function addSupportingCard(SupportingCardData ...$cards): self
|
|
{
|
|
foreach ($cards as $card) {
|
|
$this->supportingCards[] = $card;
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function addTechnicalSection(TechnicalDetailData ...$sections): self
|
|
{
|
|
foreach ($sections as $section) {
|
|
$this->technicalSections[] = $section;
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param list<array{title: string, description?: ?string, icon?: ?string}> $notes
|
|
*/
|
|
public function emptyStateNotes(array $notes): self
|
|
{
|
|
$this->emptyStateNotes = $notes;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function build(): EnterpriseDetailPageData
|
|
{
|
|
if (! $this->header instanceof SummaryHeaderData) {
|
|
throw new LogicException('Enterprise detail pages require a summary header.');
|
|
}
|
|
|
|
return new EnterpriseDetailPageData(
|
|
resourceType: $this->resourceType,
|
|
scope: $this->scope,
|
|
header: $this->header,
|
|
mainSections: array_values(array_filter(
|
|
$this->mainSections,
|
|
static fn (DetailSectionData $section): bool => $section->shouldRender(),
|
|
)),
|
|
supportingCards: array_values(array_filter(
|
|
$this->supportingCards,
|
|
static fn (SupportingCardData $card): bool => $card->shouldRender(),
|
|
)),
|
|
technicalSections: array_values(array_filter(
|
|
$this->technicalSections,
|
|
static fn (TechnicalDetailData $section): bool => $section->shouldRender(),
|
|
)),
|
|
emptyStateNotes: $this->emptyStateNotes,
|
|
);
|
|
}
|
|
}
|