Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b8b3e4dc
Commit
b8b3e4dc
authored
Nov 16, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve conflicts
parent
387f2e04
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
222 deletions
+16
-222
ee/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_code_quality.vue
...erge_request_widget/components/mr_widget_code_quality.vue
+0
-188
ee/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_report_collapsible_section.vue
...idget/components/mr_widget_report_collapsible_section.vue
+0
-1
spec/javascripts/vue_mr_widget/ee_mr_widget_options_spec.js
spec/javascripts/vue_mr_widget/ee_mr_widget_options_spec.js
+16
-33
No files found.
ee/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_code_quality.vue
deleted
100644 → 0
View file @
387f2e04
<
script
>
import
statusIcon
from
'
~/vue_merge_request_widget/components/mr_widget_status_icon
'
;
import
loadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
{
pluralize
}
from
'
~/lib/utils/text_utility
'
;
import
issuesBlock
from
'
./mr_widget_code_quality_issues.vue
'
;
export
default
{
name
:
'
MRWidgetCodeQuality
'
,
props
:
{
mr
:
{
type
:
Object
,
required
:
true
,
},
service
:
{
type
:
Object
,
required
:
true
,
},
},
components
:
{
issuesBlock
,
loadingIcon
,
statusIcon
,
},
data
()
{
return
{
collapseText
:
'
Expand
'
,
isCollapsed
:
true
,
isLoading
:
false
,
loadingFailed
:
false
,
};
},
computed
:
{
status
()
{
if
(
this
.
loadingFailed
||
this
.
mr
.
codeclimateMetrics
.
newIssues
.
length
)
{
return
'
warning
'
;
}
return
'
success
'
;
},
hasNoneIssues
()
{
const
{
newIssues
,
resolvedIssues
}
=
this
.
mr
.
codeclimateMetrics
;
return
!
newIssues
.
length
&&
!
resolvedIssues
.
length
;
},
hasIssues
()
{
const
{
newIssues
,
resolvedIssues
}
=
this
.
mr
.
codeclimateMetrics
;
return
newIssues
.
length
||
resolvedIssues
.
length
;
},
codeText
()
{
const
{
newIssues
,
resolvedIssues
}
=
this
.
mr
.
codeclimateMetrics
;
let
newIssuesText
;
let
resolvedIssuesText
;
let
text
=
[];
if
(
this
.
hasNoneIssues
)
{
text
.
push
(
'
No changes to code quality
'
);
}
else
if
(
this
.
hasIssues
)
{
if
(
newIssues
.
length
)
{
newIssuesText
=
` degraded on
${
newIssues
.
length
}
${
this
.
pointsText
(
newIssues
)}
`
;
}
if
(
resolvedIssues
.
length
)
{
resolvedIssuesText
=
` improved on
${
resolvedIssues
.
length
}
${
this
.
pointsText
(
resolvedIssues
)}
`
;
}
const
connector
=
(
newIssues
.
length
>
0
&&
resolvedIssues
.
length
>
0
)
?
'
and
'
:
null
;
text
=
[
'
Code quality
'
];
if
(
resolvedIssuesText
)
{
text
.
push
(
resolvedIssuesText
);
}
if
(
connector
)
{
text
.
push
(
connector
);
}
if
(
newIssuesText
)
{
text
.
push
(
newIssuesText
);
}
}
return
text
.
join
(
''
);
},
},
methods
:
{
pointsText
(
issues
)
{
return
pluralize
(
'
point
'
,
issues
.
length
);
},
toggleCollapsed
()
{
this
.
isCollapsed
=
!
this
.
isCollapsed
;
const
text
=
this
.
isCollapsed
?
'
Expand
'
:
'
Collapse
'
;
this
.
collapseText
=
text
;
},
handleError
()
{
this
.
isLoading
=
false
;
this
.
loadingFailed
=
true
;
},
},
created
()
{
const
{
head_path
,
head_blob_path
,
base_path
,
base_blob_path
}
=
this
.
mr
.
codeclimate
;
this
.
isLoading
=
true
;
Promise
.
all
([
this
.
service
.
fetchCodeclimate
(
head_path
)
.
then
(
resp
=>
resp
.
json
()),
this
.
service
.
fetchCodeclimate
(
base_path
)
.
then
(
resp
=>
resp
.
json
()),
])
.
then
((
values
)
=>
{
this
.
mr
.
compareCodeclimateMetrics
(
values
[
0
],
values
[
1
],
head_blob_path
,
base_blob_path
);
this
.
isLoading
=
false
;
})
.
catch
(()
=>
this
.
handleError
());
},
};
</
script
>
<
template
>
<section
class=
"mr-widget-code-quality mr-widget-section"
>
<div
v-if=
"isLoading"
class=
"media"
>
<div
class=
"mr-widget-icon"
>
<loading-icon
/>
</div>
<div
class=
"media-body"
>
Loading codeclimate report
</div>
</div>
<div
v-else-if=
"!isLoading && !loadingFailed"
class=
"media"
>
<status-icon
:status=
"status"
/>
<div
class=
"media-body space-children"
>
<span
class=
"js-code-text"
>
{{
codeText
}}
</span>
<button
type=
"button"
class=
"btn-link btn-blank"
v-if=
"hasIssues"
@
click=
"toggleCollapsed"
>
{{
collapseText
}}
</button>
</div>
</div>
<div
class=
"code-quality-container"
v-if=
"hasIssues"
v-show=
"!isCollapsed"
>
<issues-block
class=
"js-mr-code-resolved-issues"
v-if=
"mr.codeclimateMetrics.resolvedIssues.length"
type=
"success"
:issues=
"mr.codeclimateMetrics.resolvedIssues"
/>
<issues-block
class=
"js-mr-code-new-issues"
v-if=
"mr.codeclimateMetrics.newIssues.length"
type=
"failed"
:issues=
"mr.codeclimateMetrics.newIssues"
/>
</div>
<div
v-else-if=
"loadingFailed"
class=
"media"
>
<status-icon
status=
"failed"
/>
<div
class=
"media-body"
>
Failed to load codeclimate report
</div>
</div>
</section>
</
template
>
ee/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_report_collapsible_section.vue
View file @
b8b3e4dc
<
script
>
import
statusIcon
from
'
~/vue_merge_request_widget/components/mr_widget_status_icon
'
;
import
loadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
'
~/lib/utils/text_utility
'
;
import
issuesBlock
from
'
./mr_widget_report_issues.vue
'
;
export
default
{
...
...
spec/javascripts/vue_mr_widget/ee_mr_widget_options_spec.js
View file @
b8b3e4dc
import
Vue
from
'
vue
'
;
<<<<<<<
HEAD
import
mrWidgetOptions
from
'
ee/vue_merge_request_widget/mr_widget_options
'
;
import
MRWidgetService
from
'
ee/vue_merge_request_widget/services/mr_widget_service
'
;
import
MRWidgetStore
from
'
ee/vue_merge_request_widget/stores/mr_widget_store
'
;
import
mockData
,
{
baseIssues
,
headIssues
,
securityIssues
}
from
'
./mock_data
'
;
import
mountComponent
from
'
../helpers/vue_mount_component_helper
'
;
describe
(
'
ee merge request widget options
'
,
()
=>
{
let
vm
;
let
Component
;
let
mountComponent
;
beforeEach
(()
=>
{
delete
mrWidgetOptions
.
extends
.
el
;
// Prevent component mounting
Component
=
Vue
.
extend
(
mrWidgetOptions
);
mountComponent
=
()
=>
new
Component
().
$mount
();
=======
import
mrWidgetOptionsEE
from
'
ee/vue_merge_request_widget/mr_widget_options
'
;
import
mockData
from
'
./mock_data
'
;
import
mountComponent
from
'
../helpers/vue_mount_component_helper
'
;
describe
(
'
EE mrWidgetOptions
'
,
()
=>
{
let
vm
;
let
MrWidgetOptions
;
beforeEach
(()
=>
{
// Prevent component mounting
delete
mrWidgetOptionsEE
.
extends
.
el
;
MrWidgetOptions
=
Vue
.
extend
(
mrWidgetOptionsEE
);
>>>>>>>
ee
-
com
/
master
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
<<<<<<<
HEAD
describe
(
'
security widget
'
,
()
=>
{
beforeEach
(()
=>
{
gl
.
mrWidgetData
=
{
...
...
@@ -54,7 +35,7 @@ describe('EE mrWidgetOptions', () => {
describe
(
'
when it is loading
'
,
()
=>
{
it
(
'
should render loading indicator
'
,
()
=>
{
vm
=
mountComponent
();
vm
=
mountComponent
(
Component
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-sast-widget
'
).
textContent
.
trim
(),
).
toContain
(
'
Loading security report
'
);
...
...
@@ -72,7 +53,7 @@ describe('EE mrWidgetOptions', () => {
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
interceptor
);
vm
=
mountComponent
();
vm
=
mountComponent
(
Component
);
});
afterEach
(()
=>
{
...
...
@@ -100,7 +81,7 @@ describe('EE mrWidgetOptions', () => {
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
emptyInterceptor
);
vm
=
mountComponent
();
vm
=
mountComponent
(
Component
);
});
afterEach
(()
=>
{
...
...
@@ -128,7 +109,7 @@ describe('EE mrWidgetOptions', () => {
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
errorInterceptor
);
vm
=
mountComponent
();
vm
=
mountComponent
(
Component
);
});
afterEach
(()
=>
{
...
...
@@ -162,7 +143,7 @@ describe('EE mrWidgetOptions', () => {
describe
(
'
when it is loading
'
,
()
=>
{
it
(
'
should render loading indicator
'
,
()
=>
{
vm
=
mountComponent
();
vm
=
mountComponent
(
Component
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget
'
).
textContent
.
trim
(),
).
toContain
(
'
Loading codeclimate report
'
);
...
...
@@ -186,7 +167,7 @@ describe('EE mrWidgetOptions', () => {
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
interceptor
);
vm
=
mountComponent
();
vm
=
mountComponent
(
Component
);
});
afterEach
(()
=>
{
...
...
@@ -247,7 +228,7 @@ describe('EE mrWidgetOptions', () => {
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
emptyInterceptor
);
vm
=
mountComponent
();
vm
=
mountComponent
(
Component
);
});
afterEach
(()
=>
{
...
...
@@ -281,7 +262,7 @@ describe('EE mrWidgetOptions', () => {
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
errorInterceptor
);
vm
=
mountComponent
();
vm
=
mountComponent
(
Component
);
});
afterEach
(()
=>
{
...
...
@@ -293,11 +274,14 @@ describe('EE mrWidgetOptions', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget
'
).
textContent
.
trim
()).
toContain
(
'
Failed to load codeclimate report
'
);
done
();
},
0
);
=======
});
});
});
describe
(
'
computed
'
,
()
=>
{
describe
(
'
shouldRenderApprovals
'
,
()
=>
{
it
(
'
should return false when no approvals
'
,
()
=>
{
vm
=
mountComponent
(
MrWidgetOptions
,
{
vm
=
mountComponent
(
Component
,
{
mrData
:
{
...
mockData
,
approvalsRequired
:
false
,
...
...
@@ -309,7 +293,7 @@ describe('EE mrWidgetOptions', () => {
});
it
(
'
should return false when in empty state
'
,
()
=>
{
vm
=
mountComponent
(
MrWidgetOptions
,
{
vm
=
mountComponent
(
Component
,
{
mrData
:
{
...
mockData
,
approvalsRequired
:
true
,
...
...
@@ -321,7 +305,7 @@ describe('EE mrWidgetOptions', () => {
});
it
(
'
should return true when requiring approvals and in non-empty state
'
,
()
=>
{
vm
=
mountComponent
(
MrWidgetOptions
,
{
vm
=
mountComponent
(
Component
,
{
mrData
:
{
...
mockData
,
approvalsRequired
:
true
,
...
...
@@ -330,7 +314,6 @@ describe('EE mrWidgetOptions', () => {
vm
.
mr
.
state
=
'
readyToMerge
'
;
expect
(
vm
.
shouldRenderApprovals
).
toBeTruthy
();
>>>>>>>
ee
-
com
/
master
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment