fix
This commit is contained in:
@@ -133,11 +133,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 {
|
||||||
const token = localStorage.getItem('auth_token') ||
|
const token = localStorage.getItem('auth_token') ||
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user