Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/modules/indexes.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,18 @@ export const loadIndexesFromDb = () => {
dispatch(loadIndexes([]));
dispatch(localAppRegistryEmit('indexes-changed', []));
} else {
const ns = state.namespace;
state.dataService.indexes(state.namespace, {}, (err, indexes) => {
if (err) {
dispatch(handleError(parseErrorMsg(err)));
dispatch(loadIndexes([]));
dispatch(localAppRegistryEmit('indexes-changed', []));
} else {
// Set the `ns` field manually as it is not returned from the server
// since version 4.4.
for (const index of indexes) {
index.ns = ns;
}
const ixs = modelAndSort(indexes, state.sortColumn, state.sortOrder);
dispatch(loadIndexes(ixs));
dispatch(localAppRegistryEmit('indexes-changed', ixs));
Expand Down
14 changes: 7 additions & 7 deletions src/modules/indexes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('indexes module', () => {
emit: emitSpy
},
isReadonly: true,
namespace: 'citibikes.trips'
namespace: 'citibike.trips'
});
loadIndexesFromDb()(dispatch, state);
expect(actionSpy.calledOnce).to.equal(true);
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('indexes module', () => {
dataService: {
indexes: (ns, opts, cb) => { cb({message: 'error message!'}); }
},
namespace: 'citibikes.trips'
namespace: 'citibike.trips'
});
loadIndexesFromDb()(dispatch, state);
expect(actionSpy.calledTwice).to.equal(true);
Expand All @@ -165,7 +165,7 @@ describe('indexes module', () => {
},
sortColumn: DEFAULT,
sortOrder: ASC,
namespace: 'citibikes.trips'
namespace: 'citibike.trips'
});
loadIndexesFromDb()(dispatch, state);
expect(actionSpy.calledOnce).to.equal(true);
Expand All @@ -177,25 +177,25 @@ describe('indexes module', () => {
const fromDB = [
{
'name': '_id_',
'v': 2, 'key': {'_id': 1}, 'ns': 'citibike.trips',
'v': 2, 'key': {'_id': 1},
'usageHost': 'computername.local:27017', 'usageCount': 6,
'usageSince': '2019-02-08T10:21:49.176Z', 'size': 135168
}, {
'name': 'CCCC',
'v': 2, 'key': {'cccc0': -1, 'cccc1': '2dsphere', 'cccc2': 1},
'ns': 'citibike.trips', 'background': false, '2dsphereIndexVersion': 3,
'background': false, '2dsphereIndexVersion': 3,
'usageHost': 'computername.local:27017', 'usageCount': 5,
'usageSince': '2019-02-08T14:38:56.147Z', 'size': 4096
}, {
'name': 'AAAA',
'v': 2, 'key': {'aaaa': -1},
'ns': 'citibike.trips', 'background': false,
'background': false,
'expireAfterSeconds': 300, 'partialFilterExpression': {'y': 1},
'usageHost': 'computername.local:27017', 'usageCount': 4,
'usageSince': '2019-02-08T14:39:56.285Z', 'size': 4096
}, {
'name': 'BBBB',
'v': 2, 'key': {'bbbb.abcd': 1}, 'ns': 'citibike.trips',
'v': 2, 'key': {'bbbb.abcd': 1},
'background': false, 'collation': {'locale': 'ar', 'caseLevel': true,
'caseFirst': 'lower', 'strength': 3, 'numericOrdering': false,
'alternate': 'non-ignorable', 'maxVariable': 'space',
Expand Down