From c9adb1932826ace164585eb5f76f5dbb5acc6418 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Fri, 22 Sep 2023 16:25:06 +0200 Subject: [PATCH] Remove old collection elements Vuex store --- .../historyStore/collectionElementsStore.js | 73 ------------------- client/src/store/historyStore/index.js | 1 - client/src/store/index.js | 2 - 3 files changed, 76 deletions(-) delete mode 100644 client/src/store/historyStore/collectionElementsStore.js delete mode 100644 client/src/store/historyStore/index.js diff --git a/client/src/store/historyStore/collectionElementsStore.js b/client/src/store/historyStore/collectionElementsStore.js deleted file mode 100644 index 264df2f55447..000000000000 --- a/client/src/store/historyStore/collectionElementsStore.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Requests collection elements by reacting to changes of props passed to the collection elements - * provider used in the collection panel e.g. changes of the offset prop when scrolling. This store - * attached to the changed history items store, but could also use the getter of the dataset store - * instead, particularly after a collection store has been added if required. - */ - -import { LastQueue } from "utils/promise-queue"; -import { urlData } from "utils/url"; -import Vue from "vue"; - -import { mergeArray } from "./model/utilities"; - -const limit = 100; -const queue = new LastQueue(); - -const getObjectId = (elementObject) => { - return `${elementObject.model_class}-${elementObject.id}`; -}; - -const state = { - items: {}, - itemKey: "element_index", - objectIndex: {}, -}; - -const getters = { - getCollectionElements: - (state) => - ({ id }) => { - const itemArray = state.items[id] || []; - const filtered = itemArray.filter((item) => !!item); - return filtered.map((item) => { - const objectId = getObjectId(item.object); - const objectData = state.objectIndex[objectId]; - const objectResult = { ...item.object }; - if (objectData) { - Object.keys(objectResult).forEach((key) => { - objectResult[key] = objectData[key]; - }); - } - return { ...item, object: objectResult }; - }); - }, -}; - -const actions = { - fetchCollectionElements: async ({ commit }, { id, contentsUrl, offset }) => { - const url = `/${contentsUrl}?offset=${offset}&limit=${limit}`; - await queue.enqueue(urlData, { url }).then((payload) => { - commit("saveCollectionElements", { id, payload }); - }); - }, -}; - -const mutations = { - saveCollectionElements: (state, { id, payload }) => { - mergeArray(id, payload, state.items, state.itemKey); - }, - saveCollectionObjects: (state, { payload }) => { - payload.forEach((item) => { - const objectId = getObjectId(item); - Vue.set(state.objectIndex, objectId, item); - }); - }, -}; - -export const collectionElementsStore = { - state, - getters, - actions, - mutations, -}; diff --git a/client/src/store/historyStore/index.js b/client/src/store/historyStore/index.js deleted file mode 100644 index e51800782011..000000000000 --- a/client/src/store/historyStore/index.js +++ /dev/null @@ -1 +0,0 @@ -export { collectionElementsStore } from "./collectionElementsStore"; diff --git a/client/src/store/index.js b/client/src/store/index.js index 166654e2d96c..19e2b1ed020e 100644 --- a/client/src/store/index.js +++ b/client/src/store/index.js @@ -13,7 +13,6 @@ import { collectionAttributesStore } from "./collectionAttributesStore"; import { datasetExtFilesStore } from "./datasetExtFilesStore"; import { datasetPathDestinationStore } from "./datasetPathDestinationStore"; import { gridSearchStore } from "./gridSearchStore"; -import { collectionElementsStore } from "./historyStore"; import { invocationStore } from "./invocationStore"; import { jobDestinationParametersStore } from "./jobDestinationParametersStore"; import { panelStore } from "./panelStore"; @@ -47,7 +46,6 @@ export function createStore() { plugins: [createCache(), panelsPersistence.plugin], modules: { collectionAttributesStore: collectionAttributesStore, - collectionElements: collectionElementsStore, destinationParameters: jobDestinationParametersStore, datasetExtFiles: datasetExtFilesStore, datasetPathDestination: datasetPathDestinationStore,