signoz/frontend/src/hooks/queryBuilder/useGetExplorerQueryRange.ts

57 lines
1.8 KiB
TypeScript
Raw Normal View History

import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
import { useMemo } from 'react';
import { UseQueryOptions, UseQueryResult } from 'react-query';
import { useSelector } from 'react-redux';
import { AppState } from 'store/reducers';
import { SuccessResponse } from 'types/api';
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
import { Query } from 'types/api/queryBuilder/queryBuilderData';
import { GlobalReducer } from 'types/reducer/globalTime';
import { useGetQueryRange } from './useGetQueryRange';
import { useQueryBuilder } from './useQueryBuilder';
export const useGetExplorerQueryRange = (
requestData: Query | null,
panelType: PANEL_TYPES | null,
options?: UseQueryOptions<SuccessResponse<MetricRangePayloadProps>, Error>,
params?: Record<string, unknown>,
): UseQueryResult<SuccessResponse<MetricRangePayloadProps>, Error> => {
const { isEnabledQuery } = useQueryBuilder();
const { selectedTime: globalSelectedInterval, minTime, maxTime } = useSelector<
AppState,
GlobalReducer
>((state) => state.globalTime);
Signoz cloud onboarding v1 (#3525) * Signoz Cloud - Onboarding Flow - Getting Started page * Signoz Cloud - Onboarding Flow - Java lang setup flow * Signoz Cloud - Onboarding Flow - Wireup other lang docs for APM and create empty base component for other modules * Signoz Cloud - Onboarding Flow - remove try signoz cloud button, Update code background * Signoz Cloud - Onboarding Flow - Wire up all docs and modules * Signoz Cloud - Onboarding Flow - Integrate Intercom and other minor fixes * Signoz Cloud - Onboarding Flow - Logs Management - Update Connection Status component * Signoz Cloud - Onboarding Flow - Logs Management - Update light mode styles * Signoz Cloud - Onboarding Flow - Logs Management - Update Logs * Signoz Cloud - Update yarn.lock * Signoz Cloud - Delete Progress Steps component * Signoz Cloud - Poll for connection status, created common Header component * Signoz Cloud - Add polling to check connection status, update components to use common Header component * Signoz Cloud - Render onboarding only if feature flag is enabled * Signoz Cloud - Configure Logs Management Steps * Signoz Cloud - Update intercom snippet and set max width for onboarding flow container to 1440px * Signoz Cloud - Use andD card component for displaying modules * chore: first clean up * Signoz Cloud - Use ONBOARDING and CHAT_SUPPORT FF * Signoz Cloud - Update version check logic and fix minor css issues * fix: feature flag is updated * chore: docusaurus is removed * chore: docusaurus is removed * feat: signoz cloud - fix typecheck errors * feat: signoz cloud - enable chat support based on FF * feat: signoz cloud - fix type errors * feat: signoz cloud - fix type errors * feat: signoz cloud - update webpack config rules --------- Co-authored-by: Palash Gupta <palashgdev@gmail.com>
2023-09-12 19:20:14 +05:30
const key =
typeof options?.queryKey === 'string'
? options?.queryKey
: REACT_QUERY_KEY.GET_QUERY_RANGE;
const isEnabled = useMemo(() => {
if (!options) return isEnabledQuery;
if (typeof options.enabled === 'boolean') {
Signoz cloud onboarding v1 (#3525) * Signoz Cloud - Onboarding Flow - Getting Started page * Signoz Cloud - Onboarding Flow - Java lang setup flow * Signoz Cloud - Onboarding Flow - Wireup other lang docs for APM and create empty base component for other modules * Signoz Cloud - Onboarding Flow - remove try signoz cloud button, Update code background * Signoz Cloud - Onboarding Flow - Wire up all docs and modules * Signoz Cloud - Onboarding Flow - Integrate Intercom and other minor fixes * Signoz Cloud - Onboarding Flow - Logs Management - Update Connection Status component * Signoz Cloud - Onboarding Flow - Logs Management - Update light mode styles * Signoz Cloud - Onboarding Flow - Logs Management - Update Logs * Signoz Cloud - Update yarn.lock * Signoz Cloud - Delete Progress Steps component * Signoz Cloud - Poll for connection status, created common Header component * Signoz Cloud - Add polling to check connection status, update components to use common Header component * Signoz Cloud - Render onboarding only if feature flag is enabled * Signoz Cloud - Configure Logs Management Steps * Signoz Cloud - Update intercom snippet and set max width for onboarding flow container to 1440px * Signoz Cloud - Use andD card component for displaying modules * chore: first clean up * Signoz Cloud - Use ONBOARDING and CHAT_SUPPORT FF * Signoz Cloud - Update version check logic and fix minor css issues * fix: feature flag is updated * chore: docusaurus is removed * chore: docusaurus is removed * feat: signoz cloud - fix typecheck errors * feat: signoz cloud - enable chat support based on FF * feat: signoz cloud - fix type errors * feat: signoz cloud - fix type errors * feat: signoz cloud - update webpack config rules --------- Co-authored-by: Palash Gupta <palashgdev@gmail.com>
2023-09-12 19:20:14 +05:30
return isEnabledQuery || options.enabled;
}
return isEnabledQuery;
}, [options, isEnabledQuery]);
return useGetQueryRange(
{
graphType: panelType || PANEL_TYPES.LIST,
selectedTime: 'GLOBAL_TIME',
globalSelectedInterval,
query: requestData || initialQueriesMap.metrics,
params,
},
{
...options,
retry: false,
queryKey: [key, globalSelectedInterval, requestData, minTime, maxTime],
enabled: isEnabled,
},
);
};