TenantAtlas/app/Support/Navigation/RelatedActionLabelCatalog.php
ahmido b15d1950b4 feat: add cross-resource navigation cohesion (#160)
## Summary
- add a shared cross-resource navigation layer with canonical navigation context and related-context rendering
- wire findings, policy versions, baseline snapshots, backup sets, and canonical operations surfaces into consistent drill-down flows
- extend focused Pest coverage for canonical operations links, related navigation, and tenant-context preservation

## Testing
- focused Pest coverage for spec 131 was added and the task list marks the implementation verification and Pint steps as completed

## Follow-up
- manual QA checklist item `T036` in `specs/131-cross-resource-navigation/tasks.md` is still open and should be completed during review

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #160
2026-03-10 16:08:14 +00:00

62 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\Navigation;
use Illuminate\Support\Str;
final class RelatedActionLabelCatalog
{
/**
* @var array<string, string>
*/
private const ENTRY_LABELS = [
'baseline_profile' => 'Baseline profile',
'baseline_snapshot' => 'Snapshot',
'backup_set' => 'Backup set',
'current_policy_version' => 'Current policy version',
'operations' => 'Operations',
'parent_policy' => 'Policy',
'policy_version' => 'Policy version',
'restore_run' => 'Restore run',
'source_run' => 'Run',
];
/**
* @var array<string, string>
*/
private const ACTION_LABELS = [
'baseline_profile' => 'View baseline profile',
'baseline_snapshot' => 'View snapshot',
'backup_set' => 'View backup set',
'current_policy_version' => 'View policy version',
'operations' => 'Open operations',
'parent_policy' => 'View policy',
'policy_version' => 'View policy version',
'restore_run' => 'View restore run',
'source_run' => 'View run',
];
public function entryLabel(string $relationKey): string
{
return self::ENTRY_LABELS[$relationKey] ?? Str::headline(str_replace('_', ' ', $relationKey));
}
public function actionLabel(string $relationKey): string
{
return self::ACTION_LABELS[$relationKey] ?? 'Open '.Str::headline(str_replace('_', ' ', $relationKey));
}
public function unavailableMessage(string $relationKey, string $reason): string
{
$subject = mb_strtolower($this->entryLabel($relationKey));
return match ($reason) {
'missing', 'deleted' => "The related {$subject} is no longer available.",
'unauthorized' => "The related {$subject} is not available in the current scope.",
default => "The related {$subject} could not be resolved.",
};
}
}