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
5dd1f8c1
Commit
5dd1f8c1
authored
Sep 22, 2021
by
Savas Vedova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix polling on vuln details page
Changelog: fixed EE: true
parent
8ef76585
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
6 deletions
+31
-6
ee/app/assets/javascripts/vulnerabilities/components/footer.vue
.../assets/javascripts/vulnerabilities/components/footer.vue
+14
-6
ee/spec/frontend/vulnerabilities/footer_spec.js
ee/spec/frontend/vulnerabilities/footer_spec.js
+17
-0
No files found.
ee/app/assets/javascripts/vulnerabilities/components/footer.vue
View file @
5dd1f8c1
...
@@ -71,6 +71,7 @@ export default {
...
@@ -71,6 +71,7 @@ export default {
this
.
discussionsLoading
=
false
;
this
.
discussionsLoading
=
false
;
this
.
notifyHeaderForStateChangeIfRequired
();
this
.
notifyHeaderForStateChangeIfRequired
();
this
.
startPolling
();
this
.
startPolling
();
this
.
bindVisibilityListener
();
},
},
error
()
{
error
()
{
this
.
showGraphQLError
();
this
.
showGraphQLError
();
...
@@ -114,6 +115,7 @@ export default {
...
@@ -114,6 +115,7 @@ export default {
},
},
beforeDestroy
()
{
beforeDestroy
()
{
this
.
stopPolling
();
this
.
stopPolling
();
this
.
unbindVisibilityListener
();
},
},
updated
()
{
updated
()
{
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
...
@@ -129,6 +131,17 @@ export default {
...
@@ -129,6 +131,17 @@ export default {
if
(
!
Visibility
.
hidden
())
{
if
(
!
Visibility
.
hidden
())
{
this
.
pollInterval
=
setInterval
(
this
.
fetchDiscussions
,
TEN_SECONDS
);
this
.
pollInterval
=
setInterval
(
this
.
fetchDiscussions
,
TEN_SECONDS
);
}
}
},
stopPolling
()
{
if
(
typeof
this
.
pollInterval
!==
'
undefined
'
)
{
clearInterval
(
this
.
pollInterval
);
this
.
pollInterval
=
undefined
;
}
},
bindVisibilityListener
()
{
if
(
this
.
visibilityListener
)
{
return
;
}
this
.
visibilityListener
=
Visibility
.
change
(()
=>
{
this
.
visibilityListener
=
Visibility
.
change
(()
=>
{
if
(
Visibility
.
hidden
())
{
if
(
Visibility
.
hidden
())
{
...
@@ -138,12 +151,7 @@ export default {
...
@@ -138,12 +151,7 @@ export default {
}
}
});
});
},
},
stopPolling
()
{
unbindVisibilityListener
()
{
if
(
typeof
this
.
pollInterval
!==
'
undefined
'
)
{
clearInterval
(
this
.
pollInterval
);
this
.
pollInterval
=
undefined
;
}
if
(
typeof
this
.
visibilityListener
!==
'
undefined
'
)
{
if
(
typeof
this
.
visibilityListener
!==
'
undefined
'
)
{
Visibility
.
unbind
(
this
.
visibilityListener
);
Visibility
.
unbind
(
this
.
visibilityListener
);
this
.
visibilityListener
=
undefined
;
this
.
visibilityListener
=
undefined
;
...
...
ee/spec/frontend/vulnerabilities/footer_spec.js
View file @
5dd1f8c1
...
@@ -174,6 +174,23 @@ describe('Vulnerability Footer', () => {
...
@@ -174,6 +174,23 @@ describe('Vulnerability Footer', () => {
expect
(
visibilityUnbindSpy
).
toHaveBeenCalled
();
expect
(
visibilityUnbindSpy
).
toHaveBeenCalled
();
});
});
it
(
'
does not remove the listener when the visibility changes
'
,
async
()
=>
{
const
clearIntervalSpy
=
jest
.
spyOn
(
window
,
'
clearInterval
'
);
const
visibilityUnbindSpy
=
jest
.
spyOn
(
Visibility
,
'
unbind
'
);
const
visibilityHiddenSpy
=
jest
.
spyOn
(
Visibility
,
'
hidden
'
)
.
mockImplementationOnce
(()
=>
false
)
// This is called in startPolling
.
mockImplementationOnce
(()
=>
true
);
// This is called in visibilityChangeListener
const
visibilityChangeSpy
=
jest
.
spyOn
(
Visibility
,
'
change
'
)
.
mockImplementation
((
callback
)
=>
callback
());
await
createWrapperAndFetchDiscussions
({
discussions
:
[]
});
expect
(
visibilityHiddenSpy
).
toHaveBeenCalled
();
expect
(
visibilityChangeSpy
).
toHaveBeenCalled
();
expect
(
clearIntervalSpy
).
toHaveBeenCalled
();
expect
(
visibilityUnbindSpy
).
not
.
toHaveBeenCalled
();
});
it
(
'
emits the vulnerability-state-change event when the system note is new
'
,
async
()
=>
{
it
(
'
emits the vulnerability-state-change event when the system note is new
'
,
async
()
=>
{
const
eventName
=
'
vulnerability-state-change
'
;
const
eventName
=
'
vulnerability-state-change
'
;
const
queryHandler
=
discussionsHandler
({
discussions
:
[
discussion1
]
});
// first call
const
queryHandler
=
discussionsHandler
({
discussions
:
[
discussion1
]
});
// first call
...
...
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