Don't link to tag pages for third-party annotations

Tag search pages aren't supported for third-party annotations in h, so
don't link to them from the client.

Fixes https://github.com/hypothesis/client/issues/616
parent 5cd296f8
...@@ -444,6 +444,9 @@ function AnnotationController( ...@@ -444,6 +444,9 @@ function AnnotationController(
}; };
this.tagSearchURL = function(tag) { this.tagSearchURL = function(tag) {
if (this.isThirdPartyUser()) {
return null;
}
return serviceUrl('search.tag', {tag: tag}); return serviceUrl('search.tag', {tag: tag});
}; };
......
...@@ -1068,22 +1068,57 @@ describe('annotation', function() { ...@@ -1068,22 +1068,57 @@ describe('annotation', function() {
}); });
describe('tag display', function () { describe('tag display', function () {
it('displays links to tags on the stream', function () { beforeEach('make serviceUrl() return a URL for the tag', function() {
fakeServiceUrl fakeServiceUrl
.withArgs('search.tag', {tag: 'atag'}) .withArgs('search.tag', {tag: 'atag'})
.returns('https://test.hypothes.is/stream?q=tag:atag'); .returns('https://test.hypothes.is/stream?q=tag:atag');
});
var directive = createDirective(Object.assign(fixtures.defaultAnnotation(), { /*
* Return an annotation directive with a single tag.
*/
function annotationWithOneTag() {
return createDirective(Object.assign(fixtures.defaultAnnotation(), {
tags: ['atag'], tags: ['atag'],
})); }));
}
/**
* Return the one tag link element from the given annotation directive.
*/
function tagLinkFrom(directive) {
var links = [].slice.apply(directive.element[0].querySelectorAll('a')); var links = [].slice.apply(directive.element[0].querySelectorAll('a'));
var tagLinks = links.filter(function (link) { var tagLinks = links.filter(function (link) {
return link.textContent === 'atag'; return link.textContent === 'atag';
}); });
assert.equal(tagLinks.length, 1); assert.equal(tagLinks.length, 1);
assert.equal(tagLinks[0].href, return tagLinks[0];
'https://test.hypothes.is/stream?q=tag:atag'); }
context('when the annotation is first-party', function() {
beforeEach('configure a first-party annotation', function() {
fakeAccountID.isThirdPartyUser.returns(false);
});
it('displays links to tags on the stream', function () {
var tagLink = tagLinkFrom(annotationWithOneTag());
assert.equal(tagLink.href, 'https://test.hypothes.is/stream?q=tag:atag');
});
});
context('when the annotation is third-party', function() {
beforeEach('configure a third-party annotation', function() {
fakeAccountID.isThirdPartyUser.returns(true);
});
it("doesn't link tags for third-party annotations", function () {
// Tag search pages aren't supported for third-party annotations in
// h, so we don't link to them in the client.
var tagLink = tagLinkFrom(annotationWithOneTag());
assert.isFalse(tagLink.hasAttribute('href'));
});
}); });
}); });
......
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