Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NickAkhmetov/CAT-751 Prevent full-page errors from malformed provenance data #3560

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG-cat-751.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Prevent malformed provenance graph data from crashing the entire page.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { FaroErrorBoundary } from '@grafana/faro-react';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';
import DetailsAccordion from 'js/shared-styles/accordions/DetailsAccordion';
import React from 'react';

interface ErrorBoundaryProps {
children: React.ReactNode;
}

function ErrorFallback(error: Error) {
return (
<Stack p={4}>
<Typography variant="subtitle1">An error occurred while attempting to display the provenance graph.</Typography>
<DetailsAccordion summary="Click to expand error details">
<div>{error?.message}</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this div be a Typography instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll swap it in and use body2 👍🏻

</DetailsAccordion>
</Stack>
);
}

export default function ProvGraphErrorBoundary({ children }: ErrorBoundaryProps) {
return <FaroErrorBoundary fallback={ErrorFallback}>{children}</FaroErrorBoundary>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function ProvSection() {
<SectionDescription>
<Description />
</SectionDescription>

<ProvTabs provData={provData} />
</CollapsibleDetailPageSection>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ProvTable from '../ProvTable';
import { hasDataTypes } from './utils';
import { filterTabsToDisplay } from './filterTabsToDisplay';
import { ProvData } from '../types';
import ProvGraphErrorBoundary from '../ProvGraph/ProvGraphErrorBoundary';

const availableTabDetails = {
multi: { label: 'Multi-Assay', 'data-testid': 'multi-prov-tab' },
Expand Down Expand Up @@ -67,7 +68,9 @@ function ProvTabs({ provData }: ProvTabsProps) {
)}
{filteredTabs?.graph && (
<TabPanel value={open} index={filteredTabs.graph.index}>
<ProvGraph provData={provData} entity_type={entity_type} uuid={uuid} />
<ProvGraphErrorBoundary>
<ProvGraph provData={provData} entity_type={entity_type} uuid={uuid} />
</ProvGraphErrorBoundary>
</TabPanel>
)}
</Paper>
Expand Down
Loading