Skip to content

Commit

Permalink
replace is_managed filter to be done on backend
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Aug 28, 2024
1 parent 22c3f95 commit be2ae3c
Showing 1 changed file with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,22 @@
* 2.0.
*/

import { useMemo } from 'react';

import type { AgentPolicy } from '../../../../../../../../../common';

import { SO_SEARCH_LIMIT } from '../../../../../../../../../common';
import { useGetAgentPolicies } from '../../../../../../../../hooks';

export const useAllNonManagedAgentPolicies = () => {
let existingAgentPolicies: AgentPolicy[] = [];
const { data: agentPoliciesData, error: err } = useGetAgentPolicies({
page: 1,
perPage: SO_SEARCH_LIMIT,
sortField: 'name',
sortOrder: 'asc',
full: false, // package_policies will always be empty
noAgentCount: true, // agentPolicy.agents will always be 0
noAgentCount: true, // agentPolicy.agents will always be 0,
kuery: 'ingest-agent-policies.is_managed:false',
});
if (err) {
// eslint-disable-next-line no-console
console.debug('Could not retrieve agent policies');
}
existingAgentPolicies = useMemo(
() => agentPoliciesData?.items.filter((policy) => !policy.is_managed) || [],
[agentPoliciesData?.items]
);
return existingAgentPolicies;
return agentPoliciesData?.items || [];
};

0 comments on commit be2ae3c

Please sign in to comment.