Implements Spec 081 provider-connection cutover. Highlights: - Adds provider connection resolution + gating for operations/verification. - Adds provider credential observer wiring. - Updates Filament tenant verify flow to block with next-steps when provider connection isn’t ready. - Adds spec docs under specs/081-provider-connection-cutover/ and extensive Spec081 test coverage. Tests: - vendor/bin/sail artisan test --compact tests/Feature/Filament/TenantSetupTest.php - Focused suites for ProviderConnections/Verification ran during implementation (see local logs). Co-authored-by: Ahmed Darrazi <ahmeddarrazi@MacBookPro.fritz.box> Reviewed-on: #98
64 lines
2.9 KiB
PHP
64 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Support\Providers;
|
|
|
|
use App\Filament\Resources\ProviderConnectionResource;
|
|
use App\Models\ProviderConnection;
|
|
use App\Models\Tenant;
|
|
use App\Support\Links\RequiredPermissionsLinks;
|
|
|
|
final class ProviderNextStepsRegistry
|
|
{
|
|
/**
|
|
* @return array<int, array{label: string, url: string}>
|
|
*/
|
|
public function forReason(Tenant $tenant, string $reasonCode, ?ProviderConnection $connection = null): array
|
|
{
|
|
return match ($reasonCode) {
|
|
ProviderReasonCodes::ProviderConnectionMissing,
|
|
ProviderReasonCodes::ProviderConnectionInvalid,
|
|
ProviderReasonCodes::TenantTargetMismatch => [
|
|
[
|
|
'label' => 'Manage Provider Connections',
|
|
'url' => ProviderConnectionResource::getUrl('index', ['tenant' => $tenant->external_id], panel: 'admin'),
|
|
],
|
|
],
|
|
ProviderReasonCodes::ProviderCredentialMissing,
|
|
ProviderReasonCodes::ProviderCredentialInvalid,
|
|
ProviderReasonCodes::ProviderAuthFailed,
|
|
ProviderReasonCodes::ProviderConsentMissing => [
|
|
[
|
|
'label' => $connection instanceof ProviderConnection ? 'Update Credentials' : 'Manage Provider Connections',
|
|
'url' => $connection instanceof ProviderConnection
|
|
? ProviderConnectionResource::getUrl('edit', ['tenant' => $tenant->external_id, 'record' => (int) $connection->getKey()], panel: 'admin')
|
|
: ProviderConnectionResource::getUrl('index', ['tenant' => $tenant->external_id], panel: 'admin'),
|
|
],
|
|
],
|
|
ProviderReasonCodes::ProviderPermissionMissing,
|
|
ProviderReasonCodes::ProviderPermissionDenied,
|
|
ProviderReasonCodes::ProviderPermissionRefreshFailed => [
|
|
[
|
|
'label' => 'Open Required Permissions',
|
|
'url' => RequiredPermissionsLinks::requiredPermissions($tenant),
|
|
],
|
|
],
|
|
ProviderReasonCodes::NetworkUnreachable,
|
|
ProviderReasonCodes::RateLimited,
|
|
ProviderReasonCodes::UnknownError => [
|
|
[
|
|
'label' => 'Review Provider Connection',
|
|
'url' => $connection instanceof ProviderConnection
|
|
? ProviderConnectionResource::getUrl('edit', ['tenant' => $tenant->external_id, 'record' => (int) $connection->getKey()], panel: 'admin')
|
|
: ProviderConnectionResource::getUrl('index', ['tenant' => $tenant->external_id], panel: 'admin'),
|
|
],
|
|
],
|
|
default => [
|
|
[
|
|
'label' => 'Manage Provider Connections',
|
|
'url' => ProviderConnectionResource::getUrl('index', ['tenant' => $tenant->external_id], panel: 'admin'),
|
|
],
|
|
],
|
|
};
|
|
}
|
|
}
|