Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/ci/reports/codequality_report/store/actions.js')
-rw-r--r--app/assets/javascripts/ci/reports/codequality_report/store/actions.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/assets/javascripts/ci/reports/codequality_report/store/actions.js b/app/assets/javascripts/ci/reports/codequality_report/store/actions.js
new file mode 100644
index 00000000000..04aca11b945
--- /dev/null
+++ b/app/assets/javascripts/ci/reports/codequality_report/store/actions.js
@@ -0,0 +1,30 @@
+import pollUntilComplete from '~/lib/utils/poll_until_complete';
+import { STATUS_NOT_FOUND } from '../../constants';
+import * as types from './mutation_types';
+import { parseCodeclimateMetrics } from './utils/codequality_parser';
+
+export const setPaths = ({ commit }, paths) => commit(types.SET_PATHS, paths);
+
+export const fetchReports = ({ state, dispatch, commit }) => {
+ commit(types.REQUEST_REPORTS);
+
+ return pollUntilComplete(state.reportsPath)
+ .then(({ data }) => {
+ if (data.status === STATUS_NOT_FOUND) {
+ return dispatch('receiveReportsError', data);
+ }
+ return dispatch('receiveReportsSuccess', {
+ newIssues: parseCodeclimateMetrics(data.new_errors, state.headBlobPath),
+ resolvedIssues: parseCodeclimateMetrics(data.resolved_errors, state.baseBlobPath),
+ });
+ })
+ .catch((error) => dispatch('receiveReportsError', error));
+};
+
+export const receiveReportsSuccess = ({ commit }, data) => {
+ commit(types.RECEIVE_REPORTS_SUCCESS, data);
+};
+
+export const receiveReportsError = ({ commit }, error) => {
+ commit(types.RECEIVE_REPORTS_ERROR, error);
+};