From e7862589f6e635c1bb2d0c8d8cc6ecdd656bec0e Mon Sep 17 00:00:00 2001 From: Nikita Nek Dudnik Date: Wed, 10 Jun 2020 23:51:37 +0200 Subject: [PATCH] fix(catalog): merge errors --- plugins/catalog/src/api/CatalogClient.ts | 16 ++++++++++++++++ .../components/CatalogPage/CatalogPage.test.tsx | 2 +- plugins/catalog/src/data/filters.ts | 1 - .../RegisterComponentPage.test.tsx | 3 ++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/plugins/catalog/src/api/CatalogClient.ts b/plugins/catalog/src/api/CatalogClient.ts index 5717735d9f..1935b05c3f 100644 --- a/plugins/catalog/src/api/CatalogClient.ts +++ b/plugins/catalog/src/api/CatalogClient.ts @@ -140,4 +140,20 @@ export class CatalogClient implements CatalogApi { .map(r => r.data) .find(l => locationCompound === `${l.type}:${l.target}`); } + + async removeEntityByUid(uid: string): Promise { + const response = await fetch( + `${this.apiOrigin}${this.basePath}/entities/by-uid/${uid}`, + { + method: 'DELETE', + }, + ); + if (!response.ok) { + const payload = await response.text(); + throw new Error( + `Request failed with ${response.status} ${response.statusText}, ${payload}`, + ); + } + return undefined; + } } diff --git a/plugins/catalog/src/components/CatalogPage/CatalogPage.test.tsx b/plugins/catalog/src/components/CatalogPage/CatalogPage.test.tsx index d995556546..d30361d0e7 100644 --- a/plugins/catalog/src/components/CatalogPage/CatalogPage.test.tsx +++ b/plugins/catalog/src/components/CatalogPage/CatalogPage.test.tsx @@ -14,7 +14,6 @@ * limitations under the License. */ -import { Entity } from '@backstage/catalog-model'; import { ApiProvider, ApiRegistry, @@ -28,6 +27,7 @@ import React from 'react'; import { catalogApiRef } from '../..'; import { CatalogApi } from '../../api/types'; import { CatalogPage } from './CatalogPage'; +import { Entity } from '@backstage/catalog-model'; describe('CatalogPage', () => { const mockErrorApi = new MockErrorApi(); diff --git a/plugins/catalog/src/data/filters.ts b/plugins/catalog/src/data/filters.ts index 5f4c140986..fcdf4578a4 100644 --- a/plugins/catalog/src/data/filters.ts +++ b/plugins/catalog/src/data/filters.ts @@ -22,7 +22,6 @@ import StarIcon from '@material-ui/icons/Star'; import { StarredCount } from '../components/CatalogFilter/StarredCount'; import { AllServicesCount } from '../components/CatalogFilter/AllServicesCount'; import { FilterGroupItem } from '../types'; -import { Entity } from '@backstage/catalog-model'; export const filterGroups: CatalogFilterGroup[] = [ { diff --git a/plugins/register-component/src/components/RegisterComponentPage/RegisterComponentPage.test.tsx b/plugins/register-component/src/components/RegisterComponentPage/RegisterComponentPage.test.tsx index 361b98d788..32213f04e4 100644 --- a/plugins/register-component/src/components/RegisterComponentPage/RegisterComponentPage.test.tsx +++ b/plugins/register-component/src/components/RegisterComponentPage/RegisterComponentPage.test.tsx @@ -29,9 +29,10 @@ const catalogApi: jest.Mocked = { /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ addLocation: jest.fn((_a, _b) => new Promise(() => {})), getEntities: jest.fn(), - getEntity: jest.fn(), getLocationByEntity: jest.fn(), getLocationById: jest.fn(), + removeEntityByUid: jest.fn(), + getEntityByName: jest.fn(), }; const setup = () => ({