forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENDPOINT] First version of the trusted apps list. (elastic#76304)
* First version of the trusted apps list. * Added proper visualisation of OS and Date Created columns. * Small change in naming in middleware. * Renamed function to avoid naming confusion. * Migrated to usage of selectors and memo in list component. * Added explicit return types. * Changed to use server schema for service parameter. * Removed some over generalisation in types. * Renamed types and properties related to trusted apps page state. * Renamed types and properties related to trusted apps page state. * Renamed the action type to be namespaced to trusted apps. * Merged the exports and declarations in reducer and used constants for defaults. * Memoization of pagination data structure. * Used a shared constant for REST API path. * Improvements and consistency on pagination across tabs. * Added a bit more typing and used Partial<> * Made constants readonly and added some useMemo usages. * Fixed extracting page index from URI. * Fixed the case of infinite refreshes when there is loading failure (need to rethink a bit conditions when to refresh). * Resetting state to initial when we navigate away from trusted apps list. * Fixed mapping page index to the table pagination. * Changed to using AppAction in reducer. * Made ServerApiError a default error type for data binding. * Renamed all types related to data binding to resource state. * Created index file for state types. * Fixed parameter extracting code to meet expectations of endpoints list behavior. * Updated snapshot. * Changed middleware to only use selectors. * Added tests for routing. * Added documentation to the types in async resource state module. * Added tests for async resource state module. * Added tests for store selectors. * Added tests for reducer. * Moved around imports. * Added tests for the middleware. * Added list component tests. * Removed a redundant function. * Commiting snapshots.
- Loading branch information
Showing
30 changed files
with
7,310 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
x-pack/plugins/security_solution/public/management/common/routing.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* 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 { extractListPaginationParams, getTrustedAppsListPath } from './routing'; | ||
import { MANAGEMENT_DEFAULT_PAGE, MANAGEMENT_DEFAULT_PAGE_SIZE } from './constants'; | ||
|
||
describe('routing', () => { | ||
describe('extractListPaginationParams()', () => { | ||
it('extracts default page index when not provided', () => { | ||
expect(extractListPaginationParams({}).page_index).toBe(MANAGEMENT_DEFAULT_PAGE); | ||
}); | ||
|
||
it('extracts default page index when too small value provided', () => { | ||
expect(extractListPaginationParams({ page_index: '-1' }).page_index).toBe( | ||
MANAGEMENT_DEFAULT_PAGE | ||
); | ||
}); | ||
|
||
it('extracts default page index when not a number provided', () => { | ||
expect(extractListPaginationParams({ page_index: 'a' }).page_index).toBe( | ||
MANAGEMENT_DEFAULT_PAGE | ||
); | ||
}); | ||
|
||
it('extracts only last page index when multiple values provided', () => { | ||
expect(extractListPaginationParams({ page_index: ['1', '2'] }).page_index).toBe(2); | ||
}); | ||
|
||
it('extracts proper page index when single valid value provided', () => { | ||
expect(extractListPaginationParams({ page_index: '2' }).page_index).toBe(2); | ||
}); | ||
|
||
it('extracts default page size when not provided', () => { | ||
expect(extractListPaginationParams({}).page_size).toBe(MANAGEMENT_DEFAULT_PAGE_SIZE); | ||
}); | ||
|
||
it('extracts default page size when invalid option provided', () => { | ||
expect(extractListPaginationParams({ page_size: '25' }).page_size).toBe( | ||
MANAGEMENT_DEFAULT_PAGE_SIZE | ||
); | ||
}); | ||
|
||
it('extracts default page size when not a number provided', () => { | ||
expect(extractListPaginationParams({ page_size: 'a' }).page_size).toBe( | ||
MANAGEMENT_DEFAULT_PAGE_SIZE | ||
); | ||
}); | ||
|
||
it('extracts only last page size when multiple values provided', () => { | ||
expect(extractListPaginationParams({ page_size: ['10', '20'] }).page_size).toBe(20); | ||
}); | ||
|
||
it('extracts proper page size when single valid value provided', () => { | ||
expect(extractListPaginationParams({ page_size: '20' }).page_size).toBe(20); | ||
}); | ||
}); | ||
|
||
describe('getTrustedAppsListPath()', () => { | ||
it('builds proper path when no parameters provided', () => { | ||
expect(getTrustedAppsListPath()).toEqual('/trusted_apps'); | ||
}); | ||
|
||
it('builds proper path when empty parameters provided', () => { | ||
expect(getTrustedAppsListPath({})).toEqual('/trusted_apps'); | ||
}); | ||
|
||
it('builds proper path when no page index provided', () => { | ||
expect(getTrustedAppsListPath({ page_size: 20 })).toEqual('/trusted_apps?page_size=20'); | ||
}); | ||
|
||
it('builds proper path when no page size provided', () => { | ||
expect(getTrustedAppsListPath({ page_index: 2 })).toEqual('/trusted_apps?page_index=2'); | ||
}); | ||
|
||
it('builds proper path when both page index and size provided', () => { | ||
expect(getTrustedAppsListPath({ page_index: 2, page_size: 20 })).toEqual( | ||
'/trusted_apps?page_index=2&page_size=20' | ||
); | ||
}); | ||
|
||
it('builds proper path when page index is equal to default', () => { | ||
const path = getTrustedAppsListPath({ | ||
page_index: MANAGEMENT_DEFAULT_PAGE, | ||
page_size: 20, | ||
}); | ||
|
||
expect(path).toEqual('/trusted_apps?page_size=20'); | ||
}); | ||
|
||
it('builds proper path when page size is equal to default', () => { | ||
const path = getTrustedAppsListPath({ | ||
page_index: 2, | ||
page_size: MANAGEMENT_DEFAULT_PAGE_SIZE, | ||
}); | ||
|
||
expect(path).toEqual('/trusted_apps?page_index=2'); | ||
}); | ||
|
||
it('builds proper path when both page index and size are equal to default', () => { | ||
const path = getTrustedAppsListPath({ | ||
page_index: MANAGEMENT_DEFAULT_PAGE, | ||
page_size: MANAGEMENT_DEFAULT_PAGE_SIZE, | ||
}); | ||
|
||
expect(path).toEqual('/trusted_apps'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/security_solution/public/management/pages/trusted_apps/service/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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 { HttpStart } from 'kibana/public'; | ||
import { TRUSTED_APPS_LIST_API } from '../../../../../common/endpoint/constants'; | ||
import { | ||
GetTrustedListAppsResponse, | ||
GetTrustedAppsListRequest, | ||
} from '../../../../../common/endpoint/types/trusted_apps'; | ||
|
||
export interface TrustedAppsService { | ||
getTrustedAppsList(request: GetTrustedAppsListRequest): Promise<GetTrustedListAppsResponse>; | ||
} | ||
|
||
export class TrustedAppsHttpService implements TrustedAppsService { | ||
constructor(private http: HttpStart) {} | ||
|
||
async getTrustedAppsList(request: GetTrustedAppsListRequest) { | ||
return this.http.get<GetTrustedListAppsResponse>(TRUSTED_APPS_LIST_API, { | ||
query: request, | ||
}); | ||
} | ||
} |
Oops, something went wrong.