add Dismissable Error Banner

Signed-off-by: mufaddal motiwala <mufaddalmm.52@gmail.com>
This commit is contained in:
mufaddal motiwala
2022-09-05 01:16:22 +05:30
parent 5e9b41fcf6
commit f0510a20b5
4 changed files with 45 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder': patch
---
Addition of a Dismissable Error Banner in Scaffolder page
@@ -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 ? (
<Box>
<DismissableBanner
id={String(Math.random())}
variant="warning"
message={taskStream.error.message}
/>
</Box>
) : null;
};
@@ -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 && <Progress />}
<div style={{ height: '80vh' }}>
<TaskErrors taskStream={taskStream} />
<LogViewer text={logAsString} />
</div>
</Grid>
@@ -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;
}