Skip to content

Commit

Permalink
[Security Solution][Endpoint] Port trusted apps to `ArtifactlsListPag…
Browse files Browse the repository at this point in the history
…e` component (#129208)

* move validations to artifacts

fixes elastic/security-team/issues/3092

* use ArtifactsListPage

fixes elastic/security-team/issues/3092

* Remove redundant files

fixes elastic/security-team/issues/3092

* Update trusted app list ftr test

fixes elastic/security-team/issues/3092

* fix test mock

fixes elastic/security-team/issues/3092

* add trusted app form tests

fixes elastic/security-team/issues/3092

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

* default page index to 1 when set to 0

refs /pull/129099/commits/b688d505b460964117ba1a303b417760b13a2888

* add tests for new routing methods

refs /pull/129099/

* review changes

fixes elastic/security-team/issues/3092

* update fleet integration test

without any trusted app entries, it should see the trusted empty page

* update translation again after merge

refs 6a792fc

* add a test for search field KQL

review suggestions

* remove redundant flyout size

defaults to `m`

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
ashokaditya and kibanamachine authored Apr 21, 2022
1 parent cb48e11 commit ef3bd04
Show file tree
Hide file tree
Showing 73 changed files with 1,464 additions and 19,861 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { schema } from '@kbn/config-schema';
import { ConditionEntryField, OperatingSystem } from '@kbn/securitysolution-utils';
import { TrustedAppConditionEntry } from '../types';
import { getDuplicateFields, isValidHash } from '../service/trusted_apps/validations';
import { getDuplicateFields, isValidHash } from '../service/artifacts/validations';

export const DeleteTrustedAppsRequestSchema = {
params: schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { EndpointAction } from '../../management/pages/endpoint_hosts/store/action';
import { PolicyDetailsAction } from '../../management/pages/policy/store/policy_details';
import { TrustedAppsPageAction } from '../../management/pages/trusted_apps/store/action';
import { EventFiltersPageAction } from '../../management/pages/event_filters/store/action';

export { appActions } from './app';
Expand All @@ -20,5 +19,4 @@ export type AppAction =
| EndpointAction
| RoutingAction
| PolicyDetailsAction
| TrustedAppsPageAction
| EventFiltersPageAction;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { paginationFromUrlParams } from '../components/hooks/use_url_pagination'
import { EndpointIndexUIQueryParams } from '../pages/endpoint_hosts/types';
import { EventFiltersPageLocation } from '../pages/event_filters/types';
import { PolicyDetailsArtifactsPageLocation } from '../pages/policy/types';
import { TrustedAppsListPageLocation } from '../pages/trusted_apps/state';
import { AdministrationSubTab } from '../types';
import {
MANAGEMENT_DEFAULT_PAGE,
Expand Down Expand Up @@ -150,30 +149,6 @@ export const getPolicyEventFiltersPath = (
)}`;
};

const normalizeTrustedAppsPageLocation = (
location?: Partial<TrustedAppsListPageLocation>
): Partial<TrustedAppsListPageLocation> => {
if (location) {
return {
...(!isDefaultOrMissing(location.page_index, MANAGEMENT_DEFAULT_PAGE)
? { page_index: location.page_index }
: {}),
...(!isDefaultOrMissing(location.page_size, MANAGEMENT_DEFAULT_PAGE_SIZE)
? { page_size: location.page_size }
: {}),
...(!isDefaultOrMissing(location.view_type, 'grid') ? { view_type: location.view_type } : {}),
...(!isDefaultOrMissing(location.show, undefined) ? { show: location.show } : {}),
...(!isDefaultOrMissing(location.id, undefined) ? { id: location.id } : {}),
...(!isDefaultOrMissing(location.filter, '') ? { filter: location.filter } : ''),
...(!isDefaultOrMissing(location.included_policies, '')
? { included_policies: location.included_policies }
: ''),
};
} else {
return {};
}
};

const normalizePolicyDetailsArtifactsListPageLocation = (
location?: Partial<PolicyDetailsArtifactsPageLocation>
): Partial<PolicyDetailsArtifactsPageLocation> => {
Expand Down Expand Up @@ -266,31 +241,12 @@ export const extractArtifactsListPaginationParams = (query: querystring.ParsedUr
included_policies: extractIncludedPolicies(query),
});

export const extractTrustedAppsListPageLocation = (
query: querystring.ParsedUrlQuery
): TrustedAppsListPageLocation => {
const showParamValue = extractFirstParamValue(
query,
'show'
) as TrustedAppsListPageLocation['show'];

return {
...extractTrustedAppsListPaginationParams(query),
view_type: extractFirstParamValue(query, 'view_type') === 'list' ? 'list' : 'grid',
show:
showParamValue && ['edit', 'create'].includes(showParamValue) ? showParamValue : undefined,
id: extractFirstParamValue(query, 'id'),
};
};

export const getTrustedAppsListPath = (location?: Partial<TrustedAppsListPageLocation>): string => {
export const getTrustedAppsListPath = (location?: Partial<ArtifactListPageUrlParams>): string => {
const path = generatePath(MANAGEMENT_ROUTING_TRUSTED_APPS_PATH, {
tabName: AdministrationSubTab.trustedApps,
});

return `${path}${appendSearch(
querystring.stringify(normalizeTrustedAppsPageLocation(location))
)}`;
return getArtifactListPageUrlPath(path, location);
};

export const extractPolicyDetailsArtifactsListPageLocation = (
Expand Down
Loading

0 comments on commit ef3bd04

Please sign in to comment.