persist date range selection over new endpoint selection

review comments
This commit is contained in:
Ashokaditya 2021-08-19 13:50:24 +02:00
parent b638c2df44
commit 28a859ab3a
3 changed files with 14 additions and 6 deletions

View file

@ -162,8 +162,8 @@ export interface EndpointDetailsActivityLogUpdatePaging {
disabled?: boolean;
page: number;
pageSize: number;
startDate?: string;
endDate?: string;
startDate: string;
endDate: string;
};
}

View file

@ -353,6 +353,8 @@ export const endpointListReducer: StateReducer = (state = initialEndpointPageSta
...activityLog,
paging: {
...activityLog.paging,
startDate: state.endpointDetails.activityLog.paging.startDate,
endDate: state.endpointDetails.activityLog.paging.endDate,
recentlyUsedDateRanges:
state.endpointDetails.activityLog.paging.recentlyUsedDateRanges,
},
@ -378,6 +380,8 @@ export const endpointListReducer: StateReducer = (state = initialEndpointPageSta
...activityLog,
paging: {
...activityLog.paging,
startDate: state.endpointDetails.activityLog.paging.startDate,
endDate: state.endpointDetails.activityLog.paging.endDate,
recentlyUsedDateRanges:
state.endpointDetails.activityLog.paging.recentlyUsedDateRanges,
},
@ -402,6 +406,8 @@ export const endpointListReducer: StateReducer = (state = initialEndpointPageSta
...activityLog,
paging: {
...activityLog.paging,
startDate: state.endpointDetails.activityLog.paging.startDate,
endDate: state.endpointDetails.activityLog.paging.endDate,
recentlyUsedDateRanges:
state.endpointDetails.activityLog.paging.recentlyUsedDateRanges,
},
@ -428,6 +434,8 @@ export const endpointListReducer: StateReducer = (state = initialEndpointPageSta
...activityLog,
paging: {
...activityLog.paging,
startDate: state.endpointDetails.activityLog.paging.startDate,
endDate: state.endpointDetails.activityLog.paging.endDate,
recentlyUsedDateRanges: state.endpointDetails.activityLog.paging.recentlyUsedDateRanges,
},
},

View file

@ -71,7 +71,7 @@ export const EndpointDetailsFlyoutTabs = memo(
tabs: EndpointDetailsTabs[];
}) => {
const dispatch = useDispatch<(action: EndpointAction) => void>();
const { pageSize } = useEndpointSelector(getActivityLogDataPaging);
const { pageSize, startDate, endDate } = useEndpointSelector(getActivityLogDataPaging);
const handleTabClick = useCallback(
(tab: EuiTabbedContentTab) => {
@ -82,13 +82,13 @@ export const EndpointDetailsFlyoutTabs = memo(
disabled: false,
page: 1,
pageSize,
startDate: undefined,
endDate: undefined,
startDate,
endDate,
},
});
}
},
[dispatch, pageSize]
[dispatch, pageSize, startDate, endDate]
);
const selectedTab = useMemo(() => tabs.find((tab) => tab.id === show), [tabs, show]);