import './QueryAggregation.styles.scss'; import { Tooltip } from 'antd'; import InputWithLabel from 'components/InputWithLabel/InputWithLabel'; import { PANEL_TYPES } from 'constants/queryBuilder'; import { useMemo } from 'react'; import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData'; import { DataSource } from 'types/common/queryBuilder'; import QueryAggregationSelect from './QueryAggregationSelect'; function QueryAggregationOptions({ dataSource, panelType, onAggregationIntervalChange, onChange, queryData, }: { dataSource: DataSource; panelType?: string; onAggregationIntervalChange: (value: number) => void; onChange?: (value: string) => void; queryData: IBuilderQuery; }): JSX.Element { const showAggregationInterval = useMemo(() => { // eslint-disable-next-line sonarjs/prefer-single-boolean-return if (panelType === PANEL_TYPES.VALUE) { return false; } if (dataSource === DataSource.TRACES || dataSource === DataSource.LOGS) { return !(panelType === PANEL_TYPES.TABLE || panelType === PANEL_TYPES.PIE); } return true; }, [dataSource, panelType]); const handleAggregationIntervalChange = (value: string): void => { onAggregationIntervalChange(Number(value)); }; return (
{showAggregationInterval && (
Set the time interval for aggregation
Learn about step intervals
} placement="top" >
every
)}
); } QueryAggregationOptions.defaultProps = { panelType: null, onChange: undefined, }; export default QueryAggregationOptions;