Skip to content

Commit

Permalink
Fix issue where radar entry dialog with external url
Browse files Browse the repository at this point in the history
If an entry has both a radar description and an external url, when
a user clicks on the blip the description dialog would briefly
appear before they are redirected to the specified url.

Expected behaviour is not to automatically redirect the user so that
they can read the dialog and choose to follow the link for more details.

Signed-off-by: Niall McCullagh <[email protected]>
Signed-off-by: Niall McCullagh <[email protected]>
  • Loading branch information
niallmccullagh committed Mar 9, 2021
1 parent c111312 commit b56815b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-rings-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/plugin-tech-radar': patch
---

Fixes issue where radar description dialog is not shown when the entry has an url external to the radar page
16 changes: 16 additions & 0 deletions plugins/tech-radar/src/components/RadarEntry/RadarEntry.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,20 @@ describe('RadarEntry', () => {
expect(radarDescription).toBeInTheDocument();
expect(screen.getByText(String(minProps.value))).toBeInTheDocument();
});

it('should render blip with url equal to # if description present', () => {
const withUrl = {
...optionalProps,
url: 'http://backstage.io',
};
render(
<ThemeProvider theme={lightTheme}>
<svg>
<RadarEntry {...withUrl} />
</svg>
</ThemeProvider>,
);

expect(screen.getByRole('button')).toHaveAttribute('href', '#');
});
});
3 changes: 2 additions & 1 deletion plugins/tech-radar/src/components/RadarEntry/RadarEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ const RadarEntry = (props: Props): JSX.Element => {
/>
)}
{description ? (
// eslint-disable-next-line jsx-a11y/anchor-is-valid
<a
className={classes.link}
onClick={handleClickOpen}
href={url ? url : '#'}
role="button"
href="#"
tabIndex={0}
onKeyPress={toggle}
>
Expand Down
4 changes: 3 additions & 1 deletion plugins/tech-radar/src/sampleData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ entries.push({
moved: 1,
ringId: 'use',
date: new Date('2020-08-06'),
description:
'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur',
},
],
url: '#',
url: 'https://webpack.js.org/',
key: 'webpack',
id: 'webpack',
title: 'Webpack',
Expand Down

0 comments on commit b56815b

Please sign in to comment.