Skip to content

Commit

Permalink
[Fleet] fixed bug where installed beta integration was visible multip…
Browse files Browse the repository at this point in the history
…le times (#150979)

## Summary

Fixes #150969

Filtering for only uploaded packages that are not in registry.
This fixes of bug of linux integration showing up multiple times when
the `/packages` call with `prerelease:false` and `prerelease:true`
options are quickly following each other.

To verify:
- Navigate to Integrations, search `linux`.
- Add linux integration to agent policy.
- Repeat the same process again.
- Navigate back to Integrations and search `linux`.
- Only one Linux metrics integration card should be visible.

<img width="1009" alt="image"
src="https://user-images.githubusercontent.com/90178898/218418246-ffd8f9ed-796b-4ba9-97d2-5a93165c384b.png">

Uploaded integrations are still visible:
<img width="1006" alt="image"
src="https://user-images.githubusercontent.com/90178898/218418791-82d41523-b8ec-4a37-9e14-cfd67e889ba7.png">



### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
juliaElastic authored Feb 13, 2023
1 parent 27d1cc7 commit 45f5f3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions x-pack/plugins/fleet/server/services/epm/packages/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ describe('When using EPM `get` services', () => {
attributes: {
name: 'elasticsearch',
version: '0.0.1',
install_status: 'upload',
install_source: 'upload',
},
},
],
Expand All @@ -221,16 +221,16 @@ describe('When using EPM `get` services', () => {
})
).resolves.toMatchObject([
{
id: 'elasticsearch',
name: 'elasticsearch',
version: '0.0.1',
title: 'Elasticsearch',
status: 'upload',
savedObject: {
id: 'elasticsearch',
attributes: {
name: 'elasticsearch',
version: '0.0.1',
install_status: 'upload',
install_source: 'upload',
},
},
},
Expand Down
8 changes: 5 additions & 3 deletions x-pack/plugins/fleet/server/services/epm/packages/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ export async function getPackages(
// get the installed packages
const packageSavedObjects = await getPackageSavedObjects(savedObjectsClient);

const packagesNotInRegistry = packageSavedObjects.saved_objects
const uploadedPackagesNotInRegistry = packageSavedObjects.saved_objects
.filter((pkg) => !registryItems.some((item) => item.name === pkg.id))
.map((pkg) => createInstallableFrom({ ...pkg.attributes, title: nameAsTitle(pkg.id) }, pkg));
.map((pkg) =>
createInstallableFrom({ ...pkg.attributes, title: nameAsTitle(pkg.id), id: pkg.id }, pkg)
);

const packageList = registryItems
.map((item) =>
Expand All @@ -85,7 +87,7 @@ export async function getPackages(
packageSavedObjects.saved_objects.find(({ id }) => id === item.name)
)
)
.concat(packagesNotInRegistry as Installable<any>)
.concat(uploadedPackagesNotInRegistry as Installable<any>)
.sort(sortByName);

if (!excludeInstallStatus) {
Expand Down

0 comments on commit 45f5f3d

Please sign in to comment.