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

[SIEM] Changes authentications table from load more to paginated #39474

Merged
merged 37 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
38b830f
paginated table
stephmilovic Jun 18, 2019
024a3ff
more
stephmilovic Jun 18, 2019
4ef79ce
get unit tests passing
stephmilovic Jun 18, 2019
c84d712
hooked up auth table
stephmilovic Jun 18, 2019
81faa83
Merge branch 'master' into paginated-table
stephmilovic Jun 20, 2019
54d351b
auth table paginated
stephmilovic Jun 20, 2019
17d41c8
fixing types
stephmilovic Jun 21, 2019
0cad2ed
tests
stephmilovic Jun 21, 2019
91d34ef
merged master
stephmilovic Jun 21, 2019
4e41e46
fix api tests
stephmilovic Jun 21, 2019
e7c955d
readd tests
stephmilovic Jun 21, 2019
9275a47
readd tests
stephmilovic Jun 21, 2019
c8e7ede
limit paginated table to 10 items
stephmilovic Jun 27, 2019
dfae18d
Merge branch 'master' into paginated-table
stephmilovic Jun 27, 2019
fbada09
Merge branch 'master' into paginated-table
stephmilovic Jun 28, 2019
af0bea0
merge in master
stephmilovic Jul 3, 2019
8b956c4
accomodate inspect'
stephmilovic Jul 3, 2019
4ed7852
design changes
stephmilovic Jul 8, 2019
3c6152d
Merge branch 'master' of github.com:elastic/kibana into paginated-table
stephmilovic Jul 8, 2019
c154817
better types
stephmilovic Jul 8, 2019
45d8e54
more typing fixes
stephmilovic Jul 9, 2019
27f31ae
update table page to first when query updates
stephmilovic Jul 9, 2019
11ebc47
michaels css changes
stephmilovic Jul 10, 2019
490b85f
add in 10000 results limit
stephmilovic Jul 10, 2019
a4faeb0
show warning toast when too many table results
stephmilovic Jul 10, 2019
f045b69
show warning toast when too many table results
stephmilovic Jul 10, 2019
01ca59d
update snapshots
stephmilovic Jul 10, 2019
1bb9889
fix type issue
stephmilovic Jul 10, 2019
7cce848
Merge branch 'master' into paginated-table
stephmilovic Jul 10, 2019
8447aaf
better limiting
stephmilovic Jul 10, 2019
f00352a
add test for limit
stephmilovic Jul 10, 2019
4141bca
rm styles affecting block lvl elms
MichaelMarcialis Jul 10, 2019
a6cc894
correct weird rendering of css
MichaelMarcialis Jul 10, 2019
1f7a4cd
Merge remote-tracking branch 'MichaelMarcialis/paginated-table' into …
stephmilovic Jul 10, 2019
98ba369
fix css
stephmilovic Jul 10, 2019
6c2ac14
refactor props usage in styles, per xavier
MichaelMarcialis Jul 11, 2019
62d5367
get rid of results selector when totalCount is less than results
stephmilovic Jul 11, 2019
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
Empty file removed plugins/.empty
Empty file.
16 changes: 16 additions & 0 deletions x-pack/legacy/plugins/siem/common/graphql/shared/schema.gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ export const sharedSchema = gql`
tiebreaker: String
}

input PaginationInputPaginated {
"The activePage parameter defines the page of results you want to fetch"
activePage: Float!
"The cursorStart parameter defines the start of the results to be displayed"
cursorStart: Float!
"The fakePossibleCount parameter determines the total count in order to show 5 additional pages"
fakePossibleCount: Float!
"The querySize parameter is the number of items to be returned"
querySize: Float!
}

enum Direction {
asc
desc
Expand All @@ -56,4 +67,9 @@ export const sharedSchema = gql`
endCursor: CursorType
hasNextPage: Boolean
}

