diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
commit | 5afcbe03ead9ada87621888a31a62652b10a7e4f (patch) | |
tree | 9918b67a0d0f0bafa6542e839a8be37adf73102d /app/assets/javascripts/ci/pipeline_details/stores/test_reports/actions.js | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'app/assets/javascripts/ci/pipeline_details/stores/test_reports/actions.js')
-rw-r--r-- | app/assets/javascripts/ci/pipeline_details/stores/test_reports/actions.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/app/assets/javascripts/ci/pipeline_details/stores/test_reports/actions.js b/app/assets/javascripts/ci/pipeline_details/stores/test_reports/actions.js new file mode 100644 index 00000000000..1b51bb804d0 --- /dev/null +++ b/app/assets/javascripts/ci/pipeline_details/stores/test_reports/actions.js @@ -0,0 +1,51 @@ +import { createAlert } from '~/alert'; +import axios from '~/lib/utils/axios_utils'; +import { s__ } from '~/locale'; +import * as types from './mutation_types'; + +export const fetchSummary = ({ state, commit, dispatch }) => { + dispatch('toggleLoading'); + + return axios + .get(state.summaryEndpoint) + .then(({ data }) => { + commit(types.SET_SUMMARY, data); + }) + .catch(() => { + createAlert({ + message: s__('TestReports|There was an error fetching the summary.'), + }); + }) + .finally(() => { + dispatch('toggleLoading'); + }); +}; + +export const fetchTestSuite = ({ state, commit, dispatch }, index) => { + const { hasFullSuite } = state.testReports?.test_suites?.[index] || {}; + // We don't need to fetch the suite if we have the information already + if (hasFullSuite) { + return Promise.resolve(); + } + + dispatch('toggleLoading'); + + const { build_ids = [] } = state.testReports?.test_suites?.[index] || {}; + // Replacing `/:suite_name.json` with the name of the suite. Including the extra characters + // to ensure that we replace exactly the template part of the URL string + + return axios + .get(state.suiteEndpoint, { params: { build_ids } }) + .then(({ data }) => commit(types.SET_SUITE, { suite: data, index })) + .catch((error) => commit(types.SET_SUITE_ERROR, error)) + .finally(() => { + dispatch('toggleLoading'); + }); +}; + +export const setPage = ({ commit }, page) => commit(types.SET_PAGE, page); +export const setSelectedSuiteIndex = ({ commit }, data) => + commit(types.SET_SELECTED_SUITE_INDEX, data); +export const removeSelectedSuiteIndex = ({ commit }) => + commit(types.SET_SELECTED_SUITE_INDEX, null); +export const toggleLoading = ({ commit }) => commit(types.TOGGLE_LOADING); |