diff --git a/.changeset/smart-boxes-double.md b/.changeset/smart-boxes-double.md index 64a2fe9656..81d708297e 100644 --- a/.changeset/smart-boxes-double.md +++ b/.changeset/smart-boxes-double.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder': patch --- -The ScaffolderPage can be passed an optional `loadingHoldingText` string. It will replace the Loading text in the scaffolder task page. +The ScaffolderPage can be passed an optional `TaskPageComponent` with a `loadingText` string. It will replace the Loading text in the scaffolder task page. diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index c7a95f177e..befafc766b 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -21,8 +21,10 @@ import { FieldValidation } from '@rjsf/core'; import { IconButton } from '@material-ui/core'; import { JsonObject } from '@backstage/types'; import { JSONSchema } from '@backstage/catalog-model'; +import { JSXElementConstructor } from 'react'; import { Observable } from '@backstage/types'; import { default as React_2 } from 'react'; +import { ReactElement } from 'react'; import { ReactNode } from 'react'; import { RouteRef } from '@backstage/core-plugin-api'; import { ScmIntegrationRegistry } from '@backstage/integration'; @@ -245,15 +247,17 @@ export const ScaffolderFieldExtensions: React_2.ComponentType; // @public (undocumented) export const ScaffolderPage: ({ TemplateCardComponent, + TaskPageComponent, groups, - loadingHoldingText, }: { - loadingHoldingText?: string | undefined; TemplateCardComponent?: | ComponentType<{ template: TemplateEntityV1beta2; }> | undefined; + TaskPageComponent?: + | ReactElement> + | undefined; groups?: | { title?: string | undefined; @@ -277,6 +281,12 @@ const scaffolderPlugin: BackstagePlugin< export { scaffolderPlugin as plugin }; export { scaffolderPlugin }; +// Warning: (ae-forgotten-export) The symbol "TaskPageProps" needs to be exported by the entry point index.d.ts +// Warning: (ae-missing-release-tag) "TaskPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const TaskPage: ({ loadingText }: TaskPageProps) => JSX.Element; + // Warning: (ae-missing-release-tag) "TemplateList" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) diff --git a/plugins/scaffolder/src/components/Router.tsx b/plugins/scaffolder/src/components/Router.tsx index 10a78e1071..17a1606bc9 100644 --- a/plugins/scaffolder/src/components/Router.tsx +++ b/plugins/scaffolder/src/components/Router.tsx @@ -31,10 +31,10 @@ import { import { useElementFilter } from '@backstage/core-plugin-api'; type RouterProps = { - loadingHoldingText?: string; TemplateCardComponent?: | ComponentType<{ template: TemplateEntityV1beta2 }> | undefined; + TaskPageComponent?: React.ReactElement | undefined; groups?: Array<{ title?: string; titleComponent?: React.ReactNode; @@ -44,10 +44,11 @@ type RouterProps = { export const Router = ({ TemplateCardComponent, + TaskPageComponent, groups, - loadingHoldingText, }: RouterProps) => { const outlet = useOutlet(); + const TaskPageElement = TaskPageComponent || ; const customFieldExtensions = useElementFilter(outlet, elements => elements @@ -84,10 +85,7 @@ export const Router = ({ path="/templates/:templateName" element={} /> - } - /> + } /> ); diff --git a/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx b/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx index 04e303b4f4..065c7b4478 100644 --- a/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx +++ b/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx @@ -219,10 +219,10 @@ const hasLinks = ({ entityRef, remoteUrl, links = [] }: TaskOutput): boolean => !!(entityRef || remoteUrl || links.length > 0); type TaskPageProps = { - loadingHoldingText?: string; + loadingText?: string; }; -export const TaskPage = ({ loadingHoldingText }: TaskPageProps) => { +export const TaskPage = ({ loadingText }: TaskPageProps) => { const classes = useStyles(); const navigate = useNavigate(); const rootLink = useRouteRef(rootRouteRef); @@ -260,7 +260,7 @@ export const TaskPage = ({ loadingHoldingText }: TaskPageProps) => { const logAsString = useMemo(() => { if (!currentStepId) { - return loadingHoldingText ? loadingHoldingText : 'Loading...'; + return loadingText ? loadingText : 'Loading...'; } const log = taskStream.stepLogs[currentStepId]; @@ -268,7 +268,7 @@ export const TaskPage = ({ loadingHoldingText }: TaskPageProps) => { return 'Waiting for logs...'; } return log.join('\n'); - }, [taskStream.stepLogs, currentStepId, loadingHoldingText]); + }, [taskStream.stepLogs, currentStepId, loadingText]); const taskNotFound = taskStream.completed === true && diff --git a/plugins/scaffolder/src/index.ts b/plugins/scaffolder/src/index.ts index 3cf65d7a07..893ab82025 100644 --- a/plugins/scaffolder/src/index.ts +++ b/plugins/scaffolder/src/index.ts @@ -56,3 +56,4 @@ export { FavouriteTemplate } from './components/FavouriteTemplate'; export { TemplateList } from './components/TemplateList'; export type { TemplateListProps } from './components/TemplateList'; export { TemplateTypePicker } from './components/TemplateTypePicker'; +export { TaskPage } from './components/TaskPage';