Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions ui/src/components/molecules/DAGErrorSnackBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { Alert, AlertTitle, Box, Snackbar} from "@mui/material";
import React from "react";

type DAGErrorSnackBarProps = {
open: boolean;
setOpen: (open: boolean) => void;
errors: string[];
};

const DAGErrorSnackBar = ({ open, setOpen, errors }: DAGErrorSnackBarProps) => {
const handleClose = () => {
setOpen(false);
};

return (
<Snackbar
anchorOrigin={{
vertical: 'top',
horizontal: 'center',
}}
security="error"
open={open}
autoHideDuration={6000}
onClose={handleClose}
>
<Alert
severity="error"
sx={{
width: '20vw',
}}
onClose={handleClose}
>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<AlertTitle
sx={{
color: '#FF4D4D',
fontSize: '1.5rem',
}}
>Error Detected</AlertTitle>
<Box
sx={{
color: '#FC7E7E',
fontSize: '1.2rem',
}}
>
Please check the following errors:
</Box>
{errors.map((error, index) => (
<Box key={index}
sx={{
color: '#FC7E7E',
fontSize: '1rem',
margin: '2px',
}}
>
{error}
</Box>
))}
</Box>
</Alert>
</Snackbar>
);
}

export default DAGErrorSnackBar;
14 changes: 10 additions & 4 deletions ui/src/pages/dags/dag/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useMemo } from 'react';
import { Link, useParams, useLocation } from 'react-router-dom';
import { GetDAGResponse } from '../../../models/api';
import DAGSpecErrors from '../../../components/molecules/DAGSpecErrors';
import DAGStatus from '../../../components/organizations/DAGStatus';
import { DAGContext } from '../../../contexts/DAGContext';
import DAGSpec from '../../../components/organizations/DAGSpec';
Expand All @@ -14,6 +13,7 @@ import DAGEditButtons from '../../../components/molecules/DAGEditButtons';
import LoadingIndicator from '../../../components/atoms/LoadingIndicator';
import { AppBarContext } from '../../../contexts/AppBarContext';
import useSWR from 'swr';
import DAGErrorSnackBar from '../../../components/molecules/DAGErrorSnackBar';

type Params = {
name: string;
Expand All @@ -24,6 +24,7 @@ function DAGDetails() {
const params = useParams<Params>();
const appBarContext = React.useContext(AppBarContext);
const { pathname } = useLocation();
const [open, setOpen] = React.useState(true);

const baseUrl = useMemo(
() => `/dags/${encodeURI(params.name!)}`,
Expand All @@ -47,6 +48,9 @@ function DAGDetails() {
if (data) {
appBarContext.setTitle(data.Title);
}
if (data && data.Errors.length > 0 && params.tab == 'spec') {
setOpen(true);
}
}, [data, appBarContext]);

const tab = useMemo(() => {
Expand Down Expand Up @@ -112,9 +116,11 @@ function DAGDetails() {
) : null}
</Stack>

<Box sx={{ mt: 2, mx: 4 }}>
<DAGSpecErrors errors={data.Errors} />
</Box>
<DAGErrorSnackBar
open={open}
setOpen={setOpen}
errors={data.Errors}
/>

<Box sx={{ mx: 4, flex: 1 }}>
{tab == 'status' ? (
Expand Down