Commit 802a8df3 authored by mfluharty's avatar mfluharty

Get reports from new codequality endpoint

If :codequality_mr_diff feature flag is enabled
and parse new report format to make links work
parent 2a6d552e
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { mapState, mapActions, mapGetters } from 'vuex'; import { mapState, mapActions, mapGetters } from 'vuex';
import { componentNames } from '~/reports/components/issue_body'; import { componentNames } from '~/reports/components/issue_body';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import ReportSection from '~/reports/components/report_section.vue'; import ReportSection from '~/reports/components/report_section.vue';
import createStore from './store'; import createStore from './store';
...@@ -11,6 +12,7 @@ export default { ...@@ -11,6 +12,7 @@ export default {
components: { components: {
ReportSection, ReportSection,
}, },
mixins: [glFeatureFlagsMixin()],
props: { props: {
headPath: { headPath: {
type: String, type: String,
...@@ -60,7 +62,7 @@ export default { ...@@ -60,7 +62,7 @@ export default {
helpPath: this.codequalityHelpPath, helpPath: this.codequalityHelpPath,
}); });
this.fetchReports(); this.fetchReports(this.glFeatures.codequalityMrDiff);
}, },
methods: { methods: {
...mapActions(['fetchReports', 'setPaths']), ...mapActions(['fetchReports', 'setPaths']),
......
...@@ -4,9 +4,20 @@ import { parseCodeclimateMetrics, doCodeClimateComparison } from './utils/codequ ...@@ -4,9 +4,20 @@ import { parseCodeclimateMetrics, doCodeClimateComparison } from './utils/codequ
export const setPaths = ({ commit }, paths) => commit(types.SET_PATHS, paths); export const setPaths = ({ commit }, paths) => commit(types.SET_PATHS, paths);
export const fetchReports = ({ state, dispatch, commit }) => { export const fetchReports = ({ state, dispatch, commit }, diffFeatureFlagEnabled) => {
commit(types.REQUEST_REPORTS); commit(types.REQUEST_REPORTS);
if (diffFeatureFlagEnabled) {
return axios
.get(state.reportsPath)
.then(({ data }) => {
return dispatch('receiveReportsSuccess', {
newIssues: parseCodeclimateMetrics(data.new_errors, state.headBlobPath),
resolvedIssues: parseCodeclimateMetrics(data.resolved_errors, state.baseBlobPath),
});
})
.catch(() => dispatch('receiveReportsError'));
}
if (!state.basePath) { if (!state.basePath) {
return dispatch('receiveReportsError'); return dispatch('receiveReportsError');
} }
......
...@@ -3,8 +3,10 @@ import CodeQualityComparisonWorker from '../../workers/codequality_comparison_wo ...@@ -3,8 +3,10 @@ import CodeQualityComparisonWorker from '../../workers/codequality_comparison_wo
export const parseCodeclimateMetrics = (issues = [], path = '') => { export const parseCodeclimateMetrics = (issues = [], path = '') => {
return issues.map((issue) => { return issues.map((issue) => {
const parsedIssue = { const parsedIssue = {
...issue,
name: issue.description, name: issue.description,
path: issue.file_path,
urlPath: `${path}/${issue.file_path}#L${issue.line}`,
...issue,
}; };
if (issue?.location?.path) { if (issue?.location?.path) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment