Commit e9358e89 authored by Robert Knight's avatar Robert Knight

Use singular rather than plural for "directLinkedAnnotationId"

Despite the name of the settings key where this value is read from
(`settings.annotations`), only a single annotation is currently
supported. See the `initialSelection` function in
`store/modules/selection.js`.
parent 496a6735
...@@ -329,7 +329,7 @@ function SidebarContentController( ...@@ -329,7 +329,7 @@ function SidebarContentController(
// If user has not landed on a direct linked annotation // If user has not landed on a direct linked annotation
// don't show the CTA. // don't show the CTA.
if (!store.getState().directLinkedAnnotationsId) { if (!store.getState().directLinkedAnnotationId) {
return false; return false;
} }
......
...@@ -220,10 +220,10 @@ describe('sidebar.components.sidebar-content', function() { ...@@ -220,10 +220,10 @@ describe('sidebar.components.sidebar-content', function() {
assert.isFalse(store.getState().directLinkedGroupFetchFailed); assert.isFalse(store.getState().directLinkedGroupFetchFailed);
}); });
it("clears the direct linked id's from the settings", () => { it('clears the direct linked IDs in the store', () => {
ctrl.clearSelection(); ctrl.clearSelection();
assert.equal(store.getState().directLinkedAnnotationsId, null); assert.equal(store.getState().directLinkedAnnotationId, null);
assert.equal(store.getState().directLinkedGroupId, null); assert.equal(store.getState().directLinkedGroupId, null);
}); });
}); });
...@@ -595,7 +595,7 @@ describe('sidebar.components.sidebar-content', function() { ...@@ -595,7 +595,7 @@ describe('sidebar.components.sidebar-content', function() {
} }
beforeEach(function() { beforeEach(function() {
store.setDirectLinkedAnnotationsId('test'); store.setDirectLinkedAnnotationId('test');
}); });
it('displays a message if the selection is unavailable', function() { it('displays a message if the selection is unavailable', function() {
...@@ -677,7 +677,7 @@ describe('sidebar.components.sidebar-content', function() { ...@@ -677,7 +677,7 @@ describe('sidebar.components.sidebar-content', function() {
ctrl.auth = { ctrl.auth = {
status: 'logged-out', status: 'logged-out',
}; };
store.setDirectLinkedAnnotationsId(null); store.setDirectLinkedAnnotationId(null);
store.addAnnotations([{ id: '123' }]); store.addAnnotations([{ id: '123' }]);
store.selectAnnotations(['123']); store.selectAnnotations(['123']);
$scope.$digest(); $scope.$digest();
......
...@@ -167,7 +167,7 @@ function groups( ...@@ -167,7 +167,7 @@ function groups(
uri = getDocumentUriForGroupSearch(); uri = getDocumentUriForGroupSearch();
} }
const directLinkedGroupId = store.getState().directLinkedGroupId; const directLinkedGroupId = store.getState().directLinkedGroupId;
const directLinkedAnnId = store.getState().directLinkedAnnotationsId; const directLinkedAnnId = store.getState().directLinkedAnnotationId;
let directLinkedAnnotationGroupId = null; let directLinkedAnnotationGroupId = null;
return uri return uri
.then(uri => { .then(uri => {
......
...@@ -65,7 +65,7 @@ describe('groups', function() { ...@@ -65,7 +65,7 @@ describe('groups', function() {
focusedGroup: null, focusedGroup: null,
groups: [], groups: [],
directLinkedGroupId: null, directLinkedGroupId: null,
directLinkedAnnotationsId: null, directLinkedAnnotationId: null,
}, },
{ {
focusGroup: sinon.stub(), focusGroup: sinon.stub(),
...@@ -342,7 +342,7 @@ describe('groups', function() { ...@@ -342,7 +342,7 @@ describe('groups', function() {
it("sets the direct-linked annotation's group to take precedence over the group saved in local storage and the direct-linked group", () => { it("sets the direct-linked annotation's group to take precedence over the group saved in local storage and the direct-linked group", () => {
const svc = service(); const svc = service();
fakeStore.setState({ fakeStore.setState({
directLinkedAnnotationsId: 'ann-id', directLinkedAnnotationId: 'ann-id',
directLinkedGroupId: dummyGroups[1].id, directLinkedGroupId: dummyGroups[1].id,
}); });
fakeLocalStorage.getItem.returns(dummyGroups[0].id); fakeLocalStorage.getItem.returns(dummyGroups[0].id);
...@@ -360,7 +360,7 @@ describe('groups', function() { ...@@ -360,7 +360,7 @@ describe('groups', function() {
it("sets the focused group to the direct-linked annotation's group", () => { it("sets the focused group to the direct-linked annotation's group", () => {
const svc = service(); const svc = service();
fakeStore.setState({ directLinkedAnnotationsId: 'ann-id' }); fakeStore.setState({ directLinkedAnnotationId: 'ann-id' });
fakeApi.groups.list.returns(Promise.resolve(dummyGroups)); fakeApi.groups.list.returns(Promise.resolve(dummyGroups));
fakeLocalStorage.getItem.returns(dummyGroups[0].id); fakeLocalStorage.getItem.returns(dummyGroups[0].id);
fakeApi.annotation.get.returns( fakeApi.annotation.get.returns(
...@@ -470,7 +470,7 @@ describe('groups', function() { ...@@ -470,7 +470,7 @@ describe('groups', function() {
it('catches error when fetching the direct-linked annotation', () => { it('catches error when fetching the direct-linked annotation', () => {
const svc = service(); const svc = service();
fakeStore.setState({ directLinkedAnnotationsId: 'ann-id' }); fakeStore.setState({ directLinkedAnnotationId: 'ann-id' });
fakeApi.profile.groups.read.returns(Promise.resolve([])); fakeApi.profile.groups.read.returns(Promise.resolve([]));
fakeApi.groups.list.returns( fakeApi.groups.list.returns(
...@@ -494,7 +494,7 @@ describe('groups', function() { ...@@ -494,7 +494,7 @@ describe('groups', function() {
it("catches error when fetching the direct-linked annotation's group", () => { it("catches error when fetching the direct-linked annotation's group", () => {
const svc = service(); const svc = service();
fakeStore.setState({ directLinkedAnnotationsId: 'ann-id' }); fakeStore.setState({ directLinkedAnnotationId: 'ann-id' });
fakeApi.profile.groups.read.returns(Promise.resolve([])); fakeApi.profile.groups.read.returns(Promise.resolve([]));
fakeApi.groups.list.returns( fakeApi.groups.list.returns(
...@@ -530,7 +530,7 @@ describe('groups', function() { ...@@ -530,7 +530,7 @@ describe('groups', function() {
it("includes the direct-linked annotation's group when it is not in the normal list of groups", () => { it("includes the direct-linked annotation's group when it is not in the normal list of groups", () => {
const svc = service(); const svc = service();
fakeStore.setState({ directLinkedAnnotationsId: 'ann-id' }); fakeStore.setState({ directLinkedAnnotationId: 'ann-id' });
fakeApi.profile.groups.read.returns(Promise.resolve([])); fakeApi.profile.groups.read.returns(Promise.resolve([]));
fakeApi.groups.list.returns( fakeApi.groups.list.returns(
...@@ -564,7 +564,7 @@ describe('groups', function() { ...@@ -564,7 +564,7 @@ describe('groups', function() {
fakeStore.setState({ fakeStore.setState({
directLinkedGroupId: 'out-of-scope', directLinkedGroupId: 'out-of-scope',
directLinkedAnnotationsId: 'ann-id', directLinkedAnnotationId: 'ann-id',
}); });
fakeApi.profile.groups.read.returns(Promise.resolve([])); fakeApi.profile.groups.read.returns(Promise.resolve([]));
...@@ -603,7 +603,7 @@ describe('groups', function() { ...@@ -603,7 +603,7 @@ describe('groups', function() {
fakeStore.setState({ fakeStore.setState({
directLinkedGroupId: '__world__', directLinkedGroupId: '__world__',
directLinkedAnnotationsId: null, directLinkedAnnotationId: null,
}); });
fakeApi.profile.groups.read.returns(Promise.resolve([])); fakeApi.profile.groups.read.returns(Promise.resolve([]));
...@@ -643,7 +643,7 @@ describe('groups', function() { ...@@ -643,7 +643,7 @@ describe('groups', function() {
}) })
); );
fakeStore.setState({ fakeStore.setState({
directLinkedAnnotationsId: 'direct-linked-ann', directLinkedAnnotationId: 'direct-linked-ann',
}); });
} }
......
...@@ -14,7 +14,7 @@ function init(settings) { ...@@ -14,7 +14,7 @@ function init(settings) {
* The id of the direct-linked annotation's group. * The id of the direct-linked annotation's group.
* @type {string} * @type {string}
*/ */
directLinkedAnnotationsId: settings.annotations || null, directLinkedAnnotationId: settings.annotations || null,
/** /**
* Indicates that an error occured in retrieving/showing the direct linked group. * Indicates that an error occured in retrieving/showing the direct linked group.
...@@ -39,14 +39,14 @@ const update = { ...@@ -39,14 +39,14 @@ const update = {
directLinkedGroupId: action.directLinkedGroupId, directLinkedGroupId: action.directLinkedGroupId,
}; };
}, },
UPDATE_DIRECT_LINKED_ANNOTATIONS_ID(state, action) { UPDATE_DIRECT_LINKED_ANNOTATION_ID(state, action) {
return { return {
directLinkedAnnotationsId: action.directLinkedAnnotationsId, directLinkedAnnotationId: action.directLinkedAnnotationId,
}; };
}, },
CLEAR_DIRECT_LINKED_IDS() { CLEAR_DIRECT_LINKED_IDS() {
return { return {
directLinkedAnnotationsId: null, directLinkedAnnotationId: null,
directLinkedGroupId: null, directLinkedGroupId: null,
}; };
}, },
...@@ -67,10 +67,10 @@ function setDirectLinkedGroupId(groupId) { ...@@ -67,10 +67,10 @@ function setDirectLinkedGroupId(groupId) {
/** /**
* Set the direct linked annotation's id. * Set the direct linked annotation's id.
*/ */
function setDirectLinkedAnnotationsId(annId) { function setDirectLinkedAnnotationId(annId) {
return { return {
type: actions.UPDATE_DIRECT_LINKED_ANNOTATIONS_ID, type: actions.UPDATE_DIRECT_LINKED_ANNOTATION_ID,
directLinkedAnnotationsId: annId, directLinkedAnnotationId: annId,
}; };
} }
...@@ -109,7 +109,7 @@ module.exports = { ...@@ -109,7 +109,7 @@ module.exports = {
actions: { actions: {
setDirectLinkedGroupFetchFailed, setDirectLinkedGroupFetchFailed,
setDirectLinkedGroupId, setDirectLinkedGroupId,
setDirectLinkedAnnotationsId, setDirectLinkedAnnotationId,
clearDirectLinkedGroupFetchFailed, clearDirectLinkedGroupFetchFailed,
clearDirectLinkedIds, clearDirectLinkedIds,
}, },
......
...@@ -25,18 +25,18 @@ describe('sidebar/store/modules/direct-linked', () => { ...@@ -25,18 +25,18 @@ describe('sidebar/store/modules/direct-linked', () => {
assert.isFalse(store.getState().directLinkedGroupFetchFailed); assert.isFalse(store.getState().directLinkedGroupFetchFailed);
}); });
it('sets directLinkedAnnotationsId to settings.annotations during store init', () => { it('sets directLinkedAnnotationId to settings.annotations during store init', () => {
fakeSettings.annotations = 'ann-id'; fakeSettings.annotations = 'ann-id';
store = createStore([directLinked], [fakeSettings]); store = createStore([directLinked], [fakeSettings]);
assert.equal(store.getState().directLinkedAnnotationsId, 'ann-id'); assert.equal(store.getState().directLinkedAnnotationId, 'ann-id');
}); });
it('sets directLinkedAnnotationsId to the specified annotation id', () => { it('sets directLinkedAnnotationId to the specified annotation id', () => {
store.setDirectLinkedAnnotationsId('ann-id'); store.setDirectLinkedAnnotationId('ann-id');
assert.equal(store.getState().directLinkedAnnotationsId, 'ann-id'); assert.equal(store.getState().directLinkedAnnotationId, 'ann-id');
}); });
it('sets directLinkedGroupId to settings.group during store init', () => { it('sets directLinkedGroupId to settings.group during store init', () => {
...@@ -59,7 +59,7 @@ describe('sidebar/store/modules/direct-linked', () => { ...@@ -59,7 +59,7 @@ describe('sidebar/store/modules/direct-linked', () => {
store.clearDirectLinkedIds(); store.clearDirectLinkedIds();
assert.equal(store.getState().directLinkedAnnotationsId, null); assert.equal(store.getState().directLinkedAnnotationId, null);
assert.equal(store.getState().directLinkedGroupId, null); assert.equal(store.getState().directLinkedGroupId, null);
}); });
}); });
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