Skip to content

Commit

Permalink
fixed enrollment token modal for managed policy (#129870) (#129975)
Browse files Browse the repository at this point in the history
(cherry picked from commit 485f2d1)

Co-authored-by: Julia Bardi <[email protected]>
  • Loading branch information
kibanamachine and juliaElastic authored Apr 12, 2022
1 parent 3df15fb commit 04370b9
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions x-pack/plugins/fleet/public/components/new_enrollment_key_modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,18 @@ export const NewEnrollmentTokenModal: React.FunctionComponent<Props> = ({
agentPolicies = [],
}) => {
const { notifications } = useStartServices();

const selectPolicyOptions = useMemo(() => {
return agentPolicies
.filter((agentPolicy) => !agentPolicy.is_managed)
.map((agentPolicy) => ({
value: agentPolicy.id,
text: agentPolicy.name,
}));
}, [agentPolicies]);

const form = useCreateApiKeyForm(
agentPolicies.length > 0 ? agentPolicies[0].id : undefined,
selectPolicyOptions.length > 0 ? selectPolicyOptions[0].value : undefined,
(key: EnrollmentAPIKey) => {
onClose(key);
notifications.toasts.addSuccess(
Expand All @@ -93,15 +103,6 @@ export const NewEnrollmentTokenModal: React.FunctionComponent<Props> = ({
}
);

const selectPolicyOptions = useMemo(() => {
return agentPolicies
.filter((agentPolicy) => !agentPolicy.is_managed)
.map((agentPolicy) => ({
value: agentPolicy.id,
text: agentPolicy.name,
}));
}, [agentPolicies]);

const body = (
<EuiForm>
<form onSubmit={form.onSubmit}>
Expand Down

0 comments on commit 04370b9

Please sign in to comment.