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

View File

@@ -133,11 +133,6 @@ export default function ApiStatusIndicator() {
// Only run API checks on API monitor page to avoid console errors on other pages
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'> => {
try {
const token = localStorage.getItem('auth_token') ||
@@ -317,6 +312,11 @@ export default function ApiStatusIndicator() {
}, [checkEndpoint]);
useEffect(() => {
// Only run if aws-admin and on API monitor page
if (!isAwsAdmin || !isApiMonitorPage) {
return;
}
// Initial check
checkAllGroups();
@@ -369,7 +369,7 @@ export default function ApiStatusIndicator() {
window.removeEventListener('storage', handleStorageChange);
window.removeEventListener('api-monitor-interval-changed', handleCustomStorageChange);
};
}, [checkAllGroups]);
}, [checkAllGroups, isAwsAdmin, isApiMonitorPage]);
const getStatusColor = (isHealthy: boolean) => {
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) {
return null;
}