[8.6] [Fleet] Fix missing policyId in cloud integrations install url (#149243) (#149307)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[Fleet] Fix missing policyId in cloud integrations install url
(#149243)](https://github.com/elastic/kibana/pull/149243)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Cristina
Amico","email":"criamico@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-01-23T10:31:20Z","message":"[Fleet]
Fix missing policyId in cloud integrations install url (#149243)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/148272\r\n\r\n### Repro
steps\r\nThis bug is only happening in cloud, to get into the same state
in the\r\nlocal change
[this\r\nline](a31d844318/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx (LL129C12-L129C12))\r\nto
`true`\r\n\r\n- Setup a fresh version of kibana (since we need to show
the \"Ready to\r\nadd your first integration?\" splash screen)\r\n-
Create a new agent policy, select the integrations tab and add a
new\r\nintegration\r\n- The splash screen should appear with
url\r\n`app/fleet/integrations/endpoint-8.6.1/add-integration?policyId=fleet-first-agent-policy&useMultiPageLayout`\r\n-
Click on the link `Add integration only (skip agent installation)
on\r\nthe bottom\r\n- It will navigate to the integration install form
and the url should\r\nhave the policy id (previously
missing)\r\n`app/fleet/integrations/endpoint-8.6.1/add-integration?policyId=fleet-first-agent-policy`.\r\nThe
form should also be pre-filled with the correct agent policy in
the\r\n`Existing hosts`
section\r\n\r\n\r\nhttps://user-images.githubusercontent.com/16084106/213503514-97fd17b4-9559-49ec-a142-40c8df612002.mov\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"861df2d31196ef443c4da7435c718b58f94ca9a5","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","backport:prev-minor","v8.7.0"],"number":149243,"url":"https://github.com/elastic/kibana/pull/149243","mergeCommit":{"message":"[Fleet]
Fix missing policyId in cloud integrations install url (#149243)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/148272\r\n\r\n### Repro
steps\r\nThis bug is only happening in cloud, to get into the same state
in the\r\nlocal change
[this\r\nline](a31d844318/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx (LL129C12-L129C12))\r\nto
`true`\r\n\r\n- Setup a fresh version of kibana (since we need to show
the \"Ready to\r\nadd your first integration?\" splash screen)\r\n-
Create a new agent policy, select the integrations tab and add a
new\r\nintegration\r\n- The splash screen should appear with
url\r\n`app/fleet/integrations/endpoint-8.6.1/add-integration?policyId=fleet-first-agent-policy&useMultiPageLayout`\r\n-
Click on the link `Add integration only (skip agent installation)
on\r\nthe bottom\r\n- It will navigate to the integration install form
and the url should\r\nhave the policy id (previously
missing)\r\n`app/fleet/integrations/endpoint-8.6.1/add-integration?policyId=fleet-first-agent-policy`.\r\nThe
form should also be pre-filled with the correct agent policy in
the\r\n`Existing hosts`
section\r\n\r\n\r\nhttps://user-images.githubusercontent.com/16084106/213503514-97fd17b4-9559-49ec-a142-40c8df612002.mov\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"861df2d31196ef443c4da7435c718b58f94ca9a5"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/149243","number":149243,"mergeCommit":{"message":"[Fleet]
Fix missing policyId in cloud integrations install url (#149243)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/148272\r\n\r\n### Repro
steps\r\nThis bug is only happening in cloud, to get into the same state
in the\r\nlocal change
[this\r\nline](a31d844318/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx (LL129C12-L129C12))\r\nto
`true`\r\n\r\n- Setup a fresh version of kibana (since we need to show
the \"Ready to\r\nadd your first integration?\" splash screen)\r\n-
Create a new agent policy, select the integrations tab and add a
new\r\nintegration\r\n- The splash screen should appear with
url\r\n`app/fleet/integrations/endpoint-8.6.1/add-integration?policyId=fleet-first-agent-policy&useMultiPageLayout`\r\n-
Click on the link `Add integration only (skip agent installation)
on\r\nthe bottom\r\n- It will navigate to the integration install form
and the url should\r\nhave the policy id (previously
missing)\r\n`app/fleet/integrations/endpoint-8.6.1/add-integration?policyId=fleet-first-agent-policy`.\r\nThe
form should also be pre-filled with the correct agent policy in
the\r\n`Existing hosts`
section\r\n\r\n\r\nhttps://user-images.githubusercontent.com/16084106/213503514-97fd17b4-9559-49ec-a142-40c8df612002.mov\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"861df2d31196ef443c4da7435c718b58f94ca9a5"}}]}]
BACKPORT-->

Co-authored-by: Cristina Amico <criamico@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2023-01-23 06:37:56 -05:00 committed by GitHub
parent a9c81434f3
commit 6ddf28d837
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,7 +50,6 @@ const fleetManagedSteps = [installAgentStep, addIntegrationStep, confirmDataStep
const standaloneSteps = [addIntegrationStep, installAgentStep, confirmDataStep];
export const CreatePackagePolicyMultiPage: CreatePackagePolicyParams = ({
from,
queryParamsPolicyId,
prerelease,
}) => {
@ -66,7 +65,7 @@ export const CreatePackagePolicyMultiPage: CreatePackagePolicyParams = ({
setIsManaged(newIsManaged);
setCurrentStep(0);
};
const agentPolicyId = policyId || queryParamsPolicyId;
const {
data: packageInfoData,
error: packageInfoError,
@ -78,7 +77,7 @@ export const CreatePackagePolicyMultiPage: CreatePackagePolicyParams = ({
enrollmentAPIKey,
error: agentPolicyError,
isLoading: isAgentPolicyLoading,
} = useGetAgentPolicyOrDefault(queryParamsPolicyId);
} = useGetAgentPolicyOrDefault(agentPolicyId);
const packageInfo = useMemo(() => packageInfoData?.item, [packageInfoData]);
@ -99,7 +98,7 @@ export const CreatePackagePolicyMultiPage: CreatePackagePolicyParams = ({
pkgkey,
useMultiPageLayout: false,
...(integration ? { integration } : {}),
...(policyId ? { agentPolicyId: policyId } : {}),
...(agentPolicyId ? { agentPolicyId } : {}),
});
if (onSplash || !packageInfo) {