Skip to content

Commit

Permalink
fix: handled defaultTraceSelected for traces list view (SigNoz#5752)
Browse files Browse the repository at this point in the history
* fix: handled defaultTraceSelected for traces list view

* fix: added metaData id
  • Loading branch information
SagarRajput-7 authored Aug 23, 2024
1 parent bd7d14b commit 947b5bd
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions frontend/src/container/OptionsMenu/useOptionsMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { useGetAggregateKeys } from 'hooks/queryBuilder/useGetAggregateKeys';
import useDebounce from 'hooks/useDebounce';
import { useNotifications } from 'hooks/useNotifications';
import useUrlQueryData from 'hooks/useUrlQueryData';
import {
AllTraceFilterKeys,
AllTraceFilterKeyValue,
} from 'pages/TracesExplorer/Filter/filterUtils';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useQueries } from 'react-query';
import { ErrorResponse, SuccessResponse } from 'types/api';
Expand Down Expand Up @@ -111,15 +115,40 @@ const useOptionsMenu = ({
[] as BaseAutocompleteData[],
);

return (
(initialOptions.selectColumns
?.map((column) => attributesData.find(({ key }) => key === column))
.filter(Boolean) as BaseAutocompleteData[]) || []
);
let initialSelected = initialOptions.selectColumns
?.map((column) => attributesData.find(({ key }) => key === column))
.filter(Boolean) as BaseAutocompleteData[];

if (dataSource === DataSource.TRACES) {
initialSelected = initialSelected
?.map((col) => {
if (col && Object.keys(AllTraceFilterKeyValue).includes(col?.key)) {
const metaData = defaultTraceSelectedColumns.find(
(coln) => coln.key === (col.key as AllTraceFilterKeys),
);

return {
...metaData,
key: metaData?.key,
dataType: metaData?.dataType,
type: metaData?.type,
isColumn: metaData?.isColumn,
isJSON: metaData?.isJSON,
id: metaData?.id,
};
}
return col;
})
.filter(Boolean) as BaseAutocompleteData[];
}

return initialSelected || [];
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
isFetchedInitialAttributes,
initialOptions?.selectColumns,
initialAttributesResult,
dataSource,
]);

const {
Expand Down

0 comments on commit 947b5bd

Please sign in to comment.