Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: store columns while saving view and restore columns on selecting view without select columns #5647

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: restore the default select columns and remove OLD_SELECT_COLUMNS
  • Loading branch information
ahmadshaheer committed Sep 10, 2024
commit cfeb4d82d67a2843b165ba537a61a3936fb6308d
1 change: 0 additions & 1 deletion frontend/src/constants/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ export enum LOCALSTORAGE {
THEME_ANALYTICS_V1 = 'THEME_ANALYTICS_V1',
LAST_USED_SAVED_VIEWS = 'LAST_USED_SAVED_VIEWS',
SHOW_LOGS_QUICK_FILTERS = 'SHOW_LOGS_QUICK_FILTERS',
OLD_SELECT_COLUMNS = 'OLD_SELECT_COLUMNS',
}
24 changes: 6 additions & 18 deletions frontend/src/container/ExplorerOptions/ExplorerOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { PANEL_TYPES } from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
import ExportPanelContainer from 'container/ExportPanel/ExportPanelContainer';
import { useOptionsMenu } from 'container/OptionsMenu';
import { defaultTraceSelectedColumns } from 'container/OptionsMenu/constants';
import { OptionsQuery } from 'container/OptionsMenu/types';
import { useGetSearchQueryParam } from 'hooks/queryBuilder/useGetSearchQueryParam';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
Expand Down Expand Up @@ -275,28 +276,15 @@ function ExplorerOptions({
const extraData = JSON.parse(currentViewDetails?.extraData ?? '{}');
ahmadshaheer marked this conversation as resolved.
Show resolved Hide resolved

if (!!extraData && extraData?.selectColumns) {
ahmadshaheer marked this conversation as resolved.
Show resolved Hide resolved
localStorage.setItem(
LOCALSTORAGE.OLD_SELECT_COLUMNS,
JSON.stringify(options.selectColumns),
);

handleOptionsChange({
...options,
selectColumns: extraData.selectColumns,
});
} else {
const oldSelectColumns = JSON.parse(
localStorage.getItem(LOCALSTORAGE.OLD_SELECT_COLUMNS) ?? '{}',
);
if (
Object.keys(oldSelectColumns).length &&
!isEqual(oldSelectColumns, options.selectColumns)
) {
handleOptionsChange({
...options,
selectColumns: oldSelectColumns,
});
}
} else if (!isEqual(defaultTraceSelectedColumns, options.selectColumns)) {
handleOptionsChange({
...options,
selectColumns: defaultTraceSelectedColumns,
});
}
};

Expand Down
Loading