-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] change UX of edit integration policy agent policies #190583
Merged
juliaElastic
merged 12 commits into
elastic:main
from
juliaElastic:edit-reusable-policies
Aug 29, 2024
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
104e746
change UX of edit integration policy agent policies
juliaElastic d6afc5e
added tests
juliaElastic 00e8627
Merge branch 'main' into edit-reusable-policies
juliaElastic bcb8ef8
extract common logic in a hook
juliaElastic 2a9be3c
fix tests
juliaElastic 375c1db
fix tests
juliaElastic ab18a08
Merge branch 'main' into edit-reusable-policies
juliaElastic e008613
Merge branch 'main' into edit-reusable-policies
juliaElastic 6195819
removed advanced options from create agent policy
juliaElastic 020d204
fix cypress test
juliaElastic 22c3f95
Merge branch 'main' into edit-reusable-policies
juliaElastic be2ae3c
replace is_managed filter to be done on backend
juliaElastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
34 changes: 34 additions & 0 deletions
34
...ions/agent_policy/create_package_policy_page/components/steps/components/use_policies.tsx
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,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 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 | ||
}); | ||
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; | ||
}; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we search directly for non managed policies in the API call with a kuery like
not is_managed:* or is_managed:false
(not tested)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that but it didn't work. I think
is_managed
is not indexed: https://github.com/elastic/elasticsearch/blob/main/x-pack/plugin/core/template-resources/src/main/resources/fleet-agents.jsonThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be indexed https://github.com/juliaElastic/kibana/blob/22c3f95868d6a5d804e9ed85b7575da6dd423b46/x-pack/plugins/fleet/server/saved_objects/index.ts#L282 but not a blocker it should not really change the number of policies returned as we do not expect to have many managed policies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I was looking at the wrong place.
The filter actually works, I tried before without the prefix
ingest-agent-policies.is_managed:false