Skip to content

Commit

Permalink
fix stringify circular ref crash and default columns on createTimeline
Browse files Browse the repository at this point in the history
  • Loading branch information
semd committed Aug 31, 2021
1 parent 0346951 commit b4eef3e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface TimelinePersistInput {
expandedDetail?: TimelineExpandedDetail;
filters?: Filter[];
columns: ColumnHeaderOptions[];
defaultColumns?: ColumnHeaderOptions[];
itemsPerPage?: number;
indexNames: string[];
kqlQuery?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type Props = OwnProps & PropsFromRedux;
const StatefulEventsViewerComponent: React.FC<Props> = ({
createTimeline,
columns,
defaultColumns,
dataProviders,
defaultCellActions,
deletedEventIds,
Expand Down Expand Up @@ -127,6 +128,7 @@ const StatefulEventsViewerComponent: React.FC<Props> = ({
createTimeline({
id,
columns,
defaultColumns,
excludedRowRendererIds,
indexNames: selectedPatterns,
sort,
Expand Down Expand Up @@ -241,6 +243,7 @@ const makeMapStateToProps = () => {
const timeline: TimelineModel = getTimeline(state, id) ?? defaultModel;
const {
columns,
defaultColumns,
dataProviders,
deletedEventIds,
excludedRowRendererIds,
Expand All @@ -254,6 +257,7 @@ const makeMapStateToProps = () => {

return {
columns,
defaultColumns,
dataProviders,
deletedEventIds,
excludedRowRendererIds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,20 @@ export const addTimelineInStorage = (
id: TimelineIdLiteral,
timeline: TimelineModel
) => {
const timelineToStore = cleanStorageTimeline(timeline);
const timelines = getAllTimelinesInStorage(storage);
storage.set(LOCAL_STORAGE_TIMELINE_KEY, {
...timelines,
[id]: timeline,
[id]: timelineToStore,
});
};

const cleanStorageTimeline = (timeline: TimelineModel) => {
// clean filterManager as it contains circular references within observer subscriptions
const { filterManager, ...timelineToStore } = timeline;
return timelineToStore;
};

export const useTimelinesStorage = (): TimelinesStorage => {
const { storage } = useKibana().services;

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/timelines/public/store/t_grid/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export type TGridModelForTimeline = Pick<
| 'excludedRowRendererIds'
| 'expandedDetail'
| 'filters'
| 'filterManager'
| 'graphEventId'
| 'kqlQuery'
| 'id'
Expand Down

0 comments on commit b4eef3e

Please sign in to comment.