Commit 37803f91 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Make links to annotation documents open in new tab/window

Open links to documents in a new tab. This is important in the Notebook
view at present to "escape" the Notebook's frame, but makes sense in
all contexts as it more closely adheres to our pattern of opening links
to external properties in new windows.
parent 76d03be3
...@@ -20,7 +20,13 @@ export default function AnnotationDocumentInfo({ domain, link, title }) { ...@@ -20,7 +20,13 @@ export default function AnnotationDocumentInfo({ domain, link, title }) {
<div className="u-layout-row u-horizontal-rhythm"> <div className="u-layout-row u-horizontal-rhythm">
<div className="u-color-text--muted"> <div className="u-color-text--muted">
on &quot; on &quot;
{link ? <a href={link}>{title}</a> : <span>{title}</span>} {link ? (
<a href={link} target="_blank" rel="noopener noreferrer">
{title}
</a>
) : (
<span>{title}</span>
)}
&quot; &quot;
</div> </div>
{domain && <span className="u-color-text--muted">({domain})</span>} {domain && <span className="u-color-text--muted">({domain})</span>}
......
...@@ -22,17 +22,22 @@ describe('AnnotationDocumentInfo', () => { ...@@ -22,17 +22,22 @@ describe('AnnotationDocumentInfo', () => {
assert.include(wrapper.text(), '"Turtles"'); assert.include(wrapper.text(), '"Turtles"');
}); });
it('should render a link if available', () => { it('links to document in new tab/window when link available', () => {
const wrapper = createAnnotationDocumentInfo(); const wrapper = createAnnotationDocumentInfo();
const link = wrapper.find('a'); const link = wrapper.find('a');
assert.equal(link.prop('href'), 'http://www.baz'); assert.equal(link.prop('href'), 'http://www.baz');
assert.equal(link.prop('target'), '_blank');
}); });
it('does not link to document when no link available', () => {});
it('should render domain if available', () => { it('should render domain if available', () => {
const wrapper = createAnnotationDocumentInfo(); const wrapper = createAnnotationDocumentInfo({ link: '' });
assert.include(wrapper.text(), '(www.foo.bar)'); const link = wrapper.find('a');
assert.include(wrapper.text(), '"Turtles"');
assert.isFalse(link.exists());
}); });
it( it(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment