diff options
Diffstat (limited to 'app/assets/javascripts/monitoring/stores')
7 files changed, 55 insertions, 7 deletions
diff --git a/app/assets/javascripts/monitoring/stores/embed_group/actions.js b/app/assets/javascripts/monitoring/stores/embed_group/actions.js new file mode 100644 index 00000000000..cbe0950d954 --- /dev/null +++ b/app/assets/javascripts/monitoring/stores/embed_group/actions.js @@ -0,0 +1,5 @@ +import * as types from './mutation_types'; + +export const addModule = ({ commit }, data) => commit(types.ADD_MODULE, data); + +export default () => {}; diff --git a/app/assets/javascripts/monitoring/stores/embed_group/getters.js b/app/assets/javascripts/monitoring/stores/embed_group/getters.js new file mode 100644 index 00000000000..9b08cf762c1 --- /dev/null +++ b/app/assets/javascripts/monitoring/stores/embed_group/getters.js @@ -0,0 +1,4 @@ +export const metricsWithData = (state, getters, rootState, rootGetters) => + state.modules.map(module => rootGetters[`${module}/metricsWithData`]().length); + +export default () => {}; diff --git a/app/assets/javascripts/monitoring/stores/embed_group/index.js b/app/assets/javascripts/monitoring/stores/embed_group/index.js new file mode 100644 index 00000000000..773bca9f87e --- /dev/null +++ b/app/assets/javascripts/monitoring/stores/embed_group/index.js @@ -0,0 +1,24 @@ +import Vue from 'vue'; +import Vuex from 'vuex'; +import * as actions from './actions'; +import * as getters from './getters'; +import mutations from './mutations'; +import state from './state'; + +Vue.use(Vuex); + +// In practice this store will have a number of `monitoringDashboard` modules added dynamically +export const createStore = () => + new Vuex.Store({ + modules: { + embedGroup: { + namespaced: true, + actions, + getters, + mutations, + state, + }, + }, + }); + +export default createStore(); diff --git a/app/assets/javascripts/monitoring/stores/embed_group/mutation_types.js b/app/assets/javascripts/monitoring/stores/embed_group/mutation_types.js new file mode 100644 index 00000000000..e7a425d3623 --- /dev/null +++ b/app/assets/javascripts/monitoring/stores/embed_group/mutation_types.js @@ -0,0 +1,3 @@ +export const ADD_MODULE = 'ADD_MODULE'; + +export default () => {}; diff --git a/app/assets/javascripts/monitoring/stores/embed_group/mutations.js b/app/assets/javascripts/monitoring/stores/embed_group/mutations.js new file mode 100644 index 00000000000..3c66129f239 --- /dev/null +++ b/app/assets/javascripts/monitoring/stores/embed_group/mutations.js @@ -0,0 +1,7 @@ +import * as types from './mutation_types'; + +export default { + [types.ADD_MODULE](state, module) { + state.modules.push(module); + }, +}; diff --git a/app/assets/javascripts/monitoring/stores/embed_group/state.js b/app/assets/javascripts/monitoring/stores/embed_group/state.js new file mode 100644 index 00000000000..016c7e5dac7 --- /dev/null +++ b/app/assets/javascripts/monitoring/stores/embed_group/state.js @@ -0,0 +1,3 @@ +export default () => ({ + modules: [], +}); diff --git a/app/assets/javascripts/monitoring/stores/index.js b/app/assets/javascripts/monitoring/stores/index.js index c1c466b7cf0..f08a6402aa6 100644 --- a/app/assets/javascripts/monitoring/stores/index.js +++ b/app/assets/javascripts/monitoring/stores/index.js @@ -7,16 +7,18 @@ import state from './state'; Vue.use(Vuex); +export const monitoringDashboard = { + namespaced: true, + actions, + getters, + mutations, + state, +}; + export const createStore = () => new Vuex.Store({ modules: { - monitoringDashboard: { - namespaced: true, - actions, - getters, - mutations, - state, - }, + monitoringDashboard, }, }); |