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
ca258a57
Commit
ca258a57
authored
Jul 30, 2021
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Emit events in Vue with single arg instead of multiple
parent
0f763bf8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
20 deletions
+25
-20
ee/app/assets/javascripts/roadmap/components/roadmap_app.vue
ee/app/assets/javascripts/roadmap/components/roadmap_app.vue
+7
-8
ee/app/assets/javascripts/roadmap/components/roadmap_shell.vue
...p/assets/javascripts/roadmap/components/roadmap_shell.vue
+8
-2
ee/spec/frontend/roadmap/components/roadmap_app_spec.js
ee/spec/frontend/roadmap/components/roadmap_app_spec.js
+10
-10
No files found.
ee/app/assets/javascripts/roadmap/components/roadmap_app.vue
View file @
ca258a57
...
...
@@ -106,13 +106,13 @@ export default {
* 3. In case of prepending timeframe,
* reset scroll-position (due to DOM prepend).
*/
processExtendedTimeline
({
extend
Type
=
EXTEND_AS
.
PREPEND
,
roadmapTimelineEl
,
itemsCount
=
0
})
{
processExtendedTimeline
({
extend
As
=
EXTEND_AS
.
PREPEND
,
roadmapTimelineEl
,
itemsCount
=
0
})
{
// Re-render timeline bars with updated timeline
eventHub
.
$emit
(
'
refreshTimeline
'
,
{
todayBarReady
:
extend
Type
===
EXTEND_AS
.
PREPEND
,
todayBarReady
:
extend
As
===
EXTEND_AS
.
PREPEND
,
});
if
(
extend
Type
===
EXTEND_AS
.
PREPEND
)
{
if
(
extend
As
===
EXTEND_AS
.
PREPEND
)
{
// When DOM is prepended with elements
// we compensate the scrolling for added elements' width
roadmapTimelineEl
.
parentElement
.
scrollBy
(
...
...
@@ -121,8 +121,8 @@ export default {
);
}
},
handleScrollToExtend
(
roadmapTimelineEl
,
extendType
=
EXTEND_AS
.
PREPEND
)
{
this
.
extendTimeframe
({
extendAs
:
extendType
});
handleScrollToExtend
(
{
el
:
roadmapTimelineEl
,
extendAs
=
EXTEND_AS
.
PREPEND
}
)
{
this
.
extendTimeframe
({
extendAs
});
this
.
refreshEpicDates
();
this
.
refreshMilestoneDates
();
...
...
@@ -135,7 +135,7 @@ export default {
// Re-render timeline bars with updated timeline
this
.
processExtendedTimeline
({
itemsCount
:
this
.
extendedTimeframe
?
this
.
extendedTimeframe
.
length
:
0
,
extend
Type
,
extend
As
,
roadmapTimelineEl
,
});
});
...
...
@@ -164,9 +164,8 @@ export default {
primary-button-link=
"https://docs.gitlab.com/ee/user/group/roadmap/"
data-testid=
"epics_limit_callout"
@
dismiss=
"dismissTooManyEpicsWarning"
>
{{
$options
.
i18n
.
warningBody
}}
</gl-alert
>
{{
$options
.
i18n
.
warningBody
}}
</gl-alert>
<div
:class=
"
{ 'overflow-reset': epicsFetchResultEmpty }" class="roadmap-container">
<gl-loading-icon
v-if=
"epicsFetchInProgress"
class=
"gl-mt-5"
size=
"md"
/>
<epics-list-empty
...
...
ee/app/assets/javascripts/roadmap/components/roadmap_shell.vue
View file @
ca258a57
...
...
@@ -76,10 +76,16 @@ export default {
// If timeline was scrolled to start
if
(
isInViewport
(
timelineEdgeStartEl
,
{
left
:
this
.
timeframeStartOffset
}))
{
this
.
$emit
(
'
onScrollToStart
'
,
this
.
$refs
.
roadmapTimeline
.
$el
,
EXTEND_AS
.
PREPEND
);
this
.
$emit
(
'
onScrollToStart
'
,
{
el
:
this
.
$refs
.
roadmapTimeline
.
$el
,
extendAs
:
EXTEND_AS
.
PREPEND
,
});
}
else
if
(
isInViewport
(
timelineEdgeEndEl
))
{
// If timeline was scrolled to end
this
.
$emit
(
'
onScrollToEnd
'
,
this
.
$refs
.
roadmapTimeline
.
$el
,
EXTEND_AS
.
APPEND
);
this
.
$emit
(
'
onScrollToEnd
'
,
{
el
:
this
.
$refs
.
roadmapTimeline
.
$el
,
extendAs
:
EXTEND_AS
.
APPEND
,
});
}
eventHub
.
$emit
(
'
epicsListScrolled
'
,
{
scrollTop
,
scrollLeft
,
clientHeight
,
scrollHeight
});
...
...
ee/spec/frontend/roadmap/components/roadmap_app_spec.js
View file @
ca258a57
import
{
GlAlert
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
mount
,
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
Cookies
from
'
js-cookie
'
;
import
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
EpicsListEmpty
from
'
ee/roadmap/components/epics_list_empty.vue
'
;
import
RoadmapApp
from
'
ee/roadmap/components/roadmap_app.vue
'
;
...
...
@@ -212,27 +213,26 @@ describe('RoadmapApp', () => {
const
extendType
=
EXTEND_AS
.
PREPEND
;
wrapper
.
vm
.
handleScrollToExtend
(
roadmapTimelineEl
,
extendType
);
wrapper
.
vm
.
handleScrollToExtend
(
{
el
:
roadmapTimelineEl
,
extendAs
:
extendType
}
);
expect
(
wrapper
.
vm
.
extendTimeframe
).
toHaveBeenCalledWith
({
extendAs
:
extendType
});
expect
(
wrapper
.
vm
.
refreshEpicDates
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
refreshMilestoneDates
).
toHaveBeenCalled
();
});
it
(
'
calls `fetchEpicsForTimeframe` with extended timeframe array
'
,
()
=>
{
it
(
'
calls `fetchEpicsForTimeframe` with extended timeframe array
'
,
async
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
fetchEpicsForTimeframe
'
).
mockResolvedValue
();
const
extendType
=
EXTEND_AS
.
PREPEND
;
wrapper
.
vm
.
handleScrollToExtend
(
roadmapTimelineEl
,
extendType
);
wrapper
.
vm
.
handleScrollToExtend
(
{
el
:
roadmapTimelineEl
,
extendAs
:
extendType
}
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
expect
(
wrapper
.
vm
.
fetchEpicsForTimeframe
).
toHaveBeenCalledWith
(
expect
.
objectContaining
({
timeframe
:
wrapper
.
vm
.
extendedTimeframe
,
}),
);
});
await
nextTick
();
expect
(
wrapper
.
vm
.
fetchEpicsForTimeframe
).
toHaveBeenCalledWith
(
expect
.
objectContaining
({
timeframe
:
wrapper
.
vm
.
extendedTimeframe
,
}),
);
});
});
...
...
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