Skip to content

Commit

Permalink
NickAkhmetov/CAT-751 Prevent full-page errors from malformed provenan…
Browse files Browse the repository at this point in the history
…ce data (#3560)
  • Loading branch information
NickAkhmetov authored Oct 7, 2024
1 parent c4bb547 commit 60d5a49
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
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">
<Typography variant="body2">{error?.message}</Typography>
</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

0 comments on commit 60d5a49

Please sign in to comment.