diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-24 15:09:00 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-24 15:09:00 +0000 |
commit | c282dba898a4cb0645f88579339502a4e3778727 (patch) | |
tree | 94a6457ce4438e085c9ae43bc51a2b5a29787bf2 /app/assets/javascripts/monitoring/stores/actions.js | |
parent | 2c2dd5e36c4ed5f09f488be288882d98f9124d12 (diff) | |
download | gitlab-ce-c282dba898a4cb0645f88579339502a4e3778727.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/monitoring/stores/actions.js')
-rw-r--r-- | app/assets/javascripts/monitoring/stores/actions.js | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/app/assets/javascripts/monitoring/stores/actions.js b/app/assets/javascripts/monitoring/stores/actions.js index 6303ed2b82f..e26e1457f55 100644 --- a/app/assets/javascripts/monitoring/stores/actions.js +++ b/app/assets/javascripts/monitoring/stores/actions.js @@ -1,7 +1,9 @@ import * as types from './mutation_types'; import axios from '~/lib/utils/axios_utils'; import createFlash from '~/flash'; +import { gqClient, parseEnvironmentsResponse, removeLeadingSlash } from './utils'; import trackDashboardLoad from '../monitoring_tracking_helper'; +import getEnvironments from '../queries/getEnvironments.query.graphql'; import statusCodes from '../../lib/utils/http_status'; import { backOff } from '../../lib/utils/common_utils'; import { s__, sprintf } from '../../locale'; @@ -187,26 +189,30 @@ export const fetchDeploymentsData = ({ state, dispatch }) => { }); }; -export const fetchEnvironmentsData = ({ state, dispatch }) => { - if (!state.environmentsEndpoint) { - return Promise.resolve([]); - } - return axios - .get(state.environmentsEndpoint) - .then(resp => resp.data) - .then(response => { - if (!response || !response.environments) { +export const fetchEnvironmentsData = ({ state, dispatch }) => + gqClient + .mutate({ + mutation: getEnvironments, + variables: { + projectPath: removeLeadingSlash(state.projectPath), + search: state.environmentsSearchTerm, + }, + }) + .then(resp => + parseEnvironmentsResponse(resp.data?.project?.data?.environments, state.projectPath), + ) + .then(environments => { + if (!environments) { createFlash( s__('Metrics|There was an error fetching the environments data, please try again'), ); } - dispatch('receiveEnvironmentsDataSuccess', response.environments); + dispatch('receiveEnvironmentsDataSuccess', environments); }) .catch(() => { dispatch('receiveEnvironmentsDataFailure'); createFlash(s__('Metrics|There was an error getting environments information.')); }); -}; /** * Set a new array of metrics to a panel group |