Skip to content

Commit 5809f11

Browse files
Convert federation info as needed (#230)
See also Open-EO/openeo-js-client#67 (comment)
1 parent 9a15e6c commit 5809f11

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/store/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,14 @@ export default new Vuex.Store({
435435
}
436436
},
437437
federation(state, federation) {
438-
state.federation = federation;
438+
if (Array.isArray(federation)) {
439+
// convert array of objects, which each have an `id` property, into an object with those IDs as the keys
440+
// e.g. [ {id:'f',name:'foo'} ] -> { 'f': {id:'f',name:'foo'} }
441+
state.federation = federation.reduce((arr, val) => ({ ...arr, [val.id]: val }), {})
442+
} else {
443+
// otherwise expect that it is already in that format
444+
state.federation = federation;
445+
}
439446
},
440447
federationMissing(state, federationMissing) {
441448
state.federationMissing = federationMissing;

0 commit comments

Comments
 (0)