Commit f4981856 authored by Robert Knight's avatar Robert Knight

Add direct linking feature flag

Add a feature flag for direct linking and
use the link provided by the API to a view of
the annotation in context when this flag is enabled.
parent 981e6613
......@@ -109,13 +109,22 @@ function updateDomainModel(domainModel, vm, permissions) {
}
/** Update the view model from the domain model changes. */
function updateViewModel($scope, time, domainModel, vm, permissions) {
function updateViewModel($scope, time, domainModel,
vm, permissions) {
vm.form = {
text: domainModel.text,
tags: viewModelTagsFromDomainModelTags(domainModel.tags),
};
vm.annotationURI = new URL('/a/' + domainModel.id, vm.serviceUrl).href;
if (domainModel.links) {
vm.annotationURI = domainModel.links.incontext ||
domainModel.links.html ||
'';
} else {
vm.annotationURI = '';
}
vm.isPrivate = permissions.isPrivate(
domainModel.permissions, domainModel.user);
......
......@@ -347,7 +347,7 @@ describe('annotation', function() {
};
var fakeFeatures = {
flagEnabled: sandbox.stub().returns(true)
flagEnabled: sandbox.stub().returns(true),
};
fakeFlash = {
......@@ -1496,5 +1496,32 @@ describe('annotation', function() {
'https://test.hypothes.is/stream?q=tag:atag');
});
});
describe('annotation metadata', function () {
function findLink(directive) {
var links = directive.element[0]
.querySelectorAll('header .annotation-link');
return links[links.length-1];
}
it('displays HTML links when in-context links are not available', function () {
var annotation = Object.assign({}, fixtures.defaultAnnotation(), {
links: {html: 'https://test.hypothes.is/a/deadbeef'},
});
var directive = createDirective(annotation);
assert.equal(findLink(directive).href, annotation.links.html);
});
it('displays 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 directive = createDirective(annotation);
assert.equal(findLink(directive).href, annotation.links.incontext);
});
});
});
});
'use strict';
/**
* Return a fake annotation with the basic properties filled in.
*/
......
......@@ -49,7 +49,7 @@
target="_blank"
title="{{vm.absoluteTimestamp}}"
ng-if="!vm.editing() && vm.updated()"
ng-href="{{::vm.serviceUrl}}a/{{vm.id()}}"
ng-href="{{vm.annotationURI}}"
>{{vm.relativeTimestamp}}</a>
</header>
......
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