type PageInfoPaginated {
activePage: Float!
fakeTotalCount: Float!
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe('AddToKql Component', async () => {
expect(store.getState().hosts.page).toEqual({
queries: {
authentications: {
activePage: 0,
limit: 10,
},
hosts: {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as i18n from './translations';
import { AuthenticationTable, getAuthenticationColumnsCurated } from '.';

describe('Authentication Table Component', () => {
const loadMore = jest.fn();
const loadPage = jest.fn();
const state: State = mockGlobalState;

let store = createStore(state, apolloClientObservable);
Expand All @@ -34,12 +34,11 @@ describe('Authentication Table Component', () => {
const wrapper = shallow(
<ReduxStoreProvider store={store}>
<AuthenticationTable
loading={false}
data={mockData.Authentications.edges}
fakeTotalCount={getOr(50, 'fakeTotalCount', mockData.Authentications.pageInfo)!}
loading={false}
loadPage={loadPage}
totalCount={mockData.Authentications.totalCount}
hasNextPage={getOr(false, 'hasNextPage', mockData.Authentications.pageInfo)!}
nextCursor={getOr(null, 'endCursor.value', mockData.Authentications.pageInfo)}
loadMore={loadMore}
type={hostsModel.HostsType.page}
/>
</ReduxStoreProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ import { DragEffects, DraggableWrapper } from '../../../drag_and_drop/draggable_
import { escapeDataProviderId } from '../../../drag_and_drop/helpers';
import { getEmptyTagValue } from '../../../empty_value';
import { HostDetailsLink, IPDetailsLink } from '../../../links';
import { Columns, ItemsPerRow, LoadMoreTable } from '../../../load_more_table';
import { Columns, ItemsPerRow, PaginatedTable } from '../../../paginated_table';
import { IS_OPERATOR } from '../../../timeline/data_providers/data_provider';
import { Provider } from '../../../timeline/data_providers/provider';

import * as i18n from './translations';
import { getRowItemDraggables } from '../../../tables/helpers';

const tableType = hostsModel.HostsTableType.authentications;

interface OwnProps {
data: AuthenticationsEdges[];
fakeTotalCount: number;
loading: boolean;
hasNextPage: boolean;
nextCursor: string;
loadPage: (newActivePage: number) => void;
totalCount: number;
loadMore: (cursor: string) => void;
type: hostsModel.HostsType;
}

Expand All @@ -42,6 +43,16 @@ interface AuthenticationTableReduxProps {

interface AuthenticationTableDispatchProps {
updateLimitPagination: ActionCreator<{ limit: number; hostsType: hostsModel.HostsType }>;
updateTableActivePage: ActionCreator<{
activePage: number;
hostsType: hostsModel.HostsType;
tableType: hostsModel.HostsTableType;
}>;
updateTableLimit: ActionCreator<{
limit: number;
hostsType: hostsModel.HostsType;
tableType: hostsModel.HostsTableType;
}>;
}

type AuthenticationTableProps = OwnProps &
Expand Down Expand Up @@ -69,30 +80,41 @@ const rowItems: ItemsPerRow[] = [

const AuthenticationTableComponent = pure<AuthenticationTableProps>(
({
fakeTotalCount,
data,
hasNextPage,
limit,
loading,
loadMore,
loadPage,
totalCount,
nextCursor,
updateLimitPagination,
type,
updateTableActivePage,
updateTableLimit,
}) => (
<LoadMoreTable
<PaginatedTable
columns={getAuthenticationColumnsCurated(type)}
hasNextPage={hasNextPage}
headerCount={totalCount}
headerTitle={i18n.AUTHENTICATIONS}
headerUnit={i18n.UNIT(totalCount)}
itemsPerRow={rowItems}
limit={limit}
loading={loading}
loadingTitle={i18n.AUTHENTICATIONS}
loadMore={() => loadMore(nextCursor)}
loadPage={newActivePage => loadPage(newActivePage)}
pageOfItems={data}
totalCount={fakeTotalCount}
updateLimitPagination={newLimit =>
updateLimitPagination({ limit: newLimit, hostsType: type })
updateTableLimit({
hostsType: type,
limit: newLimit,
tableType,
})
}
updateActivePage={newPage =>
updateTableActivePage({
activePage: newPage,
hostsType: type,
tableType,
})
}
/>
)
Expand All @@ -109,6 +131,8 @@ export const AuthenticationTable = connect(
makeMapStateToProps,
{
updateLimitPagination: hostsActions.updateAuthenticationsLimit,
updateTableActivePage: hostsActions.updateTableActivePage,
updateTableLimit: hostsActions.updateTableLimit,
}
)(AuthenticationTableComponent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AuthenticationsData } from '../../../../graphql/types';

export const mockData: { Authentications: AuthenticationsData } = {
Authentications: {
totalCount: 4,
totalCount: 54,
edges: [
{
node: {
Expand Down Expand Up @@ -74,10 +74,8 @@ export const mockData: { Authentications: AuthenticationsData } = {
},
],
pageInfo: {
endCursor: {
value: 'aa7ca589f1b8220002f2fc61c64cfbf1',
},
hasNextPage: true,
activePage: 1,
fakeTotalCount: 50,
},
},
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { generateTablePaginationOptions } from './helpers';

describe('generateTablePaginationOptions pagination helper function', () => {
let activePage;
let limit;
test('generates 5 pages when activePage 0', () => {
activePage = 0;
limit = 10;
const result = generateTablePaginationOptions(activePage, limit);
expect(result).toEqual({
activePage,
cursorStart: 0,
fakePossibleCount: 50,
querySize: 10,
});
});
test('generates 6 pages when activePage 4', () => {
activePage = 4;
limit = 10;
const result = generateTablePaginationOptions(activePage, limit);
expect(result).toEqual({
activePage,
cursorStart: 40,
fakePossibleCount: 60,
querySize: 50,
});
});
test('generates 5 pages when activePage 2', () => {
activePage = 2;
limit = 10;
const result = generateTablePaginationOptions(activePage, limit);
expect(result).toEqual({
activePage,
cursorStart: 20,
fakePossibleCount: 50,
querySize: 30,
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { PaginationInputPaginated } from '../../graphql/types';

export const generateTablePaginationOptions = (
activePage: number,
limit: number
): PaginationInputPaginated => {
const cursorStart = activePage * limit;
return {
activePage,
cursorStart,
fakePossibleCount: 4 <= activePage && activePage > 0 ? limit * (activePage + 2) : limit * 5,
querySize: limit + cursorStart,
};
};
Loading