Commit f81e1acb authored by Filipa Lacerda's avatar Filipa Lacerda

Moves codeclimate code into ee folder

parent 801a5093
...@@ -16,7 +16,6 @@ export { default as WidgetMergeHelp } from './components/mr_widget_merge_help'; ...@@ -16,7 +16,6 @@ export { default as WidgetMergeHelp } from './components/mr_widget_merge_help';
export { default as WidgetPipeline } from './components/mr_widget_pipeline'; export { default as WidgetPipeline } from './components/mr_widget_pipeline';
export { default as WidgetDeployment } from './components/mr_widget_deployment'; export { default as WidgetDeployment } from './components/mr_widget_deployment';
export { default as WidgetRelatedLinks } from './components/mr_widget_related_links'; export { default as WidgetRelatedLinks } from './components/mr_widget_related_links';
export { default as WidgetCodeQuality } from './components/mr_widget_code_quality.vue';
export { default as MergedState } from './components/states/mr_widget_merged'; export { default as MergedState } from './components/states/mr_widget_merged';
export { default as FailedToMerge } from './components/states/mr_widget_failed_to_merge'; export { default as FailedToMerge } from './components/states/mr_widget_failed_to_merge';
export { default as ClosedState } from './components/states/mr_widget_closed'; export { default as ClosedState } from './components/states/mr_widget_closed';
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
import successIcon from 'icons/_icon_status_success.svg'; import successIcon from 'icons/_icon_status_success.svg';
import errorIcon from 'icons/_icon_status_failed.svg'; import errorIcon from 'icons/_icon_status_failed.svg';
import issuesBlock from './mr_widget_code_quality_issues.vue'; import issuesBlock from './mr_widget_code_quality_issues.vue';
import loadingIcon from '../../vue_shared/components/loading_icon.vue'; import loadingIcon from '../../../vue_shared/components/loading_icon.vue';
import '../../lib/utils/text_utility'; import '../../../lib/utils/text_utility';
export default { export default {
name: 'MRWidgetCodeQuality', name: 'MRWidgetCodeQuality',
......
...@@ -2,6 +2,7 @@ import CEWidgetOptions from '../mr_widget_options'; ...@@ -2,6 +2,7 @@ import CEWidgetOptions from '../mr_widget_options';
import WidgetApprovals from './components/approvals/mr_widget_approvals'; import WidgetApprovals from './components/approvals/mr_widget_approvals';
import GeoSecondaryNode from './components/states/mr_widget_secondary_geo_node'; import GeoSecondaryNode from './components/states/mr_widget_secondary_geo_node';
import RebaseState from './components/states/mr_widget_rebase'; import RebaseState from './components/states/mr_widget_rebase';
import WidgetCodeQuality from './components/mr_widget_code_quality.vue';
export default { export default {
extends: CEWidgetOptions, extends: CEWidgetOptions,
...@@ -9,11 +10,16 @@ export default { ...@@ -9,11 +10,16 @@ export default {
'mr-widget-approvals': WidgetApprovals, 'mr-widget-approvals': WidgetApprovals,
'mr-widget-geo-secondary-node': GeoSecondaryNode, 'mr-widget-geo-secondary-node': GeoSecondaryNode,
'mr-widget-rebase': RebaseState, 'mr-widget-rebase': RebaseState,
'mr-widget-code-quality': WidgetCodeQuality,
}, },
computed: { computed: {
shouldRenderApprovals() { shouldRenderApprovals() {
return this.mr.approvalsRequired; return this.mr.approvalsRequired;
}, },
shouldRenderCodeQuality() {
const { codeclimate } = this.mr;
return codeclimate && codeclimate.head_path && codeclimate.base_path;
},
}, },
template: ` template: `
<div class="mr-state-widget prepend-top-default"> <div class="mr-state-widget prepend-top-default">
...@@ -29,6 +35,11 @@ export default { ...@@ -29,6 +35,11 @@ export default {
v-if="mr.approvalsRequired" v-if="mr.approvalsRequired"
:mr="mr" :mr="mr"
:service="service" /> :service="service" />
<mr-widget-code-quality
v-if="shouldRenderCodeQuality"
:mr="mr"
:service="service"
/>
<component <component
:is="componentName" :is="componentName"
:mr="mr" :mr="mr"
......
...@@ -28,4 +28,8 @@ export default class MRWidgetService extends CEWidgetService { ...@@ -28,4 +28,8 @@ export default class MRWidgetService extends CEWidgetService {
rebase() { rebase() {
return this.rebaseResource.save(); return this.rebaseResource.save();
} }
fetchCodeclimate(endpoint) { // eslint-disable-line
return Vue.http.get(endpoint);
}
} }
...@@ -6,6 +6,7 @@ export default class MergeRequestStore extends CEMergeRequestStore { ...@@ -6,6 +6,7 @@ export default class MergeRequestStore extends CEMergeRequestStore {
this.initSquashBeforeMerge(data); this.initSquashBeforeMerge(data);
this.initRebase(data); this.initRebase(data);
this.initApprovals(data); this.initApprovals(data);
this.initCodeclimate(data);
super.setData(data); super.setData(data);
} }
...@@ -43,4 +44,33 @@ export default class MergeRequestStore extends CEMergeRequestStore { ...@@ -43,4 +44,33 @@ export default class MergeRequestStore extends CEMergeRequestStore {
this.isApproved = !this.approvalsLeft || false; this.isApproved = !this.approvalsLeft || false;
this.preventMerge = this.approvalsRequired && this.approvalsLeft; this.preventMerge = this.approvalsRequired && this.approvalsLeft;
} }
initCodeclimate(data) {
this.codeclimate = data.codeclimate;
this.codeclimateMetrics = {
headIssues: [],
baseIssues: [],
newIssues: [],
resolvedIssues: [],
};
}
setCodeclimateHeadMetrics(data) {
this.codeclimateMetrics.headIssues = data;
}
setCodeclimateBaseMetrics(data) {
this.codeclimateMetrics.baseIssues = data;
}
compareCodeclimateMetrics() {
const { headIssues, baseIssues } = this.codeclimateMetrics;
this.codeclimateMetrics.newIssues = this.filterByFingerprint(headIssues, baseIssues);
this.codeclimateMetrics.resolvedIssues = this.filterByFingerprint(baseIssues, headIssues);
}
filterByFingerprint(firstArray, secondArray) { // eslint-disable-line
return firstArray.filter(item => !secondArray.find(el => el.fingerprint === item.fingerprint));
}
} }
...@@ -6,7 +6,6 @@ import { ...@@ -6,7 +6,6 @@ import {
WidgetPipeline, WidgetPipeline,
WidgetDeployment, WidgetDeployment,
WidgetRelatedLinks, WidgetRelatedLinks,
WidgetCodeQuality,
MergedState, MergedState,
ClosedState, ClosedState,
LockedState, LockedState,
...@@ -59,10 +58,6 @@ export default { ...@@ -59,10 +58,6 @@ export default {
shouldRenderDeployments() { shouldRenderDeployments() {
return this.mr.deployments.length; return this.mr.deployments.length;
}, },
shouldRenderCodeQuality() {
const { codeclimate } = this.mr;
return codeclimate && codeclimate.head_path && codeclimate.base_path;
},
}, },
methods: { methods: {
createService(store) { createService(store) {
...@@ -215,7 +210,6 @@ export default { ...@@ -215,7 +210,6 @@ export default {
'mr-widget-pipeline-failed': PipelineFailedState, 'mr-widget-pipeline-failed': PipelineFailedState,
'mr-widget-merge-when-pipeline-succeeds': MergeWhenPipelineSucceedsState, 'mr-widget-merge-when-pipeline-succeeds': MergeWhenPipelineSucceedsState,
'mr-widget-auto-merge-failed': AutoMergeFailed, 'mr-widget-auto-merge-failed': AutoMergeFailed,
'mr-widget-code-quality': WidgetCodeQuality,
}, },
template: ` template: `
<div class="mr-state-widget prepend-top-default"> <div class="mr-state-widget prepend-top-default">
...@@ -227,11 +221,6 @@ export default { ...@@ -227,11 +221,6 @@ export default {
v-if="shouldRenderDeployments" v-if="shouldRenderDeployments"
:mr="mr" :mr="mr"
:service="service" /> :service="service" />
<mr-widget-code-quality
v-if="shouldRenderCodeQuality"
:mr="mr"
:service="service"
/>
<component <component
:is="componentName" :is="componentName"
:mr="mr" :mr="mr"
......
...@@ -47,10 +47,6 @@ export default class MRWidgetService { ...@@ -47,10 +47,6 @@ export default class MRWidgetService {
return this.mergeActionsContentResource.get(); return this.mergeActionsContentResource.get();
} }
fetchCodeclimate(endpoint) { // eslint-disable-line
return Vue.http.get(endpoint);
}
static stopEnvironment(url) { static stopEnvironment(url) {
return Vue.http.post(url); return Vue.http.post(url);
} }
......
...@@ -5,13 +5,6 @@ export default class MergeRequestStore { ...@@ -5,13 +5,6 @@ export default class MergeRequestStore {
constructor(data) { constructor(data) {
this.sha = data.diff_head_sha; this.sha = data.diff_head_sha;
this.codeclimate = data.codeclimate;
this.codeclimateMetrics = {
headIssues: [],
baseIssues: [],
newIssues: [],
resolvedIssues: [],
};
this.setData(data); this.setData(data);
} }
...@@ -121,25 +114,6 @@ export default class MergeRequestStore { ...@@ -121,25 +114,6 @@ export default class MergeRequestStore {
} }
} }
setCodeclimateHeadMetrics(data) {
this.codeclimateMetrics.headIssues = data;
}
setCodeclimateBaseMetrics(data) {
this.codeclimateMetrics.baseIssues = data;
}
compareCodeclimateMetrics() {
const { headIssues, baseIssues } = this.codeclimateMetrics;
this.codeclimateMetrics.newIssues = this.filterByFingerprint(headIssues, baseIssues);
this.codeclimateMetrics.resolvedIssues = this.filterByFingerprint(baseIssues, headIssues);
}
filterByFingerprint(firstArray, secondArray) { // eslint-disable-line
return firstArray.filter(item => !secondArray.find(el => el.fingerprint === item.fingerprint));
}
static getAuthorObject(event) { static getAuthorObject(event) {
if (!event) { if (!event) {
return {}; return {};
......
import Vue from 'vue'; import Vue from 'vue';
import mrWidgetCodeQualityIssues from '~/vue_merge_request_widget/components/mr_widget_code_quality_issues.vue'; import mrWidgetCodeQualityIssues from '~/vue_merge_request_widget/ee/components/mr_widget_code_quality_issues.vue';
describe('Merge Request Code Quality Issues', () => { describe('Merge Request Code Quality Issues', () => {
let vm; let vm;
......
import Vue from 'vue'; import Vue from 'vue';
import mrWidgetCodeQuality from '~/vue_merge_request_widget/components/mr_widget_code_quality.vue'; import mrWidgetCodeQuality from '~/vue_merge_request_widget/ee/components/mr_widget_code_quality.vue';
import Store from '~/vue_merge_request_widget/stores/mr_widget_store'; import Store from '~/vue_merge_request_widget/stores/mr_widget_store';
import Service from '~/vue_merge_request_widget/services/mr_widget_service'; import Service from '~/vue_merge_request_widget/services/mr_widget_service';
import mockData, { baseIssues, headIssues } from '../mock_data'; import mockData, { baseIssues, headIssues } from '../mock_data';
......
...@@ -215,7 +215,7 @@ export default { ...@@ -215,7 +215,7 @@ export default {
"head_path": "head.json", "head_path": "head.json",
"base_path": "base.json" "base_path": "base.json"
} }
} };
export const headIssues = [ export const headIssues = [
{ {
......
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