diff options
Diffstat (limited to 'app/assets/javascripts/monitoring/stores/mutations.js')
-rw-r--r-- | app/assets/javascripts/monitoring/stores/mutations.js | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/app/assets/javascripts/monitoring/stores/mutations.js b/app/assets/javascripts/monitoring/stores/mutations.js index f41cf3fc477..2d63fdd6e34 100644 --- a/app/assets/javascripts/monitoring/stores/mutations.js +++ b/app/assets/javascripts/monitoring/stores/mutations.js @@ -1,7 +1,6 @@ import Vue from 'vue'; import { pick } from 'lodash'; import * as types from './mutation_types'; -import { selectedDashboard } from './getters'; import { mapToDashboardViewModel, normalizeQueryResult } from './utils'; import { BACKOFF_TIMEOUT } from '../../lib/utils/common_utils'; import { endpointKeys, initialStateKeys, metricStates } from '../constants'; @@ -61,8 +60,14 @@ export default { state.emptyState = 'loading'; state.showEmptyState = true; }, - [types.RECEIVE_METRICS_DASHBOARD_SUCCESS](state, dashboard) { - state.dashboard = mapToDashboardViewModel(dashboard); + [types.RECEIVE_METRICS_DASHBOARD_SUCCESS](state, dashboardYML) { + const { dashboard, panelGroups, variables, links } = mapToDashboardViewModel(dashboardYML); + state.dashboard = { + dashboard, + panelGroups, + }; + state.variables = variables; + state.links = links; if (!state.dashboard.panelGroups.length) { state.emptyState = 'noData'; @@ -76,15 +81,14 @@ export default { [types.REQUEST_DASHBOARD_STARRING](state) { state.isUpdatingStarredValue = true; }, - [types.RECEIVE_DASHBOARD_STARRING_SUCCESS](state, newStarredValue) { - const dashboard = selectedDashboard(state); - const index = state.allDashboards.findIndex(d => d === dashboard); + [types.RECEIVE_DASHBOARD_STARRING_SUCCESS](state, { selectedDashboard, newStarredValue }) { + const index = state.allDashboards.findIndex(d => d === selectedDashboard); state.isUpdatingStarredValue = false; // Trigger state updates in the reactivity system for this change // https://vuejs.org/v2/guide/reactivity.html#For-Arrays - Vue.set(state.allDashboards, index, { ...dashboard, starred: newStarredValue }); + Vue.set(state.allDashboards, index, { ...selectedDashboard, starred: newStarredValue }); }, [types.RECEIVE_DASHBOARD_STARRING_FAILURE](state) { state.isUpdatingStarredValue = false; @@ -189,11 +193,11 @@ export default { state.expandedPanel.panel = panel; }, [types.SET_VARIABLES](state, variables) { - state.promVariables = variables; + state.variables = variables; }, - [types.UPDATE_VARIABLE_VALUES](state, updatedVariable) { - Object.assign(state.promVariables[updatedVariable.key], { - ...state.promVariables[updatedVariable.key], + [types.UPDATE_VARIABLES](state, updatedVariable) { + Object.assign(state.variables[updatedVariable.key], { + ...state.variables[updatedVariable.key], value: updatedVariable.value, }); }, |