refactor(system-info): reduce to Stripe-style status page
Reduce admin/system-info to a single focused status view: overall status banner, components list from existing health checks, and an environment meta table. Drops the Modules and Permissions tabs — those were dev-diagnostics already available via CLI. - Remove SystemInfoService + its test; wire the action directly to SystemHealthService and build meta inline - Extend SystemHealthService with per-check label + description so the UI speaks in customer terms while the CLI doctor path stays compatible - Rebuild the view on existing app-stats-table + app-empty-state primitives; add a small app-status-banner component for the headline signal - Align help-center nav label and i18n keys (de/en) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -36,7 +36,7 @@ class SystemHealthService
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{status: string, name: string, message: string}>
|
||||
* @return list<array{status: string, name: string, message: string, label: string, description: string}>
|
||||
*/
|
||||
public function runAll(): array
|
||||
{
|
||||
@@ -51,10 +51,13 @@ class SystemHealthService
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{status: string, name: string, message: string}
|
||||
* @return array{status: string, name: string, message: string, label: string, description: string}
|
||||
*/
|
||||
public function checkDatabase(): array
|
||||
{
|
||||
$label = 'Database';
|
||||
$okDescription = 'Connection established';
|
||||
|
||||
try {
|
||||
$ok = $this->repository->checkDatabaseConnectivity();
|
||||
|
||||
@@ -62,21 +65,27 @@ class SystemHealthService
|
||||
'status' => $ok ? 'ok' : 'fail',
|
||||
'name' => 'Database connectivity',
|
||||
'message' => $ok ? 'connection established' : 'select 1 did not return expected value',
|
||||
'label' => $label,
|
||||
'description' => $ok ? $okDescription : 'Database did not return the expected response',
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'name' => 'Database connectivity',
|
||||
'message' => 'check failed',
|
||||
'label' => $label,
|
||||
'description' => 'Database check could not be executed',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{status: string, name: string, message: string}
|
||||
* @return array{status: string, name: string, message: string, label: string, description: string}
|
||||
*/
|
||||
public function checkDatabaseSchema(): array
|
||||
{
|
||||
$label = 'Database schema';
|
||||
|
||||
try {
|
||||
$present = $this->repository->listPresentTables(self::REQUIRED_TABLES);
|
||||
sort($present, SORT_STRING);
|
||||
@@ -87,6 +96,8 @@ class SystemHealthService
|
||||
'status' => 'fail',
|
||||
'name' => 'Database schema',
|
||||
'message' => 'missing tables: ' . implode(', ', $missing),
|
||||
'label' => $label,
|
||||
'description' => 'Required core tables are missing',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -94,21 +105,27 @@ class SystemHealthService
|
||||
'status' => 'ok',
|
||||
'name' => 'Database schema',
|
||||
'message' => sprintf('%d core tables present', count(self::REQUIRED_TABLES)),
|
||||
'label' => $label,
|
||||
'description' => 'All required core tables are present',
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'name' => 'Database schema',
|
||||
'message' => 'check failed',
|
||||
'label' => $label,
|
||||
'description' => 'Schema check could not be executed',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{status: string, name: string, message: string}
|
||||
* @return array{status: string, name: string, message: string, label: string, description: string}
|
||||
*/
|
||||
public function checkStorageWriteability(): array
|
||||
{
|
||||
$label = 'Storage';
|
||||
|
||||
try {
|
||||
$storagePath = defined('APP_STORAGE_PATH') && APP_STORAGE_PATH
|
||||
? rtrim((string) APP_STORAGE_PATH, '/')
|
||||
@@ -119,6 +136,8 @@ class SystemHealthService
|
||||
'status' => 'fail',
|
||||
'name' => 'Storage writeability',
|
||||
'message' => 'storage directory not found',
|
||||
'label' => $label,
|
||||
'description' => 'Storage directory is missing',
|
||||
];
|
||||
}
|
||||
if (!is_writable($storagePath)) {
|
||||
@@ -126,6 +145,8 @@ class SystemHealthService
|
||||
'status' => 'fail',
|
||||
'name' => 'Storage writeability',
|
||||
'message' => 'storage directory not writable',
|
||||
'label' => $label,
|
||||
'description' => 'Storage directory is not writable',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -136,6 +157,8 @@ class SystemHealthService
|
||||
'status' => 'fail',
|
||||
'name' => 'Storage writeability',
|
||||
'message' => 'write probe failed',
|
||||
'label' => $label,
|
||||
'description' => 'Storage write probe failed',
|
||||
];
|
||||
}
|
||||
@unlink($probeFile);
|
||||
@@ -144,21 +167,27 @@ class SystemHealthService
|
||||
'status' => 'ok',
|
||||
'name' => 'Storage writeability',
|
||||
'message' => 'storage path is writable',
|
||||
'label' => $label,
|
||||
'description' => 'Storage path is writable',
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'name' => 'Storage writeability',
|
||||
'message' => 'check failed',
|
||||
'label' => $label,
|
||||
'description' => 'Storage check could not be executed',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{status: string, name: string, message: string}
|
||||
* @return array{status: string, name: string, message: string, label: string, description: string}
|
||||
*/
|
||||
public function checkRbacBaseline(): array
|
||||
{
|
||||
$label = 'Permissions';
|
||||
|
||||
try {
|
||||
$present = $this->repository->listActivePermissionKeys(self::REQUIRED_PERMISSIONS);
|
||||
sort($present, SORT_STRING);
|
||||
@@ -169,6 +198,8 @@ class SystemHealthService
|
||||
'status' => 'fail',
|
||||
'name' => 'RBAC baseline',
|
||||
'message' => 'missing active permissions: ' . implode(', ', $missing),
|
||||
'label' => $label,
|
||||
'description' => 'Baseline permissions are missing',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -176,21 +207,27 @@ class SystemHealthService
|
||||
'status' => 'ok',
|
||||
'name' => 'RBAC baseline',
|
||||
'message' => sprintf('%d baseline permissions active', count(self::REQUIRED_PERMISSIONS)),
|
||||
'label' => $label,
|
||||
'description' => 'Baseline permissions are present',
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'name' => 'RBAC baseline',
|
||||
'message' => 'check failed',
|
||||
'label' => $label,
|
||||
'description' => 'Permission check could not be executed',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{status: string, name: string, message: string}
|
||||
* @return array{status: string, name: string, message: string, label: string, description: string}
|
||||
*/
|
||||
public function checkAdminRoleAssignment(): array
|
||||
{
|
||||
$label = 'Administrators';
|
||||
|
||||
try {
|
||||
$count = $this->repository->countAdminUsers();
|
||||
|
||||
@@ -199,6 +236,8 @@ class SystemHealthService
|
||||
'status' => 'fail',
|
||||
'name' => 'Admin role assignment',
|
||||
'message' => 'no active user assigned to Admin/Administrator role',
|
||||
'label' => $label,
|
||||
'description' => 'No active user has the administrator role',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -206,21 +245,27 @@ class SystemHealthService
|
||||
'status' => 'ok',
|
||||
'name' => 'Admin role assignment',
|
||||
'message' => sprintf('%d admin user(s) assigned', $count),
|
||||
'label' => $label,
|
||||
'description' => 'At least one administrator is active',
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'name' => 'Admin role assignment',
|
||||
'message' => 'check failed',
|
||||
'label' => $label,
|
||||
'description' => 'Administrator check could not be executed',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{status: string, name: string, message: string}
|
||||
* @return array{status: string, name: string, message: string, label: string, description: string}
|
||||
*/
|
||||
public function checkSchedulerHeartbeat(): array
|
||||
{
|
||||
$label = 'Scheduler';
|
||||
|
||||
try {
|
||||
$status = $this->repository->getSchedulerStatus();
|
||||
|
||||
@@ -229,6 +274,8 @@ class SystemHealthService
|
||||
'status' => 'warn',
|
||||
'name' => 'Scheduler heartbeat',
|
||||
'message' => 'no scheduler runtime status row found yet',
|
||||
'label' => $label,
|
||||
'description' => 'Scheduler has not reported yet',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -241,22 +288,29 @@ class SystemHealthService
|
||||
'status' => 'warn',
|
||||
'name' => 'Scheduler heartbeat',
|
||||
'message' => 'scheduler heartbeat is empty',
|
||||
'label' => $label,
|
||||
'description' => 'Scheduler heartbeat is empty',
|
||||
];
|
||||
}
|
||||
|
||||
$seconds = max(0, time() - strtotime($heartbeat . ' UTC'));
|
||||
$detail = "last heartbeat {$seconds}s ago (result={$result}" . ($errorCode !== '' ? ", error={$errorCode}" : '') . ')';
|
||||
$stale = $seconds > self::SCHEDULER_STALE_THRESHOLD_SECONDS;
|
||||
|
||||
return [
|
||||
'status' => $seconds > self::SCHEDULER_STALE_THRESHOLD_SECONDS ? 'warn' : 'ok',
|
||||
'status' => $stale ? 'warn' : 'ok',
|
||||
'name' => 'Scheduler heartbeat',
|
||||
'message' => $detail,
|
||||
'label' => $label,
|
||||
'description' => $stale ? 'Scheduler heartbeat is outdated' : 'Scheduler is running on schedule',
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'name' => 'Scheduler heartbeat',
|
||||
'message' => 'check failed',
|
||||
'label' => $label,
|
||||
'description' => 'Scheduler check could not be executed',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user