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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
ab61eca7
Commit
ab61eca7
authored
Apr 06, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checks if commit information exists before trying to render it
parent
41ee09c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
49 deletions
+104
-49
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.vue
...ue_merge_request_widget/components/mr_widget_pipeline.vue
+58
-49
changelogs/unreleased/44296-commit-path.yml
changelogs/unreleased/44296-commit-path.yml
+6
-0
spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js
...ripts/vue_mr_widget/components/mr_widget_pipeline_spec.js
+40
-0
No files found.
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.vue
View file @
ab61eca7
<
script
>
<
script
>
/* eslint-disable vue/require-default-prop */
/* eslint-disable vue/require-default-prop */
import
p
ipelineStage
from
'
~/pipelines/components/stage.vue
'
;
import
P
ipelineStage
from
'
~/pipelines/components/stage.vue
'
;
import
c
iIcon
from
'
~/vue_shared/components/ci_icon.vue
'
;
import
C
iIcon
from
'
~/vue_shared/components/ci_icon.vue
'
;
import
i
con
from
'
~/vue_shared/components/icon.vue
'
;
import
I
con
from
'
~/vue_shared/components/icon.vue
'
;
export
default
{
export
default
{
name
:
'
MRWidgetPipeline
'
,
name
:
'
MRWidgetPipeline
'
,
components
:
{
components
:
{
pipelineStage
,
PipelineStage
,
ciIcon
,
CiIcon
,
icon
,
Icon
,
},
props
:
{
pipeline
:
{
type
:
Object
,
required
:
true
,
},
},
props
:
{
// This prop needs to be camelCase, html attributes are case insensive
pipeline
:
{
// https://vuejs.org/v2/guide/components.html#camelCase-vs-kebab-case
type
:
Object
,
hasCi
:
{
required
:
true
,
type
:
Boolean
,
},
required
:
false
,
// This prop needs to be camelCase, html attributes are case insensive
// https://vuejs.org/v2/guide/components.html#camelCase-vs-kebab-case
hasCi
:
{
type
:
Boolean
,
required
:
false
,
},
ciStatus
:
{
type
:
String
,
required
:
false
,
},
},
},
computed
:
{
ciStatus
:
{
hasPipeline
()
{
type
:
String
,
return
this
.
pipeline
&&
Object
.
keys
(
this
.
pipeline
).
length
>
0
;
required
:
false
,
},
hasCIError
()
{
return
this
.
hasCi
&&
!
this
.
ciStatus
;
},
status
()
{
return
this
.
pipeline
.
details
&&
this
.
pipeline
.
details
.
status
?
this
.
pipeline
.
details
.
status
:
{};
},
hasStages
()
{
return
this
.
pipeline
.
details
&&
this
.
pipeline
.
details
.
stages
&&
this
.
pipeline
.
details
.
stages
.
length
;
},
},
},
};
},
computed
:
{
hasPipeline
()
{
return
this
.
pipeline
&&
Object
.
keys
(
this
.
pipeline
).
length
>
0
;
},
hasCIError
()
{
return
this
.
hasCi
&&
!
this
.
ciStatus
;
},
status
()
{
return
this
.
pipeline
.
details
&&
this
.
pipeline
.
details
.
status
?
this
.
pipeline
.
details
.
status
:
{};
},
hasStages
()
{
return
(
this
.
pipeline
.
details
&&
this
.
pipeline
.
details
.
stages
&&
this
.
pipeline
.
details
.
stages
.
length
);
},
hasCommitInfo
()
{
return
this
.
pipeline
.
commit
&&
Object
.
keys
(
this
.
pipeline
.
commit
).
length
>
0
;
},
},
};
</
script
>
</
script
>
<
template
>
<
template
>
<div
<div
v-if=
"hasPipeline || hasCIError"
v-if=
"hasPipeline || hasCIError"
class=
"mr-widget-heading"
>
class=
"mr-widget-heading"
>
<div
class=
"ci-widget media"
>
<div
class=
"ci-widget media"
>
<template
v-if=
"hasCIError"
>
<template
v-if=
"hasCIError"
>
<div
class=
"ci-status-icon ci-status-icon-failed ci-error js-ci-error append-right-10"
>
<div
class=
"ci-status-icon ci-status-icon-failed ci-error js-ci-error append-right-10"
>
...
@@ -77,13 +82,17 @@
...
@@ -77,13 +82,17 @@
#
{{
pipeline
.
id
}}
#
{{
pipeline
.
id
}}
</a>
</a>
{{
pipeline
.
details
.
status
.
label
}}
for
{{
pipeline
.
details
.
status
.
label
}}
<a
<template
v-if=
"hasCommitInfo"
>
:href=
"pipeline.commit.commit_path"
for
class=
"commit-sha js-commit-link"
>
<a
{{
pipeline
.
commit
.
short_id
}}
</a>
.
:href=
"pipeline.commit.commit_path"
class=
"commit-sha js-commit-link"
>
{{
pipeline
.
commit
.
short_id
}}
</a>
.
</
template
>
<span
class=
"mr-widget-pipeline-graph"
>
<span
class=
"mr-widget-pipeline-graph"
>
<span
<span
...
...
changelogs/unreleased/44296-commit-path.yml
0 → 100644
View file @
ab61eca7
---
title
:
Verifiy if pipeline has commit idetails and render information in MR widget
when branch is deleted
merge_request
:
author
:
type
:
fixed
spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js
View file @
ab61eca7
...
@@ -113,6 +113,46 @@ describe('MRWidgetPipeline', () => {
...
@@ -113,6 +113,46 @@ describe('MRWidgetPipeline', () => {
});
});
});
});
describe
(
'
without commit path
'
,
()
=>
{
beforeEach
(()
=>
{
const
mockCopy
=
Object
.
assign
({},
mockData
);
delete
mockCopy
.
pipeline
.
commit
;
vm
=
mountComponent
(
Component
,
{
pipeline
:
mockCopy
.
pipeline
,
hasCi
:
true
,
ciStatus
:
'
success
'
,
});
});
it
(
'
should render pipeline ID
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.pipeline-id
'
).
textContent
.
trim
(),
).
toEqual
(
`#
${
mockData
.
pipeline
.
id
}
`
);
});
it
(
'
should render pipeline status
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.media-body
'
).
textContent
.
trim
(),
).
toContain
(
mockData
.
pipeline
.
details
.
status
.
label
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-commit-link
'
),
).
toBeNull
();
});
it
(
'
should render pipeline graph
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.mr-widget-pipeline-graph
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelectorAll
(
'
.stage-container
'
).
length
).
toEqual
(
mockData
.
pipeline
.
details
.
stages
.
length
);
});
it
(
'
should render coverage information
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.media-body
'
).
textContent
,
).
toContain
(
`Coverage
${
mockData
.
pipeline
.
coverage
}
`
);
});
});
describe
(
'
without coverage
'
,
()
=>
{
describe
(
'
without coverage
'
,
()
=>
{
it
(
'
should not render a coverage
'
,
()
=>
{
it
(
'
should not render a coverage
'
,
()
=>
{
const
mockCopy
=
Object
.
assign
({},
mockData
);
const
mockCopy
=
Object
.
assign
({},
mockData
);
...
...
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