Skip to content

Commit

Permalink
chore: pr review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadshaheer committed Sep 27, 2024
1 parent cfeb4d8 commit af0f393
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions frontend/src/container/ExplorerOptions/ExplorerOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import { useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
import { AppState } from 'store/reducers';
import { Dashboard } from 'types/api/dashboard/getAll';
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
import { Query } from 'types/api/queryBuilder/queryBuilderData';
import { ViewProps } from 'types/api/saveViews/types';
import { DataSource, StringOperators } from 'types/common/queryBuilder';
Expand Down Expand Up @@ -262,6 +263,10 @@ function ExplorerOptions({
aggregateOperator: StringOperators.NOOP,
});

type ExtraData = {
selectColumns?: BaseAutocompleteData[];
};

const updateOrRestoreSelectColumns = (
key: string,
allViewsData: ViewProps[] | undefined,
Expand All @@ -273,9 +278,14 @@ function ExplorerOptions({
return;
}

const extraData = JSON.parse(currentViewDetails?.extraData ?? '{}');
let extraData: ExtraData = {};
try {
extraData = JSON.parse(currentViewDetails?.extraData ?? '{}') as ExtraData;
} catch (error) {
console.error('Error parsing extraData:', error);
}

if (!!extraData && extraData?.selectColumns) {
if (extraData.selectColumns?.length) {
handleOptionsChange({
...options,
selectColumns: extraData.selectColumns,
Expand All @@ -287,7 +297,6 @@ function ExplorerOptions({
});
}
};

const onMenuItemSelectHandler = useCallback(
({ key }: { key: string }): void => {
const currentViewDetails = getViewDetailsUsingViewKey(
Expand Down

0 comments on commit af0f393

Please sign in to comment.