Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load manifests provided by the imported configuration #3550

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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 __tests__/src/reducers/manifests.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,10 @@ describe('manifests reducer', () => {
type: ActionTypes.IMPORT_MIRADOR_STATE,
})).toEqual({ new: 'stuff' });
});
it('should handle IMPORT_CONFIG setting to load manifests', () => {
expect(manifestsReducer({}, {
config: { manifests: { new: 'stuff' } },
type: ActionTypes.IMPORT_CONFIG,
})).toEqual({ new: 'stuff' });
});
});
4 changes: 4 additions & 0 deletions src/state/reducers/manifests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import omit from 'lodash/omit';
import deepmerge from 'deepmerge';
import ActionTypes from '../actions/action-types';

/**
Expand Down Expand Up @@ -36,6 +37,9 @@ export const manifestsReducer = (state = {}, action) => {
isFetching: false,
},
};
case ActionTypes.UPDATE_CONFIG:
case ActionTypes.IMPORT_CONFIG:
return deepmerge(state, action.config.manifests || {});
case ActionTypes.REMOVE_MANIFEST:
return Object.keys(state).reduce((object, key) => {
if (key !== action.manifestId) {
Expand Down
6 changes: 4 additions & 2 deletions src/state/sagas/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ export function* fetchWindowManifest(action) {

if (!manifestId) return;

if (action.manifest) {
yield put(receiveManifest(manifestId, action.manifest));
const sideloadedManifest = action.manifest || (action.payload || {}).manifest;

if (sideloadedManifest) {
yield put(receiveManifest(manifestId, sideloadedManifest));
} else {
yield call(fetchManifests, manifestId, ...(collectionPath || []));
}
Expand Down