Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FETCH_SCHEMA_REGISTRY_NOTIFICATION_QUERY_NAME } from '../constants';
import { FETCH_SCHEMA_REGISTRY_NOTIFICATION_QUERY } from '../queries';
import { GetSchemaRegistryNotificationResponseWithError } from '../types';
import { schemaRegsitryControlPlaneClient } from '../utils';
import globals from '../../../Globals';

type FetchSchemaRegistryNotificationResponse =
| {
Expand All @@ -21,6 +22,9 @@ type FetchSchemaRegistryNotificationResponse =
export const useGetSchemaRegistryNotificationColor = (
projectId: string
): FetchSchemaRegistryNotificationResponse => {
// Skip API calls if running in CE mode or schema registry host is not configured
const isSchemaRegistryAvailable = !!globals.schemaRegistryHost && globals.consoleType !== 'oss';

const fetchSchemaRegistyNotificationFn = (projectId: string) => {
return schemaRegsitryControlPlaneClient.query<
GetSchemaRegistryNotificationResponseWithError,
Expand All @@ -34,7 +38,17 @@ export const useGetSchemaRegistryNotificationColor = (
queryFn: () => fetchSchemaRegistyNotificationFn(projectId),
refetchOnMount: 'always',
refetchOnWindowFocus: true,
// Skip the query completely if schema registry is not available
enabled: isSchemaRegistryAvailable,
});

// Return loading state if schema registry is not available
if (!isSchemaRegistryAvailable) {
return {
kind: 'loading',
};
}

if (isLoading) {
return {
kind: 'loading',
Expand Down