This commit is contained in:
IGNY8 VPS (Salman)
2025-11-16 00:25:43 +00:00
parent 7665b8c6e7
commit a42a130835

View File

@@ -132,11 +132,6 @@ export default function ApiStatusIndicator() {
// Only run API checks on API monitor page to avoid console errors on other pages // Only run API checks on API monitor page to avoid console errors on other pages
const isApiMonitorPage = location.pathname === '/settings/api-monitor'; const isApiMonitorPage = location.pathname === '/settings/api-monitor';
// Return null if not aws-admin account or not on API monitor page
if (!isAwsAdmin || !isApiMonitorPage) {
return null;
}
const checkEndpoint = useCallback(async (path: string, method: string): Promise<'healthy' | 'warning' | 'error'> => { const checkEndpoint = useCallback(async (path: string, method: string): Promise<'healthy' | 'warning' | 'error'> => {
try { try {
@@ -317,6 +312,11 @@ export default function ApiStatusIndicator() {
}, [checkEndpoint]); }, [checkEndpoint]);
useEffect(() => { useEffect(() => {
// Only run if aws-admin and on API monitor page
if (!isAwsAdmin || !isApiMonitorPage) {
return;
}
// Initial check // Initial check
checkAllGroups(); checkAllGroups();
@@ -369,7 +369,7 @@ export default function ApiStatusIndicator() {
window.removeEventListener('storage', handleStorageChange); window.removeEventListener('storage', handleStorageChange);
window.removeEventListener('api-monitor-interval-changed', handleCustomStorageChange); window.removeEventListener('api-monitor-interval-changed', handleCustomStorageChange);
}; };
}, [checkAllGroups]); }, [checkAllGroups, isAwsAdmin, isApiMonitorPage]);
const getStatusColor = (isHealthy: boolean) => { const getStatusColor = (isHealthy: boolean) => {
if (isHealthy) { if (isHealthy) {
@@ -379,6 +379,12 @@ export default function ApiStatusIndicator() {
} }
}; };
// Return null if not aws-admin account or not on API monitor page
// This check must come AFTER all hooks are called
if (!isAwsAdmin || !isApiMonitorPage) {
return null;
}
if (groupStatuses.length === 0 && !isChecking) { if (groupStatuses.length === 0 && !isChecking) {
return null; return null;
} }