Palash Gupta 56f1f71461
feat: tree is updated to show different node values instead of editor (#2696)
* feat: tree is updated to show different node values instead of editor

* chore: table view is updated

* [Refactoring]: Seperate title and menu to another component  (#3531)

* refactor: separated the title renderer

* refactor: separated styles

* refactor: seperate types

* refactor: instead of key showing value if array (#3532)

* refactor: instead of key showing value if array

* feat: added filter for array and also nodekey

* refactor: made common check for value is array

* refactor: changed the key to value for arrays

* chore: getData types is updated

* chore: getDataTypes function types is updated

* refactor: connection to querybuilder (#3535)

Co-authored-by: Palash Gupta <palashgdev@gmail.com>

* chore: operator is updated

* fix: build is fixed

* fix: build is fixed

* chore: operator is updated

* chore: operator is updated

* chore: parsing is updated

* chore: key is updated

* Refactor: Log parsing updates (#3542)

* refactor: updated nodekey

* refactor: removed pasred data

* refactor: parentIsArray check

* chore: added the support for the bool

* [Refactor]: handle nested object case (#3545)

* refactor: updated nodekey

* refactor: removed pasred data

* refactor: parentIsArray check

* refactor: handled nested array inside object case

* fix: float issue parsing

* chore: operator is updated

* chore: title is updated

* chore: title is updated

* fix: update tagRegexp

* fix: maintain single source of DataTypes

* chore: operator is updated

* fix: fixed due to merge conflicts

---------

Co-authored-by: Rajat Dabade <rajat@signoz.io>
Co-authored-by: Yunus A M <myounis.ar@live.com>
2023-09-15 10:21:42 +05:30

74 lines
2.0 KiB
TypeScript

import { Select, Spin } from 'antd';
import { OrderByFilterProps } from 'container/QueryBuilder/filters/OrderByFilter/OrderByFilter.interfaces';
import { useOrderByFilter } from 'container/QueryBuilder/filters/OrderByFilter/useOrderByFilter';
import { selectStyle } from 'container/QueryBuilder/filters/QueryBuilderSearch/config';
import { useGetAggregateKeys } from 'hooks/queryBuilder/useGetAggregateKeys';
import { memo, useMemo } from 'react';
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
import { StringOperators } from 'types/common/queryBuilder';
function ExplorerOrderBy({ query, onChange }: OrderByFilterProps): JSX.Element {
const {
debouncedSearchText,
selectedValue,
aggregationOptions,
generateOptions,
createOptions,
handleChange,
handleSearchKeys,
} = useOrderByFilter({ query, onChange });
const { data, isFetching } = useGetAggregateKeys(
{
aggregateAttribute: query.aggregateAttribute.key,
dataSource: query.dataSource,
aggregateOperator: query.aggregateOperator,
searchText: debouncedSearchText,
},
{
keepPreviousData: true,
},
);
const options = useMemo(() => {
const keysOptions = createOptions(data?.payload?.attributeKeys || []);
const customOptions = createOptions([
{ key: 'timestamp', isColumn: true, type: '', dataType: DataTypes.EMPTY },
]);
const baseOptions = [
...customOptions,
...(query.aggregateOperator === StringOperators.NOOP
? []
: aggregationOptions),
...keysOptions,
];
return generateOptions(baseOptions);
}, [
aggregationOptions,
createOptions,
data?.payload?.attributeKeys,
generateOptions,
query.aggregateOperator,
]);
return (
<Select
mode="tags"
style={selectStyle}
onSearch={handleSearchKeys}
showSearch
showArrow={false}
value={selectedValue}
labelInValue
options={options}
notFoundContent={isFetching ? <Spin size="small" /> : null}
onChange={handleChange}
/>
);
}
export default memo(ExplorerOrderBy);