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 all 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.
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/siem/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export const APP_ID = 'siem';
export const APP_NAME = 'SIEM';
export const DEFAULT_INDEX_KEY = 'siem:defaultIndex';
export const DEFAULT_ANOMALY_SCORE = 'siem:defaultAnomalyScore';
export const DEFAULT_MAX_TABLE_QUERY_SIZE = 10000;
17 changes: 17 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 Down Expand Up @@ -61,4 +72,10 @@ export const sharedSchema = gql`
dsl: [String!]!
response: [String!]!
}

type PageInfoPaginated {
activePage: Float!
fakeTotalCount: Float!
showMorePagesIndicator: Boolean!
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import euiLightVars from '@elastic/eui/dist/eui_theme_light.json';
import React from 'react';
import { Sticky } from 'react-sticky';
import { pure } from 'recompose';
import styled from 'styled-components';
import styled, { css } from 'styled-components';

import { SuperDatePicker } from '../super_date_picker';

Expand All @@ -20,7 +20,7 @@ const disableSticky = 'screen and (max-width: ' + euiLightVars.euiBreakpoints.s
const disableStickyMq = window.matchMedia(disableSticky);

const Aside = styled.aside<{ isSticky?: boolean }>`
${props => `
${props => css`
position: relative;
z-index: ${props.theme.eui.euiZNavigation};
background: ${props.theme.eui.euiColorEmptyShade};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import { EuiFlexGroup, EuiFlexItem, EuiIconTip, EuiText, EuiTitle } from '@elastic/eui';
import React from 'react';
import { pure } from 'recompose';
import styled from 'styled-components';
import styled, { css } from 'styled-components';

import { InspectButton } from '../inspect';

const Header = styled.header<{ border?: boolean }>`
${props => `
${props => css`
margin-bottom: ${props.theme.eui.euiSizeL};

${props.border &&
Expand Down
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 @@ -18,7 +18,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 @@ -33,11 +33,15 @@ describe('Authentication Table Component', () => {
<ReduxStoreProvider store={store}>
<AuthenticationTable
data={mockData.Authentications.edges}
hasNextPage={getOr(false, 'hasNextPage', mockData.Authentications.pageInfo)!}
fakeTotalCount={getOr(50, 'fakeTotalCount', mockData.Authentications.pageInfo)!}
id="authentication"
loading={false}
loadMore={loadMore}
nextCursor={getOr(null, 'endCursor.value', mockData.Authentications.pageInfo)}
loadPage={loadPage}
showMorePagesIndicator={getOr(
false,
'showMorePagesIndicator',
mockData.Authentications.pageInfo
)}
totalCount={mockData.Authentications.totalCount}
type={hostsModel.HostsType.page}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ 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;
loadPage: (newActivePage: number) => void;
id: string;
hasNextPage: boolean;
nextCursor: string;
showMorePagesIndicator: boolean;
totalCount: number;
loadMore: (cursor: string) => void;
type: hostsModel.HostsType;
}

Expand All @@ -43,8 +45,30 @@ 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;
}>;
}

export declare type AuthTableColumns = [
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>
];

type AuthenticationTableProps = OwnProps &
AuthenticationTableReduxProps &
AuthenticationTableDispatchProps;
Expand All @@ -58,32 +82,24 @@ const rowItems: ItemsPerRow[] = [
text: i18n.ROWS_10,
numberOfRow: 10,
},
{
text: i18n.ROWS_20,
numberOfRow: 20,
},
{
text: i18n.ROWS_50,
numberOfRow: 50,
},
];

const AuthenticationTableComponent = pure<AuthenticationTableProps>(
({
fakeTotalCount,
data,
hasNextPage,
id,
limit,
loading,
loadMore,
loadPage,
showMorePagesIndicator,
totalCount,
nextCursor,
updateLimitPagination,
type,
updateTableActivePage,
updateTableLimit,
}) => (
<LoadMoreTable
<PaginatedTable
columns={getAuthenticationColumnsCurated(type)}
hasNextPage={hasNextPage}
headerCount={totalCount}
headerTitle={i18n.AUTHENTICATIONS}
headerUnit={i18n.UNIT(totalCount)}
Expand All @@ -92,11 +108,25 @@ const AuthenticationTableComponent = pure<AuthenticationTableProps>(
limit={limit}
loading={loading}
loadingTitle={i18n.AUTHENTICATIONS}
loadMore={() => loadMore(nextCursor)}
loadPage={newActivePage => loadPage(newActivePage)}
pageOfItems={data}
showMorePagesIndicator={showMorePagesIndicator}
totalCount={fakeTotalCount}
updateLimitPagination={newLimit =>
updateLimitPagination({ limit: newLimit, hostsType: type })
updateTableLimit({
hostsType: type,
limit: newLimit,
tableType,
})
}
updateActivePage={newPage =>
updateTableActivePage({
activePage: newPage,
hostsType: type,
tableType,
})
}
updateProps={{ totalCount }}
/>
)
);
Expand All @@ -112,20 +142,12 @@ export const AuthenticationTable = connect(
makeMapStateToProps,
{
updateLimitPagination: hostsActions.updateAuthenticationsLimit,
updateTableActivePage: hostsActions.updateTableActivePage,
updateTableLimit: hostsActions.updateTableLimit,
}
)(AuthenticationTableComponent);

const getAuthenticationColumns = (): [
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>,
Columns<AuthenticationsEdges>
] => [
const getAuthenticationColumns = (): AuthTableColumns => [
{
name: i18n.USER,
truncateText: false,
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,9 @@ export const mockData: { Authentications: AuthenticationsData } = {
},
],
pageInfo: {
endCursor: {
value: 'aa7ca589f1b8220002f2fc61c64cfbf1',
},
hasNextPage: true,
activePage: 1,
fakeTotalCount: 50,
showMorePagesIndicator: true,
},
},
};
Loading