From 1360f7d73a2ed1bda6496b6a40a04cbb7e833557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Fri, 4 Mar 2022 14:38:52 +0100 Subject: [PATCH] remove old ScaffolderTaskOutput link outputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/lazy-points-explain.md | 5 +++ plugins/scaffolder/api-report.md | 16 ++++---- .../src/components/TaskPage/TaskPage.tsx | 8 +--- .../TaskPage/TaskPageLinks.test.tsx | 37 ------------------- .../src/components/TaskPage/TaskPageLinks.tsx | 18 +-------- plugins/scaffolder/src/index.ts | 1 + plugins/scaffolder/src/types.ts | 8 ++-- 7 files changed, 20 insertions(+), 73 deletions(-) create mode 100644 .changeset/lazy-points-explain.md diff --git a/.changeset/lazy-points-explain.md b/.changeset/lazy-points-explain.md new file mode 100644 index 0000000000..ced31c2195 --- /dev/null +++ b/.changeset/lazy-points-explain.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': minor +--- + +**BREAKING**: Removed `ScaffolderTaskOutput.entityRef` and `ScaffolderTaskOutput.remoteUrl`, which both have been deprecated for over a year. Please use the `links` output instead. diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index b51f18fcc9..9326a61fd5 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -314,6 +314,14 @@ export interface ScaffolderGetIntegrationsListResponse { }[]; } +// @public (undocumented) +export type ScaffolderOutputLink = { + title?: string; + icon?: string; + url?: string; + entityRef?: string; +}; + // Warning: (ae-missing-release-tag) "ScaffolderPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -372,12 +380,8 @@ export type ScaffolderTask = { createdAt: string; }; -// Warning: (ae-missing-release-tag) "ScaffolderTaskOutput" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type ScaffolderTaskOutput = { - entityRef?: string; - remoteUrl?: string; links?: ScaffolderOutputLink[]; } & { [key: string]: unknown; @@ -451,8 +455,4 @@ export const TemplateTypePicker: () => JSX.Element | null; // @public export const useTemplateSecrets: () => ScaffolderUseTemplateSecrets; - -// Warnings were encountered during analysis: -// -// src/types.d.ts:32:5 - (ae-forgotten-export) The symbol "ScaffolderOutputLink" needs to be exported by the entry point index.d.ts ``` diff --git a/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx b/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx index e0445ed641..aab5e8348a 100644 --- a/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx +++ b/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx @@ -217,12 +217,8 @@ export const TaskStatusStepper = memo( }, ); -const hasLinks = ({ - entityRef, - remoteUrl, - links = [], -}: ScaffolderTaskOutput): boolean => - !!(entityRef || remoteUrl || links.length > 0); +const hasLinks = ({ links = [] }: ScaffolderTaskOutput): boolean => + links.length > 0; /** * TaskPageProps for constructing a TaskPage diff --git a/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.test.tsx b/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.test.tsx index 8316b67ff5..2f5d015f8d 100644 --- a/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.test.tsx +++ b/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.test.tsx @@ -26,43 +26,6 @@ describe('TaskPageLinks', () => { jest.resetAllMocks(); }); - it('renders the entityRef link', async () => { - const output = { entityRef: 'Component:default/my-app' }; - const { findByText } = await renderInTestApp( - , - { - mountedRoutes: { - '/catalog/:namespace/:kind/:name/*': entityRouteRef, - }, - }, - ); - - const element = await findByText('Open in catalog'); - - expect(element).toBeInTheDocument(); - expect(element).toHaveAttribute( - 'href', - '/catalog/default/Component/my-app', - ); - }); - - it('renders the remoteUrl link', async () => { - const output = { remoteUrl: 'https://remote.url' }; - const { findByText } = await renderInTestApp( - , - { - mountedRoutes: { - '/catalog/:namespace/:kind/:name/*': entityRouteRef, - }, - }, - ); - - const element = await findByText('Repo'); - - expect(element).toBeInTheDocument(); - expect(element).toHaveAttribute('href', 'https://remote.url'); - }); - it('renders further links', async () => { const output = { links: [ diff --git a/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.tsx b/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.tsx index 5451b4e725..cb77689b6e 100644 --- a/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.tsx +++ b/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.tsx @@ -28,29 +28,13 @@ type TaskPageLinksProps = { }; export const TaskPageLinks = ({ output }: TaskPageLinksProps) => { - const { entityRef: entityRefOutput, remoteUrl } = output; - let { links = [] } = output; + const { links = [] } = output; const app = useApp(); const entityRoute = useRouteRef(entityRouteRef); const iconResolver = (key?: string): IconComponent => key ? app.getSystemIcon(key) ?? LanguageIcon : LanguageIcon; - if (remoteUrl) { - links = [{ url: remoteUrl, title: 'Repo' }, ...links]; - } - - if (entityRefOutput) { - links = [ - { - entityRef: entityRefOutput, - title: 'Open in catalog', - icon: 'catalog', - }, - ...links, - ]; - } - return ( {links diff --git a/plugins/scaffolder/src/index.ts b/plugins/scaffolder/src/index.ts index f33cf289f4..34b9155d66 100644 --- a/plugins/scaffolder/src/index.ts +++ b/plugins/scaffolder/src/index.ts @@ -28,6 +28,7 @@ export type { ScaffolderApi, ScaffolderGetIntegrationsListOptions, ScaffolderGetIntegrationsListResponse, + ScaffolderOutputLink, ScaffolderScaffoldOptions, ScaffolderScaffoldResponse, ScaffolderStreamLogsOptions, diff --git a/plugins/scaffolder/src/types.ts b/plugins/scaffolder/src/types.ts index 0ffbd601a8..069c28d85c 100644 --- a/plugins/scaffolder/src/types.ts +++ b/plugins/scaffolder/src/types.ts @@ -43,18 +43,16 @@ export type ListActionsResponse = Array<{ }; }>; -type ScaffolderOutputLink = { +/** @public */ +export type ScaffolderOutputLink = { title?: string; icon?: string; url?: string; entityRef?: string; }; +/** @public */ export type ScaffolderTaskOutput = { - /** @deprecated use the `links` property to link out to relevant resources */ - entityRef?: string; - /** @deprecated use the `links` property to link out to relevant resources */ - remoteUrl?: string; links?: ScaffolderOutputLink[]; } & { [key: string]: unknown;