Fix Sentry widget showing [No Type]
Signed-off-by: Miguel Alexandre <m.alexandrex@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-sentry': patch
|
||||
---
|
||||
|
||||
Do not show [No Type] when issue metadata includes title instead of type
|
||||
@@ -44,4 +44,24 @@ describe('Sentry error cell component', () => {
|
||||
'http://example.com',
|
||||
);
|
||||
});
|
||||
it('should render the title if type is not present', async () => {
|
||||
const testIssue = {
|
||||
...mockIssue,
|
||||
title: 'Exception: Could not load credentials from any providers',
|
||||
count: '1',
|
||||
metadata: {},
|
||||
userCount: 2,
|
||||
permalink: 'http://example.com',
|
||||
};
|
||||
const cell = render(
|
||||
<ThemeProvider theme={lightTheme}>
|
||||
<ErrorCell sentryIssue={testIssue} />
|
||||
</ThemeProvider>,
|
||||
);
|
||||
const errorType = await cell.findByText('Exception: Could not load cr...');
|
||||
expect(errorType.closest('a')).toHaveAttribute(
|
||||
'href',
|
||||
'http://example.com',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -44,13 +44,18 @@ const useStyles = makeStyles<BackstageTheme>(theme => ({
|
||||
|
||||
export const ErrorCell = ({ sentryIssue }: { sentryIssue: SentryIssue }) => {
|
||||
const classes = useStyles();
|
||||
let issueType = '[No Type]';
|
||||
if (sentryIssue.metadata.type) {
|
||||
issueType = sentryIssue.metadata.type;
|
||||
} else if (sentryIssue.title) {
|
||||
issueType = sentryIssue.title;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<Link href={sentryIssue.permalink}>
|
||||
<Typography variant="body1" gutterBottom className={classes.text}>
|
||||
{sentryIssue.metadata.type
|
||||
? stripText(sentryIssue.metadata.type, 28)
|
||||
: '[No type]'}
|
||||
{stripText(issueType, 28)}
|
||||
</Typography>
|
||||
</Link>
|
||||
<Typography
|
||||
|
||||
Reference in New Issue
Block a user