diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /app/assets/javascripts/pipelines/stores/test_reports/actions.js | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'app/assets/javascripts/pipelines/stores/test_reports/actions.js')
-rw-r--r-- | app/assets/javascripts/pipelines/stores/test_reports/actions.js | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/app/assets/javascripts/pipelines/stores/test_reports/actions.js b/app/assets/javascripts/pipelines/stores/test_reports/actions.js index 71d875c1a83..ccacb9f7e97 100644 --- a/app/assets/javascripts/pipelines/stores/test_reports/actions.js +++ b/app/assets/javascripts/pipelines/stores/test_reports/actions.js @@ -3,17 +3,42 @@ import * as types from './mutation_types'; import createFlash from '~/flash'; import { s__ } from '~/locale'; -export const setEndpoint = ({ commit }, data) => commit(types.SET_ENDPOINT, data); +export const fetchSummary = ({ state, commit, dispatch }) => { + // If we do this without the build_report_summary feature flag enabled + // it causes a race condition for toggleLoading and ruins the loading + // state in the application + if (state.useBuildSummaryReport) { + dispatch('toggleLoading'); + } -export const fetchReports = ({ state, commit, dispatch }) => { + return axios + .get(state.summaryEndpoint) + .then(({ data }) => { + commit(types.SET_SUMMARY, data); + + if (!state.useBuildSummaryReport) { + // Set the tab counter badge to total_count + // This is temporary until we can server-side render that count number + // (see https://gitlab.com/gitlab-org/gitlab/-/issues/223134) + document.querySelector('.js-test-report-badge-counter').innerHTML = data.total_count || 0; + } + }) + .catch(() => { + createFlash(s__('TestReports|There was an error fetching the summary.')); + }) + .finally(() => { + if (state.useBuildSummaryReport) { + dispatch('toggleLoading'); + } + }); +}; + +export const fetchFullReport = ({ state, commit, dispatch }) => { dispatch('toggleLoading'); return axios - .get(state.endpoint) - .then(response => { - const { data } = response; - commit(types.SET_REPORTS, data); - }) + .get(state.fullReportEndpoint) + .then(({ data }) => commit(types.SET_REPORTS, data)) .catch(() => { createFlash(s__('TestReports|There was an error fetching the test reports.')); }) @@ -22,8 +47,10 @@ export const fetchReports = ({ state, commit, dispatch }) => { }); }; -export const setSelectedSuite = ({ commit }, data) => commit(types.SET_SELECTED_SUITE, data); -export const removeSelectedSuite = ({ commit }) => commit(types.SET_SELECTED_SUITE, {}); +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); // prevent babel-plugin-rewire from generating an invalid default during karma tests |