diff --git a/.changeset/new-taxis-vanish.md b/.changeset/new-taxis-vanish.md new file mode 100644 index 0000000000..c461d06824 --- /dev/null +++ b/.changeset/new-taxis-vanish.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': patch +--- + +Addition of a Dismissable Error Banner in Scaffolder page diff --git a/plugins/scaffolder/src/components/TaskPage/TaskErrors.tsx b/plugins/scaffolder/src/components/TaskPage/TaskErrors.tsx new file mode 100644 index 0000000000..3d82bfc5a3 --- /dev/null +++ b/plugins/scaffolder/src/components/TaskPage/TaskErrors.tsx @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 { Box } from '@material-ui/core'; +import React from 'react'; +import { DismissableBanner } from '@backstage/core-components'; +import { TaskStream } from '../hooks/useEventStream'; + +type TaskPageLinksProps = { + taskStream: TaskStream; +}; + +export const TaskErrors = ({ taskStream }: TaskPageLinksProps) => { + return taskStream.error ? ( + + + + ) : null; +}; diff --git a/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx b/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx index 3dd54e1d09..4fa5968216 100644 --- a/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx +++ b/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx @@ -54,6 +54,7 @@ import { } from '../../routes'; import { ScaffolderTaskStatus, ScaffolderTaskOutput } from '../../types'; import { useTaskEventStream } from '../hooks/useEventStream'; +import { TaskErrors } from './TaskErrors'; import { TaskPageLinks } from './TaskPageLinks'; // typings are wrong for this library, so fallback to not parsing types. @@ -356,6 +357,7 @@ export const TaskPage = ({ loadingText }: TaskPageProps) => { {!currentStepId && }
+
diff --git a/plugins/scaffolder/src/components/hooks/useEventStream.ts b/plugins/scaffolder/src/components/hooks/useEventStream.ts index 8ff9a30d0b..bb24c0d612 100644 --- a/plugins/scaffolder/src/components/hooks/useEventStream.ts +++ b/plugins/scaffolder/src/components/hooks/useEventStream.ts @@ -49,6 +49,7 @@ type ReducerLogEntry = { status?: ScaffolderTaskStatus; message: string; output?: ScaffolderTaskOutput; + error?: Error; }; }; @@ -114,6 +115,8 @@ function reducer(draft: TaskStream, action: ReducerAction) { case 'COMPLETED': { draft.completed = true; draft.output = action.data.body.output; + draft.error = action.data.body.error; + return; }