Commit d2ebf467 authored by Filipa Lacerda's avatar Filipa Lacerda

[ci skip] Move common components into a shared location

Rename common components
Break CSS into a new file
Update tests
parent 1e2dd2ac
...@@ -783,57 +783,3 @@ ...@@ -783,57 +783,3 @@
font-size: 22px; font-size: 22px;
margin: 0 10px 0 0; margin: 0 10px 0 0;
} }
.mr-widget-code-quality {
.code-quality-container {
border-top: 1px solid $gray-darker;
padding: $gl-padding-top;
background-color: $gray-light;
margin: $gl-padding -16px -16px;
.mr-widget-code-quality-info {
padding-left: 10px;
}
.mr-widget-dast-code {
margin-left: 26px;
}
.mr-widget-code-quality-list {
list-style: none;
padding: 0 1px;
margin: 0;
line-height: $code_line_height;
.btn-open-modal {
padding: 0 5px 4px;
}
.mr-widget-code-quality-list-item {
display: flex;
}
.mr-widget-code-quality-list-item-modal {
display: flex;
flex-wrap: wrap;
}
.failed .mr-widget-code-quality-icon {
color: $red-500;
}
.success .mr-widget-code-quality-icon {
color: $green-500;
}
.neutral .mr-widget-code-quality-icon {
color: $theme-gray-700;
}
.mr-widget-code-quality-icon {
margin: -5px 4px 0 0;
fill: currentColor;
}
}
}
}
...@@ -2,14 +2,14 @@ import { n__, s__, __, sprintf } from '~/locale'; ...@@ -2,14 +2,14 @@ import { n__, s__, __, sprintf } from '~/locale';
import CEWidgetOptions from '~/vue_merge_request_widget/mr_widget_options'; import CEWidgetOptions from '~/vue_merge_request_widget/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 collapsibleSection from './components/mr_widget_report_collapsible_section.vue'; import CollapsibleSection from '../vue_shared/components/security_reports/report_collapsible_section.vue';
export default { export default {
extends: CEWidgetOptions, extends: CEWidgetOptions,
components: { components: {
'mr-widget-approvals': WidgetApprovals, 'mr-widget-approvals': WidgetApprovals,
'mr-widget-geo-secondary-node': GeoSecondaryNode, 'mr-widget-geo-secondary-node': GeoSecondaryNode,
collapsibleSection, CollapsibleSection,
}, },
data() { data() {
return { return {
......
<script> <script>
import { __ } from '~/locale'; import { __ } from '~/locale';
import statusIcon from '~/vue_merge_request_widget/components/mr_widget_status_icon.vue'; import StatusIcon from '~/vue_merge_request_widget/components/mr_widget_status_icon.vue';
import loadingIcon from '~/vue_shared/components/loading_icon.vue'; import LoadingIcon from '~/vue_shared/components/loading_icon.vue';
import issuesBlock from './mr_widget_report_issues.vue'; import IssuesBlock from './report_issues.vue';
export default { export default {
name: 'MRWidgetCodeQualityCollapsible', name: 'ReportCollapsibleSection',
components: { components: {
issuesBlock, IssuesBlock,
loadingIcon, LoadingIcon,
statusIcon, StatusIcon,
}, },
props: { props: {
// security | codequality | performance | docker // security | codequality | performance | docker
...@@ -37,22 +37,22 @@ ...@@ -37,22 +37,22 @@
unresolvedIssues: { unresolvedIssues: {
type: Array, type: Array,
required: false, required: false,
default: () => [], default: () => ([]),
}, },
resolvedIssues: { resolvedIssues: {
type: Array, type: Array,
required: false, required: false,
default: () => [], default: () => ([]),
}, },
neutralIssues: { neutralIssues: {
type: Array, type: Array,
required: false, required: false,
default: () => [], default: () => ([]),
}, },
allIssues: { allIssues: {
type: Array, type: Array,
required: false, required: false,
default: () => [], default: () => ([]),
}, },
infoText: { infoText: {
type: [String, Boolean], type: [String, Boolean],
......
<script> <script>
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import modal from './mr_widget_dast_modal.vue'; import Modal from './dast_modal.vue';
const modalDefaultData = { const modalDefaultData = {
modalId: 'modal-mrwidget-issue', modalId: 'modal-mrwidget-issue',
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
}; };
export default { export default {
name: 'MrWidgetReportIssues', name: 'ReportIssues',
components: { components: {
modal, Modal,
icon, Icon,
}, },
props: { props: {
issues: { issues: {
......
.mr-widget-code-quality {
.code-quality-container {
border-top: 1px solid $gray-darker;
padding: $gl-padding-top;
background-color: $gray-light;
margin: $gl-padding -16px -16px;
.mr-widget-code-quality-info {
padding-left: 10px;
}
.mr-widget-dast-code {
margin-left: 26px;
}
.mr-widget-code-quality-list {
list-style: none;
padding: 0 1px;
margin: 0;
line-height: $code_line_height;
.btn-open-modal {
padding: 0 5px 4px;
}
.mr-widget-code-quality-list-item {
display: flex;
}
.mr-widget-code-quality-list-item-modal {
display: flex;
flex-wrap: wrap;
}
.failed .mr-widget-code-quality-icon {
color: $red-500;
}
.success .mr-widget-code-quality-icon {
color: $green-500;
}
.neutral .mr-widget-code-quality-icon {
color: $theme-gray-700;
}
.mr-widget-code-quality-icon {
margin: -5px 4px 0 0;
fill: currentColor;
}
}
}
}
import Vue from 'vue'; import Vue from 'vue';
import modal from 'ee/vue_merge_request_widget/components/mr_widget_dast_modal.vue'; import modal from 'ee/vue_shared/components/security_reports/dast_modal.vue';
import mountComponent from '../../helpers/vue_mount_component_helper'; import mountComponent from '../../../helpers/vue_mount_component_helper';
describe('mr widget modal', () => { describe('mr widget modal', () => {
let vm; let vm;
......
import Vue from 'vue'; import Vue from 'vue';
import mrWidgetCodeQuality from 'ee/vue_merge_request_widget/components/mr_widget_report_collapsible_section.vue'; import reportCollapsibleSection from 'ee/vue_shared/components/security_reports/report_collapsible_section.vue';
import mountComponent from '../../helpers/vue_mount_component_helper'; import mountComponent from '../../../helpers/vue_mount_component_helper';
import { codequalityParsedIssues } from '../mock_data'; import { codequalityParsedIssues } from '../../../vue_mr_widget/mock_data';
describe('Merge Request collapsible section', () => { describe('Report Collapsible section', () => {
let vm; let vm;
let MRWidgetCodeQuality; let ReportCollapsibleSection;
beforeEach(() => { beforeEach(() => {
MRWidgetCodeQuality = Vue.extend(mrWidgetCodeQuality); ReportCollapsibleSection = Vue.extend(reportCollapsibleSection);
}); });
afterEach(() => { afterEach(() => {
...@@ -17,7 +17,7 @@ describe('Merge Request collapsible section', () => { ...@@ -17,7 +17,7 @@ describe('Merge Request collapsible section', () => {
describe('when it is loading', () => { describe('when it is loading', () => {
it('should render loading indicator', () => { it('should render loading indicator', () => {
vm = mountComponent(MRWidgetCodeQuality, { vm = mountComponent(ReportCollapsibleSection, {
type: 'codequality', type: 'codequality',
status: 'loading', status: 'loading',
loadingText: 'Loading codeclimate report', loadingText: 'Loading codeclimate report',
...@@ -30,7 +30,7 @@ describe('Merge Request collapsible section', () => { ...@@ -30,7 +30,7 @@ describe('Merge Request collapsible section', () => {
describe('with success status', () => { describe('with success status', () => {
it('should render provided data', () => { it('should render provided data', () => {
vm = mountComponent(MRWidgetCodeQuality, { vm = mountComponent(ReportCollapsibleSection, {
type: 'codequality', type: 'codequality',
status: 'success', status: 'success',
loadingText: 'Loading codeclimate report', loadingText: 'Loading codeclimate report',
...@@ -50,7 +50,7 @@ describe('Merge Request collapsible section', () => { ...@@ -50,7 +50,7 @@ describe('Merge Request collapsible section', () => {
describe('toggleCollapsed', () => { describe('toggleCollapsed', () => {
it('toggles issues', (done) => { it('toggles issues', (done) => {
vm = mountComponent(MRWidgetCodeQuality, { vm = mountComponent(ReportCollapsibleSection, {
type: 'codequality', type: 'codequality',
status: 'success', status: 'success',
loadingText: 'Loading codeclimate report', loadingText: 'Loading codeclimate report',
...@@ -88,7 +88,7 @@ describe('Merge Request collapsible section', () => { ...@@ -88,7 +88,7 @@ describe('Merge Request collapsible section', () => {
describe('with failed request', () => { describe('with failed request', () => {
it('should render error indicator', () => { it('should render error indicator', () => {
vm = mountComponent(MRWidgetCodeQuality, { vm = mountComponent(ReportCollapsibleSection, {
type: 'codequality', type: 'codequality',
status: 'error', status: 'error',
loadingText: 'Loading codeclimate report', loadingText: 'Loading codeclimate report',
...@@ -101,7 +101,7 @@ describe('Merge Request collapsible section', () => { ...@@ -101,7 +101,7 @@ describe('Merge Request collapsible section', () => {
describe('With full report', () => { describe('With full report', () => {
beforeEach(() => { beforeEach(() => {
vm = mountComponent(MRWidgetCodeQuality, { vm = mountComponent(ReportCollapsibleSection, {
status: 'success', status: 'success',
successText: 'SAST improved on 1 security vulnerability and degraded on 1 security vulnerability', successText: 'SAST improved on 1 security vulnerability and degraded on 1 security vulnerability',
type: 'security', type: 'security',
......
import Vue from 'vue'; import Vue from 'vue';
import mrWidgetCodeQualityIssues from 'ee/vue_merge_request_widget/components/mr_widget_report_issues.vue'; import reportIssues from 'ee/vue_shared/components/security_reports/report_issues.vue';
import mountComponent from '../../helpers/vue_mount_component_helper'; import mountComponent from '../../../helpers/vue_mount_component_helper';
import { import {
securityParsedIssues, securityParsedIssues,
codequalityParsedIssues, codequalityParsedIssues,
dockerReportParsed, dockerReportParsed,
parsedDast, parsedDast,
} from '../mock_data'; } from '../../../vue_mr_widget/mock_data';
describe('merge request report issues', () => { describe('Report issues', () => {
let vm; let vm;
let MRWidgetCodeQualityIssues; let ReportIssues;
beforeEach(() => { beforeEach(() => {
MRWidgetCodeQualityIssues = Vue.extend(mrWidgetCodeQualityIssues); ReportIssues = Vue.extend(reportIssues);
}); });
afterEach(() => { afterEach(() => {
...@@ -23,7 +23,7 @@ describe('merge request report issues', () => { ...@@ -23,7 +23,7 @@ describe('merge request report issues', () => {
describe('for codequality issues', () => { describe('for codequality issues', () => {
describe('resolved issues', () => { describe('resolved issues', () => {
beforeEach(() => { beforeEach(() => {
vm = mountComponent(MRWidgetCodeQualityIssues, { vm = mountComponent(ReportIssues, {
issues: codequalityParsedIssues, issues: codequalityParsedIssues,
type: 'codequality', type: 'codequality',
status: 'success', status: 'success',
...@@ -44,7 +44,7 @@ describe('merge request report issues', () => { ...@@ -44,7 +44,7 @@ describe('merge request report issues', () => {
describe('unresolved issues', () => { describe('unresolved issues', () => {
beforeEach(() => { beforeEach(() => {
vm = mountComponent(MRWidgetCodeQualityIssues, { vm = mountComponent(ReportIssues, {
issues: codequalityParsedIssues, issues: codequalityParsedIssues,
type: 'codequality', type: 'codequality',
status: 'failed', status: 'failed',
...@@ -63,7 +63,7 @@ describe('merge request report issues', () => { ...@@ -63,7 +63,7 @@ describe('merge request report issues', () => {
describe('for security issues', () => { describe('for security issues', () => {
beforeEach(() => { beforeEach(() => {
vm = mountComponent(MRWidgetCodeQualityIssues, { vm = mountComponent(ReportIssues, {
issues: securityParsedIssues, issues: securityParsedIssues,
type: 'security', type: 'security',
status: 'failed', status: 'failed',
...@@ -82,7 +82,7 @@ describe('merge request report issues', () => { ...@@ -82,7 +82,7 @@ describe('merge request report issues', () => {
describe('with location', () => { describe('with location', () => {
it('should render location', () => { it('should render location', () => {
vm = mountComponent(MRWidgetCodeQualityIssues, { vm = mountComponent(ReportIssues, {
issues: securityParsedIssues, issues: securityParsedIssues,
type: 'security', type: 'security',
status: 'failed', status: 'failed',
...@@ -95,7 +95,7 @@ describe('merge request report issues', () => { ...@@ -95,7 +95,7 @@ describe('merge request report issues', () => {
describe('without location', () => { describe('without location', () => {
it('should not render location', () => { it('should not render location', () => {
vm = mountComponent(MRWidgetCodeQualityIssues, { vm = mountComponent(ReportIssues, {
issues: [{ issues: [{
name: 'foo', name: 'foo',
}], }],
...@@ -110,7 +110,7 @@ describe('merge request report issues', () => { ...@@ -110,7 +110,7 @@ describe('merge request report issues', () => {
describe('for docker issues', () => { describe('for docker issues', () => {
beforeEach(() => { beforeEach(() => {
vm = mountComponent(MRWidgetCodeQualityIssues, { vm = mountComponent(ReportIssues, {
issues: dockerReportParsed.unapproved, issues: dockerReportParsed.unapproved,
type: 'docker', type: 'docker',
status: 'failed', status: 'failed',
...@@ -145,7 +145,7 @@ describe('merge request report issues', () => { ...@@ -145,7 +145,7 @@ describe('merge request report issues', () => {
describe('for dast issues', () => { describe('for dast issues', () => {
beforeEach(() => { beforeEach(() => {
vm = mountComponent(MRWidgetCodeQualityIssues, { vm = mountComponent(ReportIssues, {
issues: parsedDast, issues: parsedDast,
type: 'dast', type: 'dast',
status: 'failed', status: 'failed',
......
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