Skip to content
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

[8.15] [Fleet] fix navigating back to Agent policy integration list (#189165) #189194

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export const EditPackagePolicyForm = memo<{
})
: policyId
? getHref('policy_details', { policyId })
: '/';
: getHref('agent_list');
}, [from, getHref, packageInfo, policyId]);
const successRedirectPath = useMemo(() => {
return (from === 'package-edit' || from === 'upgrade-from-integrations-policy-list') &&
Expand All @@ -200,7 +200,7 @@ export const EditPackagePolicyForm = memo<{
})
: policyId
? getHref('policy_details', { policyId })
: '/';
: getHref('agent_list');
}, [from, getHref, packageInfo, policyId]);

useHistoryBlock(isEdited);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,17 @@ describe('PackagePolicyActionsMenu', () => {
expect(utils.queryByText('Add agent')).toBeNull();
});
});

it('Should show Edit integration with correct href when agentPolicy is defined', async () => {
const agentPolicies = createMockAgentPolicies();
const packagePolicy = createMockPackagePolicy();
const { utils } = renderMenu({ agentPolicies, packagePolicy });
await act(async () => {
const editButton = utils.getByTestId('PackagePolicyActionsEditItem');
expect(editButton).toHaveAttribute(
'href',
'/mock/app/fleet/policies/some-uuid1/edit-integration/some-uuid2'
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export const PackagePolicyActionsMenu: React.FunctionComponent<{
data-test-subj="PackagePolicyActionsEditItem"
disabled={!canWriteIntegrationPolicies || !agentPolicy}
icon="pencil"
href={`${getHref('integration_policy_edit', {
href={`${getHref('edit_integration', {
policyId: agentPolicy?.id ?? '',
packagePolicyId: packagePolicy.id,
})}${from ? `?from=${from}` : ''}`}
key="packagePolicyEdit"
Expand Down
Loading