forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release_23.1' into release_23.2
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import Vue from "vue"; | ||
import { urlData } from "utils/url"; | ||
|
||
const state = { | ||
items: {}, | ||
}; | ||
|
||
const getters = { | ||
getDataset: | ||
(state) => | ||
({ id }) => { | ||
return state.items[id] || { hid: 0, name: "Wait..." }; | ||
}, | ||
}; | ||
|
||
const actions = { | ||
fetchDataset: async ({ state, commit }, { id }) => { | ||
if (!state.items[id]) { | ||
const url = `/api/datasets/${id}`; | ||
const dataset = await urlData({ url }); | ||
commit("saveDataset", { id, dataset }); | ||
} | ||
}, | ||
}; | ||
|
||
const mutations = { | ||
/** | ||
* Adds a new dataset. | ||
* @param {Array} dataset as returned by the datasets api (detailed serialization) | ||
*/ | ||
saveDataset: (state, { id, dataset }) => { | ||
Vue.set(state.items, id, dataset); | ||
}, | ||
/** | ||
* Updates existing datasets. This is called by the history changed items store. | ||
* @param {Array} payload as returned by the history contents api (detailed serialization) | ||
*/ | ||
saveDatasets: (state, { payload }) => { | ||
payload.forEach((item) => { | ||
if (item.history_content_type == "dataset") { | ||
const id = item.id; | ||
if (state.items[id]) { | ||
const localItem = state.items[id]; | ||
Object.keys(item).forEach((key) => { | ||
localItem[key] = item[key]; | ||
}); | ||
} | ||
} | ||
}); | ||
}, | ||
}; | ||
|
||
export const datasetStore = { | ||
state, | ||
getters, | ||
actions, | ||
mutations, | ||
}; |