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
355bf7d5
Commit
355bf7d5
authored
Feb 25, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
80646fd8
4f5bb088
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
5 deletions
+55
-5
app/assets/javascripts/lib/utils/poll.js
app/assets/javascripts/lib/utils/poll.js
+17
-3
app/assets/javascripts/pipelines/mixins/pipelines.js
app/assets/javascripts/pipelines/mixins/pipelines.js
+1
-2
changelogs/unreleased/sh-fix-double-xhr-pipelines.yml
changelogs/unreleased/sh-fix-double-xhr-pipelines.yml
+5
-0
spec/javascripts/lib/utils/poll_spec.js
spec/javascripts/lib/utils/poll_spec.js
+32
-0
No files found.
app/assets/javascripts/lib/utils/poll.js
View file @
355bf7d5
...
...
@@ -63,6 +63,10 @@ export default class Poll {
const
headers
=
normalizeHeaders
(
response
.
headers
);
const
pollInterval
=
parseInt
(
headers
[
this
.
intervalHeader
],
10
);
if
(
pollInterval
>
0
&&
successCodes
.
indexOf
(
response
.
status
)
!==
-
1
&&
this
.
canPoll
)
{
if
(
this
.
timeoutID
)
{
clearTimeout
(
this
.
timeoutID
);
}
this
.
timeoutID
=
setTimeout
(()
=>
{
this
.
makeRequest
();
},
pollInterval
);
...
...
@@ -101,15 +105,25 @@ export default class Poll {
}
/**
*
Restarts polling after it has been sto
ped
*
Enables polling after it has been stop
ped
*/
restart
(
options
)
{
// update data
enable
(
options
)
{
if
(
options
&&
options
.
data
)
{
this
.
options
.
data
=
options
.
data
;
}
this
.
canPoll
=
true
;
if
(
options
&&
options
.
response
)
{
this
.
checkConditions
(
options
.
response
);
}
}
/**
* Restarts polling after it has been stopped and makes a request
*/
restart
(
options
)
{
this
.
enable
(
options
);
this
.
makeRequest
();
}
}
app/assets/javascripts/pipelines/mixins/pipelines.js
View file @
355bf7d5
...
...
@@ -94,8 +94,7 @@ export default {
this
.
isLoading
=
false
;
this
.
successCallback
(
response
);
// restart polling
this
.
poll
.
restart
({
data
:
this
.
requestData
});
this
.
poll
.
enable
({
data
:
this
.
requestData
,
response
});
})
.
catch
(()
=>
{
this
.
isLoading
=
false
;
...
...
changelogs/unreleased/sh-fix-double-xhr-pipelines.yml
0 → 100644
View file @
355bf7d5
---
title
:
Remove duplicate XHR request when requesting new pipeline page
merge_request
:
25506
author
:
type
:
fixed
spec/javascripts/lib/utils/poll_spec.js
View file @
355bf7d5
...
...
@@ -153,6 +153,36 @@ describe('Poll', () => {
});
});
describe
(
'
enable
'
,
()
=>
{
it
(
'
should enable polling upon a response
'
,
done
=>
{
jasmine
.
clock
().
install
();
const
Polling
=
new
Poll
({
resource
:
service
,
method
:
'
fetch
'
,
data
:
{
page
:
1
},
successCallback
:
()
=>
{},
});
Polling
.
enable
({
data
:
{
page
:
4
},
response
:
{
status
:
200
,
headers
:
{
'
poll-interval
'
:
1
}
},
});
jasmine
.
clock
().
tick
(
1
);
jasmine
.
clock
().
uninstall
();
waitForAllCallsToFinish
(
service
,
1
,
()
=>
{
Polling
.
stop
();
expect
(
service
.
fetch
.
calls
.
count
()).
toEqual
(
1
);
expect
(
service
.
fetch
).
toHaveBeenCalledWith
({
page
:
4
});
expect
(
Polling
.
options
.
data
).
toEqual
({
page
:
4
});
done
();
});
});
});
describe
(
'
restart
'
,
()
=>
{
it
(
'
should restart polling when its called
'
,
done
=>
{
mockServiceCall
(
service
,
{
status
:
200
,
headers
:
{
'
poll-interval
'
:
1
}
});
...
...
@@ -171,6 +201,7 @@ describe('Poll', () => {
});
spyOn
(
Polling
,
'
stop
'
).
and
.
callThrough
();
spyOn
(
Polling
,
'
enable
'
).
and
.
callThrough
();
spyOn
(
Polling
,
'
restart
'
).
and
.
callThrough
();
Polling
.
makeRequest
();
...
...
@@ -181,6 +212,7 @@ describe('Poll', () => {
expect
(
service
.
fetch
.
calls
.
count
()).
toEqual
(
2
);
expect
(
service
.
fetch
).
toHaveBeenCalledWith
({
page
:
4
});
expect
(
Polling
.
stop
).
toHaveBeenCalled
();
expect
(
Polling
.
enable
).
toHaveBeenCalled
();
expect
(
Polling
.
restart
).
toHaveBeenCalled
();
expect
(
Polling
.
options
.
data
).
toEqual
({
page
:
4
});
done
();
...
...
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