[Logs Explorer]: Update integration icons type (#162219)

## 📓 Summary

The integrations returned from the API have an `icons` property which is
an array of icon object descriptors.

The runtime validation on the clientside was not aligned with the type
of these icons, which are retrieved from the package manifest and have
some optional attributes, while the current implementation assumed all
the properties were mandatory.

This PR aligns the runtime type with the
[PackageSpecIcon](https://github.com/elastic/kibana/blob/main/x-pack/plugins/fleet/common/types/models/package_spec.ts#L114)
type.

<img width="314" alt="Screenshot 2023-07-19 at 11 08 01"
src="ff51bad6-89dd-44f3-a959-24d6717db235">
<img width="315" alt="Screenshot 2023-07-19 at 11 08 18"
src="10cb05bc-c138-4c03-9d8b-74f5a4b7aab0">

Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>
This commit is contained in:
Marco Antonio Ghiani 2023-07-19 17:15:12 +02:00 committed by GitHub
parent 092e988df2
commit 917e3f219b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,17 @@ const integrationStatusRT = rt.keyof({
install_failed: null,
});
const iconRT = rt.intersection([
rt.type({
src: rt.string,
}),
rt.partial({
title: rt.string,
size: rt.string,
type: rt.string,
}),
]);
export const integrationRT = rt.intersection([
rt.type({
name: rt.string,
@ -34,17 +45,7 @@ export const integrationRT = rt.intersection([
}),
rt.partial({
title: rt.union([rt.string, rt.undefined]),
icons: rt.union([
rt.array(
rt.type({
src: rt.string,
title: rt.string,
size: rt.string,
type: rt.string,
})
),
rt.undefined,
]),
icons: rt.union([rt.array(iconRT), rt.undefined]),
description: rt.union([rt.string, rt.undefined]),
}),
]);