Commit d25b5981 authored by Nick Stenning's avatar Nick Stenning

Use the "HTML" link for the annotation timestamp

The timestamp wasn't originally specified to be switched to the
"in-context" link, so this commit makes sure that it always points to
the "HTML" representation of the annotation, if that link is available.
parent 23b3020f
......@@ -120,11 +120,13 @@ function updateViewModel($scope, time, domainModel,
};
if (domainModel.links) {
vm.annotationURI = domainModel.links.incontext ||
vm.linkInContext = domainModel.links.incontext ||
domainModel.links.html ||
'';
vm.linkHTML = domainModel.links.html || '';
} else {
vm.annotationURI = '';
vm.linkInContext = '';
vm.linkHTML = '';
}
vm.isPrivate = permissions.isPrivate(
......
......@@ -1424,30 +1424,54 @@ describe('annotation', function() {
});
});
describe('annotation metadata', function () {
function findLink(directive) {
var links = directive.element[0]
.querySelectorAll('header .annotation-header__timestamp');
return links[links.length-1];
}
describe('annotation links', function () {
it('linkInContext uses the in-context links when available', function () {
var annotation = Object.assign({}, fixtures.defaultAnnotation(), {
links: {
html: 'https://test.hypothes.is/a/deadbeef',
incontext: 'https://hpt.is/deadbeef'
},
});
var controller = createDirective(annotation).controller;
assert.equal(controller.linkInContext, annotation.links.incontext);
});
it('displays HTML links when in-context links are not available', function () {
it('linkInContext falls back to the HTML link when in-context links are missing', function () {
var annotation = Object.assign({}, fixtures.defaultAnnotation(), {
links: {html: 'https://test.hypothes.is/a/deadbeef'},
links: {
html: 'https://test.hypothes.is/a/deadbeef',
},
});
var directive = createDirective(annotation);
assert.equal(findLink(directive).href, annotation.links.html);
var controller = createDirective(annotation).controller;
assert.equal(controller.linkInContext, annotation.links.html);
});
it('displays in-context links when available', function () {
it('linkHTML uses the HTML link when available', function () {
var annotation = Object.assign({}, fixtures.defaultAnnotation(), {
links: {
html: 'https://test.hypothes.is/a/deadbeef',
incontext: 'https://hpt.is/deadbeef'
},
});
var directive = createDirective(annotation);
assert.equal(findLink(directive).href, annotation.links.incontext);
var controller = createDirective(annotation).controller;
assert.equal(controller.linkHTML, annotation.links.html);
});
it('linkInContext is blank when unknown', function () {
var annotation = fixtures.defaultAnnotation();
var controller = createDirective(annotation).controller;
assert.equal(controller.linkInContext, '');
});
it('linkHTML is blank when unknown', function () {
var annotation = fixtures.defaultAnnotation();
var controller = createDirective(annotation).controller;
assert.equal(controller.linkHTML, '');
});
});
});
......
......@@ -45,7 +45,7 @@
target="_blank"
title="{{vm.absoluteTimestamp}}"
ng-if="!vm.editing() && vm.updated()"
ng-href="{{vm.annotationURI}}"
ng-href="{{vm.linkHTML}}"
>{{vm.relativeTimestamp}}</a>
</header>
......@@ -183,7 +183,7 @@
</button>
<annotation-share-dialog
group="vm.group()"
uri="vm.annotationURI"
uri="vm.linkInContext"
is-private="vm.isPrivate"
is-open="vm.showShareDialog"
on-close="vm.showShareDialog = false">
......
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