Skip to content

Commit 376da43

Browse files
committed
addresses comments
1 parent b41a158 commit 376da43

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/selectors.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,23 @@ export const alertListPagination = (state: AlertListState) => {
2828
* Returns a boolean based on whether or not the user is on the alerts page
2929
*/
3030
export const isOnAlertPage = (state: AlertListState): boolean => {
31-
return state.location ? state.location.pathname.endsWith('/alerts') : false;
31+
return state.location ? state.location.pathname === '/alerts' : false;
3232
};
3333

3434
/**
3535
* Returns the query object received from parsing the URL query params
3636
*/
3737
export const paginationDataFromUrl = (state: AlertListState): qs.ParsedUrlQuery => {
38-
// Removes the `?` from the beginning of query string if it exists
39-
return state.location ? qs.parse(state.location.search.slice(1)) : {};
38+
if (state.location) {
39+
// Removes the `?` from the beginning of query string if it exists
40+
const query = qs.parse(state.location.search.slice(1));
41+
return {
42+
...(query.page_size ? { page_size: query.page_size } : {}),
43+
...(query.page_index ? { page_index: query.page_index } : {}),
44+
};
45+
} else {
46+
return {};
47+
}
4048
};
4149

4250
/**

x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const AlertIndex = memo(() => {
7171
const { pageIndex, pageSize, total } = useAlertListSelector(selectors.alertListPagination);
7272
const urlFromNewPageSizeParam = useAlertListSelector(selectors.urlFromNewPageSizeParam);
7373
const urlFromNewPageIndexParam = useAlertListSelector(selectors.urlFromNewPageIndexParam);
74-
const json = useAlertListSelector(selectors.alertListData);
74+
const alertListData = useAlertListSelector(selectors.alertListData);
7575

7676
const onChangeItemsPerPage = useCallback(
7777
newPageSize => history.push(urlFromNewPageSizeParam(newPageSize)),
@@ -91,7 +91,7 @@ export const AlertIndex = memo(() => {
9191
return null;
9292
}
9393

94-
const row = json[rowIndex % pageSize];
94+
const row = alertListData[rowIndex % pageSize];
9595

9696
if (columnId === 'alert_type') {
9797
return i18n.translate(
@@ -117,13 +117,13 @@ export const AlertIndex = memo(() => {
117117
}
118118
return null;
119119
};
120-
}, [json, pageSize, total]);
120+
}, [alertListData, pageSize, total]);
121121

122122
const pagination = useMemo(() => {
123123
return {
124124
pageIndex,
125125
pageSize,
126-
pageSizeOptions: [10, 50, 100],
126+
pageSizeOptions: [10, 20, 50],
127127
onChangeItemsPerPage,
128128
onChangePage,
129129
};

0 commit comments

Comments
 (0)