From d620646890a293509b1cd2cbd44bf6a5596887c5 Mon Sep 17 00:00:00 2001 From: Sebastian Qvarfordt Date: Tue, 2 Jun 2020 15:45:38 +0200 Subject: [PATCH] Updated types --- plugins/catalog/src/api/CatalogClient.ts | 3 ++- plugins/catalog/src/components/CatalogPage/CatalogPage.tsx | 4 +++- plugins/catalog/src/data/component.ts | 4 +++- plugins/catalog/src/data/utils.ts | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/catalog/src/api/CatalogClient.ts b/plugins/catalog/src/api/CatalogClient.ts index 20720d34bd..bf308cb012 100644 --- a/plugins/catalog/src/api/CatalogClient.ts +++ b/plugins/catalog/src/api/CatalogClient.ts @@ -57,6 +57,7 @@ export class CatalogClient implements CatalogApi { const location = await response.json(); if (location) return location.data; } - throw new Error(`'Location not found: ${locationId}`); + + return undefined; } } diff --git a/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx b/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx index 479b5fee42..fe21c7de31 100644 --- a/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx +++ b/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx @@ -72,7 +72,9 @@ const CatalogPage: FC<{}> = () => { }; if (value) { - getLocationDataForEntities(value).then(setLocations); + getLocationDataForEntities(value) + .then(location => location.filter(l => !!l)) + .then(setLocations); } }, [value, catalogApi]); diff --git a/plugins/catalog/src/data/component.ts b/plugins/catalog/src/data/component.ts index d53a6387fc..1a7935a196 100644 --- a/plugins/catalog/src/data/component.ts +++ b/plugins/catalog/src/data/component.ts @@ -13,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { Location } from '@backstage/catalog-model'; + export type Component = { name: string; kind: string; description: string; - location?: any; + location?: Location; }; diff --git a/plugins/catalog/src/data/utils.ts b/plugins/catalog/src/data/utils.ts index 645d6b845d..fe2ec62493 100644 --- a/plugins/catalog/src/data/utils.ts +++ b/plugins/catalog/src/data/utils.ts @@ -14,11 +14,11 @@ * limitations under the License. */ import { Component } from './component'; -import { Entity } from '@backstage/catalog-model'; +import { Entity, Location } from '@backstage/catalog-model'; export function envelopeToComponent( envelope: Entity, - location?: any, + location?: Location, ): Component { return { name: envelope.metadata?.name ?? '',