mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-23 10:26:40 +00:00
* feat: qb-suggestions base setup * chore: make the dropdown a little similar to the designs * chore: move out example queries from og and add to renderer * chore: added the handlers for example queries * chore: hide the example queries as soon as the user starts typing * feat: handle changes for cancel query * chore: remove stupid concept of option group * chore: show only first 3 items and add option to show all filters * chore: minor css changes and remove transitions * feat: integrate suggestions api and control re-renders * feat: added keyboard shortcuts for the dropdown * fix: design cleanups and touchups * fix: build issues and tests * chore: extra safety check for base64 and fix tests * fix: qs doesn't handle padding in base64 strings, added client logic * chore: some code comments * chore: some code comments * chore: increase the height of the bar when key is set * chore: address minor designs * chore: update the keyboard shortcut to cmd+/ * feat: correct the option render for logs for tooltip * chore: search bar to not loose focus on btn click * fix: update the spacing and icon for search bar * chore: address review comments
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { getAttributeSuggestions } from 'api/queryBuilder/getAttributeSuggestions';
|
|
import { QueryBuilderKeys } from 'constants/queryBuilder';
|
|
import { useMemo } from 'react';
|
|
import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
|
|
import { ErrorResponse, SuccessResponse } from 'types/api';
|
|
import {
|
|
IGetAttributeSuggestionsPayload,
|
|
IGetAttributeSuggestionsSuccessResponse,
|
|
} from 'types/api/queryBuilder/getAttributeSuggestions';
|
|
|
|
type UseGetAttributeSuggestions = (
|
|
requestData: IGetAttributeSuggestionsPayload,
|
|
options?: UseQueryOptions<
|
|
SuccessResponse<IGetAttributeSuggestionsSuccessResponse> | ErrorResponse
|
|
>,
|
|
) => UseQueryResult<
|
|
SuccessResponse<IGetAttributeSuggestionsSuccessResponse> | ErrorResponse
|
|
>;
|
|
|
|
export const useGetAttributeSuggestions: UseGetAttributeSuggestions = (
|
|
requestData,
|
|
options,
|
|
) => {
|
|
const queryKey = useMemo(() => {
|
|
if (options?.queryKey && Array.isArray(options.queryKey)) {
|
|
return [QueryBuilderKeys.GET_ATTRIBUTE_SUGGESTIONS, ...options.queryKey];
|
|
}
|
|
return [QueryBuilderKeys.GET_ATTRIBUTE_SUGGESTIONS, requestData];
|
|
}, [options?.queryKey, requestData]);
|
|
|
|
return useQuery<
|
|
SuccessResponse<IGetAttributeSuggestionsSuccessResponse> | ErrorResponse
|
|
>({
|
|
queryKey,
|
|
queryFn: () => getAttributeSuggestions(requestData),
|
|
...options,
|
|
});
|
|
};
|