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