mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Security Solutions] remove excluded_policies option from the SearchExceptions component (#122020)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
5f07a0f9c7
commit
2987654354
12 changed files with 14 additions and 61 deletions
|
@ -139,11 +139,10 @@ describe('routing', () => {
|
|||
view_type: 'list',
|
||||
filter: 'test',
|
||||
included_policies: 'globally',
|
||||
excluded_policies: 'unassigned',
|
||||
};
|
||||
|
||||
expect(getTrustedAppsListPath(location)).toEqual(
|
||||
`/administration/trusted_apps?page_index=${location.page_index}&page_size=${location.page_size}&view_type=${location.view_type}&show=${location.show}&filter=${location.filter}&included_policies=${location.included_policies}&excluded_policies=${location.excluded_policies}`
|
||||
`/administration/trusted_apps?page_index=${location.page_index}&page_size=${location.page_size}&view_type=${location.view_type}&show=${location.show}&filter=${location.filter}&included_policies=${location.included_policies}`
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -155,7 +154,6 @@ describe('routing', () => {
|
|||
view_type: 'list',
|
||||
filter: '',
|
||||
included_policies: '',
|
||||
excluded_policies: '',
|
||||
};
|
||||
const path = getTrustedAppsListPath(location);
|
||||
|
||||
|
@ -172,7 +170,6 @@ describe('routing', () => {
|
|||
view_type: 'list',
|
||||
filter: '',
|
||||
included_policies: '',
|
||||
excluded_policies: '',
|
||||
};
|
||||
const path = getTrustedAppsListPath(location);
|
||||
|
||||
|
@ -189,7 +186,6 @@ describe('routing', () => {
|
|||
view_type: 'list',
|
||||
filter: '',
|
||||
included_policies: '',
|
||||
excluded_policies: '',
|
||||
};
|
||||
const path = getTrustedAppsListPath(location);
|
||||
|
||||
|
@ -206,7 +202,6 @@ describe('routing', () => {
|
|||
view_type: 'grid',
|
||||
filter: '',
|
||||
included_policies: '',
|
||||
excluded_policies: '',
|
||||
};
|
||||
const path = getTrustedAppsListPath(location);
|
||||
|
||||
|
|
|
@ -167,9 +167,6 @@ const normalizeTrustedAppsPageLocation = (
|
|||
...(!isDefaultOrMissing(location.included_policies, '')
|
||||
? { included_policies: location.included_policies }
|
||||
: ''),
|
||||
...(!isDefaultOrMissing(location.excluded_policies, '')
|
||||
? { excluded_policies: location.excluded_policies }
|
||||
: ''),
|
||||
};
|
||||
} else {
|
||||
return {};
|
||||
|
@ -275,10 +272,6 @@ const extractIncludedPolicies = (query: querystring.ParsedUrlQuery): string => {
|
|||
return extractFirstParamValue(query, 'included_policies') || '';
|
||||
};
|
||||
|
||||
const extractExcludedPolicies = (query: querystring.ParsedUrlQuery): string => {
|
||||
return extractFirstParamValue(query, 'excluded_policies') || '';
|
||||
};
|
||||
|
||||
export const extractListPaginationParams = (query: querystring.ParsedUrlQuery) => ({
|
||||
page_index: extractPageIndex(query),
|
||||
page_size: extractPageSize(query),
|
||||
|
@ -288,7 +281,6 @@ export const extractListPaginationParams = (query: querystring.ParsedUrlQuery) =
|
|||
export const extractTrustedAppsListPaginationParams = (query: querystring.ParsedUrlQuery) => ({
|
||||
...extractListPaginationParams(query),
|
||||
included_policies: extractIncludedPolicies(query),
|
||||
excluded_policies: extractExcludedPolicies(query),
|
||||
});
|
||||
|
||||
export const extractArtifactsListPaginationParams = (query: querystring.ParsedUrlQuery) => ({
|
||||
|
|
|
@ -83,7 +83,7 @@ describe('Search exceptions', () => {
|
|||
});
|
||||
|
||||
expect(onSearchMock).toHaveBeenCalledTimes(1);
|
||||
expect(onSearchMock).toHaveBeenCalledWith(expectedDefaultValue, '', '');
|
||||
expect(onSearchMock).toHaveBeenCalledWith(expectedDefaultValue, '');
|
||||
});
|
||||
|
||||
it('should dispatch search action when click on button', () => {
|
||||
|
@ -96,7 +96,7 @@ describe('Search exceptions', () => {
|
|||
});
|
||||
|
||||
expect(onSearchMock).toHaveBeenCalledTimes(1);
|
||||
expect(onSearchMock).toHaveBeenCalledWith(expectedDefaultValue, '', '');
|
||||
expect(onSearchMock).toHaveBeenCalledWith(expectedDefaultValue, '');
|
||||
});
|
||||
|
||||
it('should hide refresh button', () => {
|
||||
|
|
|
@ -17,10 +17,9 @@ export interface SearchExceptionsProps {
|
|||
placeholder: string;
|
||||
hasPolicyFilter?: boolean;
|
||||
policyList?: ImmutableArray<PolicyData>;
|
||||
defaultExcludedPolicies?: string;
|
||||
defaultIncludedPolicies?: string;
|
||||
hideRefreshButton?: boolean;
|
||||
onSearch(query: string, includedPolicies?: string, excludedPolicies?: string): void;
|
||||
onSearch(query: string, includedPolicies?: string): void;
|
||||
}
|
||||
|
||||
export const SearchExceptions = memo<SearchExceptionsProps>(
|
||||
|
@ -31,13 +30,11 @@ export const SearchExceptions = memo<SearchExceptionsProps>(
|
|||
hasPolicyFilter,
|
||||
policyList,
|
||||
defaultIncludedPolicies,
|
||||
defaultExcludedPolicies,
|
||||
hideRefreshButton = false,
|
||||
}) => {
|
||||
const { canCreateArtifactsByPolicy } = useUserPrivileges().endpointPrivileges;
|
||||
const [query, setQuery] = useState<string>(defaultValue);
|
||||
const [includedPolicies, setIncludedPolicies] = useState<string>(defaultIncludedPolicies || '');
|
||||
const [excludedPolicies, setExcludedPolicies] = useState<string>(defaultExcludedPolicies || '');
|
||||
|
||||
const onChangeSelection = useCallback(
|
||||
(items: PolicySelectionItem[]) => {
|
||||
|
@ -45,15 +42,10 @@ export const SearchExceptions = memo<SearchExceptionsProps>(
|
|||
.filter((item) => item.checked === 'on')
|
||||
.map((item) => item.id)
|
||||
.join(',');
|
||||
const excludePoliciesNew = items
|
||||
.filter((item) => item.checked === 'off')
|
||||
.map((item) => item.id)
|
||||
.join(',');
|
||||
|
||||
setIncludedPolicies(includePoliciesNew);
|
||||
setExcludedPolicies(excludePoliciesNew);
|
||||
|
||||
onSearch(query, includePoliciesNew, excludePoliciesNew);
|
||||
onSearch(query, includePoliciesNew);
|
||||
},
|
||||
[onSearch, query]
|
||||
);
|
||||
|
@ -63,15 +55,15 @@ export const SearchExceptions = memo<SearchExceptionsProps>(
|
|||
[setQuery]
|
||||
);
|
||||
const handleOnSearch = useCallback(
|
||||
() => onSearch(query, includedPolicies, excludedPolicies),
|
||||
[onSearch, query, includedPolicies, excludedPolicies]
|
||||
() => onSearch(query, includedPolicies),
|
||||
[onSearch, query, includedPolicies]
|
||||
);
|
||||
|
||||
const handleOnSearchQuery = useCallback(
|
||||
(value) => {
|
||||
onSearch(value, includedPolicies, excludedPolicies);
|
||||
onSearch(value, includedPolicies);
|
||||
},
|
||||
[onSearch, includedPolicies, excludedPolicies]
|
||||
[onSearch, includedPolicies]
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -96,7 +88,6 @@ export const SearchExceptions = memo<SearchExceptionsProps>(
|
|||
<EuiFlexItem grow={false}>
|
||||
<PoliciesSelector
|
||||
policies={policyList}
|
||||
defaultExcludedPolicies={defaultExcludedPolicies}
|
||||
defaultIncludedPolicies={defaultIncludedPolicies}
|
||||
onChangeSelection={onChangeSelection}
|
||||
/>
|
||||
|
|
|
@ -24,7 +24,6 @@ export interface TrustedAppsListData {
|
|||
totalItemsCount: number;
|
||||
filter: string;
|
||||
includedPolicies: string;
|
||||
excludedPolicies: string;
|
||||
}
|
||||
|
||||
export type ViewType = 'list' | 'grid';
|
||||
|
@ -39,8 +38,6 @@ export interface TrustedAppsListPageLocation {
|
|||
filter: string;
|
||||
// A string with comma dlimetered list of included policy IDs
|
||||
included_policies: string;
|
||||
// A string with comma dlimetered list of excluded policy IDs
|
||||
excluded_policies: string;
|
||||
}
|
||||
|
||||
export interface TrustedAppsListPageState {
|
||||
|
|
|
@ -58,7 +58,6 @@ export const initialTrustedAppsPageState = (): TrustedAppsListPageState => ({
|
|||
view_type: 'grid',
|
||||
filter: '',
|
||||
included_policies: '',
|
||||
excluded_policies: '',
|
||||
},
|
||||
active: false,
|
||||
forceRefresh: false,
|
||||
|
|
|
@ -64,7 +64,6 @@ import {
|
|||
editingTrustedApp,
|
||||
getListItems,
|
||||
getCurrentLocationIncludedPolicies,
|
||||
getCurrentLocationExcludedPolicies,
|
||||
} from './selectors';
|
||||
import { parsePoliciesToKQL, parseQueryFilterToKQL } from '../../../common/utils';
|
||||
import { toUpdateTrustedApp } from '../../../../../common/endpoint/service/trusted_apps/to_update_trusted_app';
|
||||
|
@ -98,7 +97,6 @@ const refreshListIfNeeded = async (
|
|||
const pageSize = getCurrentLocationPageSize(store.getState());
|
||||
const filter = getCurrentLocationFilter(store.getState());
|
||||
const includedPolicies = getCurrentLocationIncludedPolicies(store.getState());
|
||||
const excludedPolicies = getCurrentLocationExcludedPolicies(store.getState());
|
||||
|
||||
const kuery = [];
|
||||
|
||||
|
@ -106,10 +104,7 @@ const refreshListIfNeeded = async (
|
|||
if (filterKuery) kuery.push(filterKuery);
|
||||
|
||||
const policiesKuery =
|
||||
parsePoliciesToKQL(
|
||||
includedPolicies ? includedPolicies.split(',') : [],
|
||||
excludedPolicies ? excludedPolicies.split(',') : []
|
||||
) || undefined;
|
||||
parsePoliciesToKQL(includedPolicies ? includedPolicies.split(',') : []) || undefined;
|
||||
if (policiesKuery) kuery.push(policiesKuery);
|
||||
|
||||
const response = await trustedAppsService.getTrustedAppsList({
|
||||
|
@ -129,7 +124,6 @@ const refreshListIfNeeded = async (
|
|||
timestamp: Date.now(),
|
||||
filter,
|
||||
includedPolicies,
|
||||
excludedPolicies,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
|
|
@ -31,7 +31,7 @@ describe('reducer', () => {
|
|||
initialState,
|
||||
createUserChangedUrlAction(
|
||||
'/administration/trusted_apps',
|
||||
'?page_index=5&page_size=50&show=create&view_type=list&filter=test&included_policies=global&excluded_policies=unassigned'
|
||||
'?page_index=5&page_size=50&show=create&view_type=list&filter=test&included_policies=global'
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -45,7 +45,6 @@ describe('reducer', () => {
|
|||
id: undefined,
|
||||
filter: 'test',
|
||||
included_policies: 'global',
|
||||
excluded_policies: 'unassigned',
|
||||
},
|
||||
active: true,
|
||||
});
|
||||
|
@ -61,7 +60,6 @@ describe('reducer', () => {
|
|||
view_type: 'grid',
|
||||
filter: '',
|
||||
included_policies: '',
|
||||
excluded_policies: '',
|
||||
},
|
||||
},
|
||||
createUserChangedUrlAction(
|
||||
|
@ -83,7 +81,6 @@ describe('reducer', () => {
|
|||
view_type: 'grid',
|
||||
filter: '',
|
||||
included_policies: '',
|
||||
excluded_policies: '',
|
||||
},
|
||||
},
|
||||
createUserChangedUrlAction('/administration/trusted_apps')
|
||||
|
|
|
@ -95,7 +95,6 @@ describe('selectors', () => {
|
|||
view_type: 'grid',
|
||||
filter: '',
|
||||
included_policies: '',
|
||||
excluded_policies: '',
|
||||
};
|
||||
|
||||
expect(needsRefreshOfListData({ ...initialState, listView, active: true, location })).toBe(
|
||||
|
@ -179,7 +178,6 @@ describe('selectors', () => {
|
|||
view_type: 'grid',
|
||||
filter: '',
|
||||
included_policies: '',
|
||||
excluded_policies: '',
|
||||
};
|
||||
|
||||
expect(getCurrentLocationPageIndex({ ...initialState, location })).toBe(3);
|
||||
|
@ -194,7 +192,6 @@ describe('selectors', () => {
|
|||
view_type: 'grid',
|
||||
filter: '',
|
||||
included_policies: '',
|
||||
excluded_policies: '',
|
||||
};
|
||||
|
||||
expect(getCurrentLocationPageSize({ ...initialState, location })).toBe(20);
|
||||
|
|
|
@ -85,12 +85,6 @@ export const getCurrentLocationIncludedPolicies = (
|
|||
return state.location.included_policies;
|
||||
};
|
||||
|
||||
export const getCurrentLocationExcludedPolicies = (
|
||||
state: Immutable<TrustedAppsListPageState>
|
||||
): string => {
|
||||
return state.location.excluded_policies;
|
||||
};
|
||||
|
||||
export const getListTotalItemsCount = (state: Immutable<TrustedAppsListPageState>): number => {
|
||||
return getLastLoadedResourceState(state.listView.listResourceState)?.data.totalItemsCount || 0;
|
||||
};
|
||||
|
|
|
@ -80,7 +80,6 @@ export const createTrustedAppsListData = (
|
|||
totalItemsCount: fullPagination.totalItemCount,
|
||||
timestamp,
|
||||
filter: '',
|
||||
excludedPolicies: '',
|
||||
includedPolicies: '',
|
||||
};
|
||||
};
|
||||
|
|
|
@ -45,10 +45,9 @@ export const TrustedAppsPage = memo(() => {
|
|||
const doEntriesExist = useTrustedAppsSelector(entriesExist);
|
||||
const didEntriesExist = useTrustedAppsSelector(prevEntriesExist);
|
||||
const navigationCallbackQuery = useTrustedAppsNavigateCallback(
|
||||
(query: string, includedPolicies?: string, excludedPolicies?: string) => ({
|
||||
(query: string, includedPolicies?: string) => ({
|
||||
filter: query,
|
||||
included_policies: includedPolicies,
|
||||
excluded_policies: excludedPolicies,
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -62,9 +61,9 @@ export const TrustedAppsPage = memo(() => {
|
|||
}));
|
||||
|
||||
const handleOnSearch = useCallback(
|
||||
(query: string, includedPolicies?: string, excludedPolicies?: string) => {
|
||||
(query: string, includedPolicies?: string) => {
|
||||
dispatch({ type: 'trustedAppForceRefresh', payload: { forceRefresh: true } });
|
||||
navigationCallbackQuery(query, includedPolicies, excludedPolicies);
|
||||
navigationCallbackQuery(query, includedPolicies);
|
||||
},
|
||||
[dispatch, navigationCallbackQuery]
|
||||
);
|
||||
|
@ -118,7 +117,6 @@ export const TrustedAppsPage = memo(() => {
|
|||
placeholder={SEARCH_TRUSTED_APP_PLACEHOLDER}
|
||||
hasPolicyFilter={true}
|
||||
policyList={policyList}
|
||||
defaultExcludedPolicies={location.excluded_policies}
|
||||
defaultIncludedPolicies={location.included_policies}
|
||||
/>
|
||||
<EuiFlexGroup
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue