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
d700659b
Commit
d700659b
authored
Jan 30, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move mr widget related links into a vue file
parent
a20e02a5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
123 deletions
+95
-123
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.js
...erge_request_widget/components/mr_widget_related_links.js
+0
-37
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.vue
...rge_request_widget/components/mr_widget_related_links.vue
+42
-0
app/assets/javascripts/vue_merge_request_widget/dependencies.js
...sets/javascripts/vue_merge_request_widget/dependencies.js
+1
-1
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
...javascripts/vue_merge_request_widget/mr_widget_options.js
+4
-2
spec/javascripts/vue_mr_widget/components/mr_widget_related_links_spec.js
.../vue_mr_widget/components/mr_widget_related_links_spec.js
+48
-83
No files found.
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.js
deleted
100644 → 0
View file @
a20e02a5
export
default
{
name
:
'
MRWidgetRelatedLinks
'
,
props
:
{
relatedLinks
:
{
type
:
Object
,
required
:
true
},
state
:
{
type
:
String
,
required
:
false
},
},
computed
:
{
hasLinks
()
{
const
{
closing
,
mentioned
,
assignToMe
}
=
this
.
relatedLinks
;
return
closing
||
mentioned
||
assignToMe
;
},
closesText
()
{
if
(
this
.
state
===
'
merged
'
)
{
return
'
Closed
'
;
}
if
(
this
.
state
===
'
closed
'
)
{
return
'
Did not close
'
;
}
return
'
Closes
'
;
},
},
template
:
`
<section
v-if="hasLinks"
class="mr-info-list mr-links">
<p v-if="relatedLinks.closing">
{{closesText}} <span v-html="relatedLinks.closing"></span>
</p>
<p v-if="relatedLinks.mentioned">
Mentions <span v-html="relatedLinks.mentioned"></span>
</p>
<p v-if="relatedLinks.assignToMe">
<span v-html="relatedLinks.assignToMe"></span>
</p>
</section>
`
,
};
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.vue
0 → 100644
View file @
d700659b
<
script
>
import
{
s__
}
from
'
~/locale
'
;
export
default
{
name
:
'
MRWidgetRelatedLinks
'
,
props
:
{
relatedLinks
:
{
type
:
Object
,
required
:
true
,
},
state
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
},
computed
:
{
closesText
()
{
if
(
this
.
state
===
'
merged
'
)
{
return
s__
(
'
mrWidget|Closed
'
);
}
if
(
this
.
state
===
'
closed
'
)
{
return
s__
(
'
mrWidget|Did not close
'
);
}
return
s__
(
'
mrWidget|Closes
'
);
},
},
};
</
script
>
<
template
>
<section
class=
"mr-info-list mr-links"
>
<p
v-if=
"relatedLinks.closing"
>
{{
closesText
}}
<span
v-html=
"relatedLinks.closing"
></span>
</p>
<p
v-if=
"relatedLinks.mentioned"
>
Mentions
<span
v-html=
"relatedLinks.mentioned"
></span>
</p>
<p
v-if=
"relatedLinks.assignToMe"
>
<span
v-html=
"relatedLinks.assignToMe"
></span>
</p>
</section>
</
template
>
app/assets/javascripts/vue_merge_request_widget/dependencies.js
View file @
d700659b
...
...
@@ -15,7 +15,7 @@ export { default as WidgetHeader } from './components/mr_widget_header';
export
{
default
as
WidgetMergeHelp
}
from
'
./components/mr_widget_merge_help
'
;
export
{
default
as
WidgetPipeline
}
from
'
./components/mr_widget_pipeline.vue
'
;
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
.vue
'
;
export
{
default
as
MergedState
}
from
'
./components/states/mr_widget_merged.vue
'
;
export
{
default
as
FailedToMerge
}
from
'
./components/states/mr_widget_failed_to_merge.vue
'
;
export
{
default
as
ClosedState
}
from
'
./components/states/mr_widget_closed.vue
'
;
...
...
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
View file @
d700659b
...
...
@@ -63,7 +63,8 @@ export default {
return
this
.
mr
.
hasCI
;
},
shouldRenderRelatedLinks
()
{
return
!!
this
.
mr
.
relatedLinks
&&
!
this
.
mr
.
isNothingToMergeState
;
const
{
closing
,
mentioned
,
assignToMe
}
=
this
.
mr
.
relatedLinks
;
return
(
closing
||
mentioned
||
assignToMe
)
&&
!
this
.
mr
.
isNothingToMergeState
;
},
shouldRenderDeployments
()
{
return
this
.
mr
.
deployments
.
length
;
...
...
@@ -257,7 +258,8 @@ export default {
<mr-widget-related-links
v-if="shouldRenderRelatedLinks"
:state="mr.state"
:related-links="mr.relatedLinks" />
:related-links="mr.relatedLinks"
/>
</div>
<div
class="mr-widget-footer"
...
...
spec/javascripts/vue_mr_widget/components/mr_widget_related_links_spec.js
View file @
d700659b
import
Vue
from
'
vue
'
;
import
relatedLinksComponent
from
'
~/vue_merge_request_widget/components/mr_widget_related_links
'
;
const
createComponent
=
(
data
)
=>
{
const
Component
=
Vue
.
extend
(
relatedLinksComponent
);
return
new
Component
({
el
:
document
.
createElement
(
'
div
'
),
propsData
:
data
,
});
};
import
relatedLinksComponent
from
'
~/vue_merge_request_widget/components/mr_widget_related_links.vue
'
;
import
mountComponent
from
'
../../helpers/vue_mount_component_helper
'
;
describe
(
'
MRWidgetRelatedLinks
'
,
()
=>
{
describe
(
'
props
'
,
()
=>
{
it
(
'
should have props
'
,
()
=>
{
const
{
relatedLinks
}
=
relatedLinksComponent
.
props
;
let
vm
;
expect
(
relatedLinks
).
toBeDefined
();
expect
(
relatedLinks
.
type
instanceof
Object
).
toBeTruthy
();
expect
(
relatedLinks
.
required
).
toBeTruthy
();
});
});
const
createComponent
=
(
data
)
=>
{
const
Component
=
Vue
.
extend
(
relatedLinksComponent
);
describe
(
'
computed
'
,
()
=>
{
const
data
=
{
relatedLinks
:
{
closing
:
'
/foo
'
,
mentioned
:
'
/foo
'
,
assignToMe
:
'
/foo
'
,
},
return
mountComponent
(
Component
,
data
);
};
describe
(
'
hasLinks
'
,
()
=>
{
it
(
'
should return correct value when we have links reference
'
,
()
=>
{
const
vm
=
createComponent
(
data
);
expect
(
vm
.
hasLinks
).
toBeTruthy
();
vm
.
relatedLinks
.
closing
=
null
;
expect
(
vm
.
hasLinks
).
toBeTruthy
();
vm
.
relatedLinks
.
mentioned
=
null
;
expect
(
vm
.
hasLinks
).
toBeTruthy
();
vm
.
relatedLinks
.
assignToMe
=
null
;
expect
(
vm
.
hasLinks
).
toBeFalsy
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'
computed
'
,
()
=>
{
describe
(
'
closesText
'
,
()
=>
{
it
(
'
returns correct text for open merge request
'
,
()
=>
{
data
.
state
=
'
open
'
;
const
vm
=
createComponent
(
data
);
it
(
'
returns Closes text for open merge request
'
,
()
=>
{
vm
=
createComponent
({
state
:
'
open
'
,
relatedLinks
:
{}
});
expect
(
vm
.
closesText
).
toEqual
(
'
Closes
'
);
});
it
(
'
returns correct text for closed merge request
'
,
()
=>
{
data
.
state
=
'
closed
'
;
const
vm
=
createComponent
(
data
);
vm
=
createComponent
({
state
:
'
closed
'
,
relatedLinks
:
{}
});
expect
(
vm
.
closesText
).
toEqual
(
'
Did not close
'
);
});
it
(
'
returns correct tense for merged request
'
,
()
=>
{
data
.
state
=
'
merged
'
;
const
vm
=
createComponent
(
data
);
vm
=
createComponent
({
state
:
'
merged
'
,
relatedLinks
:
{}
});
expect
(
vm
.
closesText
).
toEqual
(
'
Closed
'
);
});
});
});
describe
(
'
template
'
,
()
=>
{
it
(
'
should have only have closing issues text
'
,
()
=>
{
const
vm
=
createComponent
({
vm
=
createComponent
({
relatedLinks
:
{
closing
:
'
<a href="#">#23</a> and <a>#42</a>
'
,
},
...
...
@@ -81,7 +47,7 @@ describe('MRWidgetRelatedLinks', () => {
});
it
(
'
should have only have mentioned issues text
'
,
()
=>
{
const
vm
=
createComponent
({
vm
=
createComponent
({
relatedLinks
:
{
mentioned
:
'
<a href="#">#7</a>
'
,
},
...
...
@@ -92,7 +58,7 @@ describe('MRWidgetRelatedLinks', () => {
});
it
(
'
should have closing and mentioned issues at the same time
'
,
()
=>
{
const
vm
=
createComponent
({
vm
=
createComponent
({
relatedLinks
:
{
closing
:
'
<a href="#">#7</a>
'
,
mentioned
:
'
<a href="#">#23</a> and <a>#42</a>
'
,
...
...
@@ -105,7 +71,7 @@ describe('MRWidgetRelatedLinks', () => {
});
it
(
'
should have assing issues link
'
,
()
=>
{
const
vm
=
createComponent
({
vm
=
createComponent
({
relatedLinks
:
{
assignToMe
:
'
<a href="#">Assign yourself to these issues</a>
'
,
},
...
...
@@ -113,5 +79,4 @@ describe('MRWidgetRelatedLinks', () => {
expect
(
vm
.
$el
.
innerText
).
toContain
(
'
Assign yourself to these issues
'
);
});
});
});
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