From 7cb5788e9ce94ec03d9304902efa006bc9f94202 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 14 Mar 2022 13:39:16 +0100 Subject: [PATCH] clean up deprecations of techdocs plugin Signed-off-by: Emma Indal --- docs/features/techdocs/configuration.md | 5 -- plugins/techdocs/api-report.md | 23 +----- plugins/techdocs/config.d.ts | 7 -- plugins/techdocs/src/api.ts | 6 -- plugins/techdocs/src/client.ts | 10 +-- .../components/LegacyTechDocsHome.test.tsx | 76 ------------------ .../home/components/LegacyTechDocsHome.tsx | 58 -------------- .../reader/components/LegacyTechDocsPage.tsx | 80 ------------------- .../reader/components/TechDocsReaderPage.tsx | 16 +--- .../components/TechDocsReaderPageHeader.tsx | 13 --- .../techdocs/src/reader/components/index.ts | 2 - .../TechDocsSearchResultListItem.tsx | 6 -- 12 files changed, 6 insertions(+), 296 deletions(-) delete mode 100644 plugins/techdocs/src/home/components/LegacyTechDocsHome.test.tsx delete mode 100644 plugins/techdocs/src/home/components/LegacyTechDocsHome.tsx delete mode 100644 plugins/techdocs/src/reader/components/LegacyTechDocsPage.tsx diff --git a/docs/features/techdocs/configuration.md b/docs/features/techdocs/configuration.md index 3edc55574f..d16e9142dc 100644 --- a/docs/features/techdocs/configuration.md +++ b/docs/features/techdocs/configuration.md @@ -161,11 +161,6 @@ techdocs: # default value is 1000 readTimeout: 500 - # (Optional and Legacy) TechDocs makes API calls to techdocs-backend using this URL. e.g. get docs of an entity, get metadata, etc. - # You don't have to specify this anymore. - - requestUrl: http://localhost:7007/api/techdocs - # (Optional and Legacy) Just another route in techdocs-backend where TechDocs requests the static files from. This URL uses an HTTP middleware # to serve files from either a local directory or an External storage provider. # You don't have to specify this anymore. diff --git a/plugins/techdocs/api-report.md b/plugins/techdocs/api-report.md index f7ef6e984a..e6f9d463ed 100644 --- a/plugins/techdocs/api-report.md +++ b/plugins/techdocs/api-report.md @@ -41,11 +41,6 @@ export type DocsCardGridProps = { entities: Entity[] | undefined; }; -// @public @deprecated (undocumented) -export const DocsResultListItem: ( - props: TechDocsSearchResultListItemProps, -) => JSX.Element; - // @public export const DocsTable: { (props: DocsTableProps): JSX.Element | null; @@ -185,6 +180,7 @@ export type TabsConfig = TabConfig[]; // @public export interface TechDocsApi { + // (undocumented) getApiOrigin(): Promise; // (undocumented) getEntityMetadata( @@ -243,23 +239,9 @@ export type TechDocsMetadata = { site_description: string; }; -// @public @deprecated (undocumented) -export const TechDocsPage: (props: TechDocsReaderPageProps) => JSX.Element; - // @public export const TechdocsPage: () => JSX.Element; -// @public @deprecated (undocumented) -export const TechDocsPageHeader: ( - props: TechDocsReaderPageHeaderProps, -) => JSX.Element; - -// @public @deprecated (undocumented) -export type TechDocsPageHeaderProps = TechDocsReaderPageHeaderProps; - -// @public @deprecated (undocumented) -export type TechDocsPageRenderFunction = TechDocsReaderPageRenderFunction; - // @public export const TechDocsPageWrapper: ( props: TechDocsPageWrapperProps, @@ -292,7 +274,7 @@ export { techdocsPlugin }; // @public export const TechDocsReaderPage: ( props: TechDocsReaderPageProps, -) => JSX.Element; +) => JSX.Element | null; // @public export const TechDocsReaderPageHeader: ( @@ -348,6 +330,7 @@ export type TechDocsSearchResultListItemProps = { // @public export interface TechDocsStorageApi { + // (undocumented) getApiOrigin(): Promise; // (undocumented) getBaseUrl( diff --git a/plugins/techdocs/config.d.ts b/plugins/techdocs/config.d.ts index 5274a31ed0..82ae8dd87a 100644 --- a/plugins/techdocs/config.d.ts +++ b/plugins/techdocs/config.d.ts @@ -33,13 +33,6 @@ export interface Config { */ legacyUseCaseSensitiveTripletPaths?: boolean; - /** - * @example http://localhost:7007/api/techdocs - * @visibility frontend - * @deprecated - */ - requestUrl?: string; - sanitizer?: { /** * Allows iframe tag only for listed hosts diff --git a/plugins/techdocs/src/api.ts b/plugins/techdocs/src/api.ts index b349431b0d..51dd82e643 100644 --- a/plugins/techdocs/src/api.ts +++ b/plugins/techdocs/src/api.ts @@ -49,9 +49,6 @@ export type SyncResult = 'cached' | 'updated'; * @public */ export interface TechDocsStorageApi { - /** - * Set to techdocs.requestUrl as the URL for techdocs-backend API. - */ getApiOrigin(): Promise; getStorageUrl(): Promise; getBuilder(): Promise; @@ -73,9 +70,6 @@ export interface TechDocsStorageApi { * @public */ export interface TechDocsApi { - /** - * Set to techdocs.requestUrl as the URL for techdocs-backend API. - */ getApiOrigin(): Promise; getTechDocsMetadata(entityId: CompoundEntityRef): Promise; getEntityMetadata( diff --git a/plugins/techdocs/src/client.ts b/plugins/techdocs/src/client.ts index f260f00547..69a5a91efc 100644 --- a/plugins/techdocs/src/client.ts +++ b/plugins/techdocs/src/client.ts @@ -47,10 +47,7 @@ export class TechDocsClient implements TechDocsApi { } async getApiOrigin(): Promise { - return ( - this.configApi.getOptionalString('techdocs.requestUrl') ?? - (await this.discoveryApi.getBaseUrl('techdocs')) - ); + return await this.discoveryApi.getBaseUrl('techdocs'); } /** @@ -126,10 +123,7 @@ export class TechDocsStorageClient implements TechDocsStorageApi { } async getApiOrigin(): Promise { - return ( - this.configApi.getOptionalString('techdocs.requestUrl') ?? - (await this.discoveryApi.getBaseUrl('techdocs')) - ); + return await this.discoveryApi.getBaseUrl('techdocs'); } async getStorageUrl(): Promise { diff --git a/plugins/techdocs/src/home/components/LegacyTechDocsHome.test.tsx b/plugins/techdocs/src/home/components/LegacyTechDocsHome.test.tsx deleted file mode 100644 index 4c33f69fb7..0000000000 --- a/plugins/techdocs/src/home/components/LegacyTechDocsHome.test.tsx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2021 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { CatalogApi, catalogApiRef } from '@backstage/plugin-catalog-react'; -import { renderInTestApp, TestApiRegistry } from '@backstage/test-utils'; -import { screen } from '@testing-library/react'; -import React from 'react'; -import { LegacyTechDocsHome } from './LegacyTechDocsHome'; - -import { ApiProvider, ConfigReader } from '@backstage/core-app-api'; -import { ConfigApi, configApiRef } from '@backstage/core-plugin-api'; -import { rootDocsRouteRef } from '../../routes'; - -const mockCatalogApi = { - getEntityByRef: jest.fn(), - getEntities: async () => ({ - items: [ - { - apiVersion: 'version', - kind: 'User', - metadata: { - name: 'owned', - namespace: 'default', - }, - }, - ], - }), -} as Partial; - -describe('Legacy TechDocs Home', () => { - const configApi: ConfigApi = new ConfigReader({ - organization: { - name: 'My Company', - }, - }); - - const apiRegistry = TestApiRegistry.from( - [catalogApiRef, mockCatalogApi], - [configApiRef, configApi], - ); - - it('should render a TechDocs home page', async () => { - await renderInTestApp( - - - , - { - mountedRoutes: { - '/docs/:namespace/:kind/:name/*': rootDocsRouteRef, - }, - }, - ); - - // Header - expect(await screen.findByText('Documentation')).toBeInTheDocument(); - expect( - await screen.findByText(/Documentation available in My Company/i), - ).toBeInTheDocument(); - - // Explore Content - expect(await screen.findByTestId('docs-explore')).toBeDefined(); - }); -}); diff --git a/plugins/techdocs/src/home/components/LegacyTechDocsHome.tsx b/plugins/techdocs/src/home/components/LegacyTechDocsHome.tsx deleted file mode 100644 index 536c2c80c8..0000000000 --- a/plugins/techdocs/src/home/components/LegacyTechDocsHome.tsx +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2021 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import React from 'react'; -import { PanelType, TechDocsCustomHome } from './TechDocsCustomHome'; - -/** - * @deprecated Use {@link TechDocsCustomHome} instead. - */ -export const LegacyTechDocsHome = () => { - const tabsConfig = [ - { - label: 'Overview', - panels: [ - { - title: 'Overview', - description: - 'Explore your internal technical ecosystem through documentation.', - panelType: 'DocsCardGrid' as PanelType, - filterPredicate: () => true, - }, - // uncomment this if you would like to have a secondary panel with owned documents - // { - // title: 'Owned', - // description: 'Explore your owned internal documentation.', - // panelType: 'DocsCardGrid' as PanelType, - // filterPredicate: 'ownedByUser', - // }, - ], - }, - { - label: 'Owned Documents', - panels: [ - { - title: 'Owned documents', - description: 'Access your documentation.', - panelType: 'DocsTable' as PanelType, - // ownedByUser filters out entities owned by signed in user - filterPredicate: 'ownedByUser', - }, - ], - }, - ]; - return ; -}; diff --git a/plugins/techdocs/src/reader/components/LegacyTechDocsPage.tsx b/plugins/techdocs/src/reader/components/LegacyTechDocsPage.tsx deleted file mode 100644 index 4bfda57ace..0000000000 --- a/plugins/techdocs/src/reader/components/LegacyTechDocsPage.tsx +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2020 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import React, { useCallback, useState } from 'react'; -import { useParams } from 'react-router-dom'; -import useAsync from 'react-use/lib/useAsync'; -import { techdocsApiRef } from '../../api'; -import { TechDocsNotFound } from './TechDocsNotFound'; -import { useApi } from '@backstage/core-plugin-api'; -import { Page, Content } from '@backstage/core-components'; -import { Reader } from './Reader'; -import { TechDocsReaderPageHeader } from './TechDocsReaderPageHeader'; - -/** - * @deprecated Use {@link TechDocsReaderPage} instead. - */ -export const LegacyTechDocsPage = () => { - const [documentReady, setDocumentReady] = useState(false); - const { namespace, kind, name } = useParams(); - - const techdocsApi = useApi(techdocsApiRef); - - const { value: techdocsMetadataValue } = useAsync(() => { - if (documentReady) { - return techdocsApi.getTechDocsMetadata({ kind, namespace, name }); - } - - return Promise.resolve(undefined); - }, [kind, namespace, name, techdocsApi, documentReady]); - - const { value: entityMetadataValue, error: entityMetadataError } = - useAsync(() => { - return techdocsApi.getEntityMetadata({ kind, namespace, name }); - }, [kind, namespace, name, techdocsApi]); - - const onReady = useCallback(() => { - setDocumentReady(true); - }, [setDocumentReady]); - - if (entityMetadataError) { - return ; - } - - return ( - - - - - - - ); -}; diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPage.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPage.tsx index 184ab24b6d..ff44d429df 100644 --- a/plugins/techdocs/src/reader/components/TechDocsReaderPage.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsReaderPage.tsx @@ -19,7 +19,6 @@ import { useOutlet } from 'react-router'; import { useParams } from 'react-router-dom'; import useAsync from 'react-use/lib/useAsync'; import { techdocsApiRef } from '../../api'; -import { LegacyTechDocsPage } from './LegacyTechDocsPage'; import { TechDocsEntityMetadata, TechDocsMetadata } from '../../types'; import { CompoundEntityRef } from '@backstage/catalog-model'; import { useApi, useApp } from '@backstage/core-plugin-api'; @@ -79,7 +78,7 @@ export const TechDocsReaderPage = (props: TechDocsReaderPageProps) => { if (entityMetadataError) return ; - if (!children) return outlet || ; + if (!children) return outlet; return ( @@ -94,16 +93,3 @@ export const TechDocsReaderPage = (props: TechDocsReaderPageProps) => { ); }; - -/** - * @public - * @deprecated use {@link TechDocsReaderPage} instead - */ -export const TechDocsPage = TechDocsReaderPage; - -/** - * @public - * @deprecated use {@link TechDocsReaderPageRenderFunction} instead - */ - -export type TechDocsPageRenderFunction = TechDocsReaderPageRenderFunction; diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPageHeader.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPageHeader.tsx index 5867641c48..f6a3352e7d 100644 --- a/plugins/techdocs/src/reader/components/TechDocsReaderPageHeader.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsReaderPageHeader.tsx @@ -122,16 +122,3 @@ export const TechDocsReaderPageHeader = ( ); }; - -/** - * @public - * @deprecated use {@link TechDocsReaderPageHeader} instead - */ -export const TechDocsPageHeader = TechDocsReaderPageHeader; - -/** - * @public - * @deprecated use {@link TechDocsReaderPageHeader} instead - */ - -export type TechDocsPageHeaderProps = TechDocsReaderPageHeaderProps; diff --git a/plugins/techdocs/src/reader/components/index.ts b/plugins/techdocs/src/reader/components/index.ts index 3124a92f93..8e660767ad 100644 --- a/plugins/techdocs/src/reader/components/index.ts +++ b/plugins/techdocs/src/reader/components/index.ts @@ -17,10 +17,8 @@ export * from './Reader'; export type { TechDocsReaderPageProps, - TechDocsPageRenderFunction, TechDocsReaderPageRenderFunction, } from './TechDocsReaderPage'; -export { TechDocsPage } from './TechDocsReaderPage'; export * from './TechDocsReaderPageHeader'; export * from './TechDocsStateIndicator'; diff --git a/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx b/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx index 152fa2e3d3..db5751654d 100644 --- a/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx +++ b/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx @@ -101,9 +101,3 @@ export const TechDocsSearchResultListItem = ( ); }; - -/** - * @public - * @deprecated use {@link TechDocsSearchResultListItem} instead - */ -export const DocsResultListItem = TechDocsSearchResultListItem;