From e3f1835936bf7489b5fcd3e14908af1656874883 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Fri, 8 Apr 2022 10:45:39 -0700 Subject: [PATCH 1/2] Load manifests provided by the imported configuration --- __tests__/src/reducers/manifests.test.js | 6 ++++++ src/state/reducers/manifests.js | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/__tests__/src/reducers/manifests.test.js b/__tests__/src/reducers/manifests.test.js index 31ce91188f..ad38401983 100644 --- a/__tests__/src/reducers/manifests.test.js +++ b/__tests__/src/reducers/manifests.test.js @@ -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' }); + }); }); diff --git a/src/state/reducers/manifests.js b/src/state/reducers/manifests.js index 2fb36b4b36..02231f2359 100644 --- a/src/state/reducers/manifests.js +++ b/src/state/reducers/manifests.js @@ -1,4 +1,5 @@ import omit from 'lodash/omit'; +import deepmerge from 'deepmerge'; import ActionTypes from '../actions/action-types'; /** @@ -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) { From db31897585a23210d3ccb976794967f9430befb7 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Fri, 8 Apr 2022 11:02:14 -0700 Subject: [PATCH 2/2] Allow the UPDATE_WINDOW action to sideload manifests --- src/state/sagas/windows.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/state/sagas/windows.js b/src/state/sagas/windows.js index bc63cdcbb9..a7dc55597c 100644 --- a/src/state/sagas/windows.js +++ b/src/state/sagas/windows.js @@ -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 || [])); }