TenantAtlas/apps/platform/app/Services/Inventory/DependencyTargets/DependencyTargetDto.php
ahmido 360d20e881 feat: complete workspace-first environment routing cutover (#340)
## Summary
- retire the tenant panel runtime and converge operator routing on the workspace-first admin shell
- update tenant, operations, and required-permissions navigation helpers to use canonical workspace-scoped URLs
- repair the focused feature coverage, add the Spec 280 browser smoke, and record the implementation close-out in the requirements checklist

## Validation
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/WorkspaceFoundation tests/Feature/Workspaces tests/Feature/ManagedEnvironment tests/Feature/RequiredPermissions tests/Feature/Operations tests/Feature/MonitoringOperationsTest.php`
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Browser/Spec280WorkspaceTenancyEnvironmentRoutingSmokeTest.php`
- `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent`

## Note
- `origin/platform` is not present on the remote; `platform-dev` is the clean base branch that limits this PR to the Spec 280 prep commit plus the implementation commit.

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #340
2026-05-07 21:56:14 +00:00

125 lines
3.9 KiB
PHP

<?php
namespace App\Services\Inventory\DependencyTargets;
use App\Filament\Resources\InventoryItemResource;
use App\Models\ManagedEnvironment;
class DependencyTargetDto
{
public function __construct(
public readonly string $targetLabel,
public readonly ?string $displayName,
public readonly ?string $maskedId,
public readonly bool $resolved,
public readonly ?string $linkUrl,
public readonly ?string $foundationType,
public readonly ?string $reasonUnresolved,
public readonly string $badgeText,
) {}
public static function missing(): self
{
return new self(
targetLabel: 'Missing target',
displayName: null,
maskedId: null,
resolved: false,
linkUrl: null,
foundationType: null,
reasonUnresolved: 'missing_target',
badgeText: 'Missing target',
);
}
public static function externalGroup(string $targetId): self
{
return static::externalGroupWithLabel($targetId, 'Group (external)');
}
public static function externalGroupWithLabel(string $targetId, string $label): self
{
$maskedId = static::mask($targetId);
return new self(
targetLabel: $label,
displayName: null,
maskedId: $maskedId,
resolved: false,
linkUrl: null,
foundationType: 'aad_group',
reasonUnresolved: 'external_reference',
badgeText: "{$label}: {$maskedId}",
);
}
public static function unresolvedFoundation(string $label, string $foundationType, string $targetId): self
{
$maskedId = static::mask($targetId);
return new self(
targetLabel: $label,
displayName: null,
maskedId: $maskedId,
resolved: false,
linkUrl: null,
foundationType: $foundationType,
reasonUnresolved: 'not_in_local_db',
badgeText: "{$label} (unresolved): {$maskedId}",
);
}
public static function resolvedFoundation(string $label, string $foundationType, string $targetId, string $displayName, ?int $inventoryItemId, ManagedEnvironment $tenant): self
{
$maskedId = static::mask($targetId);
$url = $inventoryItemId ? InventoryItemResource::getUrl('view', ['record' => $inventoryItemId], tenant: $tenant) : null;
return new self(
targetLabel: $label,
displayName: $displayName,
maskedId: $maskedId,
resolved: true,
linkUrl: $url,
foundationType: $foundationType,
reasonUnresolved: null,
badgeText: "{$label}: {$displayName} ({$maskedId})",
);
}
public static function externalReference(string $targetId, ?string $foundationType = null): self
{
$maskedId = static::mask($targetId);
$label = $foundationType ? "External ref ({$foundationType})" : 'External reference';
return new self(
targetLabel: $label,
displayName: null,
maskedId: $maskedId,
resolved: false,
linkUrl: null,
foundationType: $foundationType,
reasonUnresolved: 'unsupported_foundation_type',
badgeText: "{$label}: {$maskedId}",
);
}
public function toArray(): array
{
return [
'target_label' => $this->targetLabel,
'display_name' => $this->displayName,
'masked_id' => $this->maskedId,
'resolved' => $this->resolved,
'link_url' => $this->linkUrl,
'foundation_type' => $this->foundationType,
'reason_unresolved' => $this->reasonUnresolved,
'badge_text' => $this->badgeText,
];
}
private static function mask(string $id): string
{
return substr($id, 0, 6).'…';
}
}