BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
429eb466
Commit
429eb466
authored
Mar 09, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent dropdown from closing when user clicks in a build.
parent
1df518ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
mini_pipeline_graph_dropdown.js
app/assets/javascripts/mini_pipeline_graph_dropdown.js
+16
-0
mini_pipeline_graph_dropdown_spec.js
spec/javascripts/mini_pipeline_graph_dropdown_spec.js
+15
-0
No files found.
app/assets/javascripts/mini_pipeline_graph_dropdown.js
View file @
429eb466
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
this
.
container
=
opts
.
container
||
''
;
this
.
container
=
opts
.
container
||
''
;
this
.
dropdownListSelector
=
'.js-builds-dropdown-container'
;
this
.
dropdownListSelector
=
'.js-builds-dropdown-container'
;
this
.
getBuildsList
=
this
.
getBuildsList
.
bind
(
this
);
this
.
getBuildsList
=
this
.
getBuildsList
.
bind
(
this
);
this
.
stopDropdownClickPropagation
();
}
}
/**
/**
...
@@ -32,6 +34,20 @@
...
@@ -32,6 +34,20 @@
}
}
/**
/**
* When the user right clicks or cmd/ctrl + click in the job name
* the dropdown should not be closed and the link should open in another tab,
* so we stop propagation of the click event inside the dropdown.
*
* Since this component is rendered multiple times per page we need to guarantee we only
* target the click event of this component.
*/
stopDropdownClickPropagation
()
{
$
(
document
).
on
(
'click'
,
`
${
this
.
container
}
.js-builds-dropdown-list a.mini-pipeline-graph-dropdown-item`
,
(
e
)
=>
{
e
.
stopPropagation
();
});
}
/**
* For the clicked stage, renders the given data in the dropdown list.
* For the clicked stage, renders the given data in the dropdown list.
*
*
* @param {HTMLElement} stageContainer
* @param {HTMLElement} stageContainer
...
...
spec/javascripts/mini_pipeline_graph_dropdown_spec.js
View file @
429eb466
...
@@ -46,6 +46,21 @@ require('~/mini_pipeline_graph_dropdown');
...
@@ -46,6 +46,21 @@ require('~/mini_pipeline_graph_dropdown');
document
.
querySelector
(
'.js-builds-dropdown-button'
).
click
();
document
.
querySelector
(
'.js-builds-dropdown-button'
).
click
();
expect
(
ajaxSpy
.
calls
.
allArgs
()[
0
][
0
].
url
).
toEqual
(
'foobar'
);
expect
(
ajaxSpy
.
calls
.
allArgs
()[
0
][
0
].
url
).
toEqual
(
'foobar'
);
});
});
it
(
'should not close when user uses cmd/ctrl + click'
,
()
=>
{
spyOn
(
$
,
'ajax'
).
and
.
callFake
(
function
(
params
)
{
params
.
success
({
html
:
'
\
u003cli
\
u003e
\
n
\
u003ca class="mini-pipeline-graph-dropdown-item" href="#"
\
u003e
\
u003cspan class="ci-status-icon ci-status-icon-failed"
\
u003e
\
u003c/span
\
u003e
\
n
\
u003cspan class="ci-build-text"
\
u003ebuild
\
u003c/span
\
u003e
\
n
\
u003c/a
\
u003e
\
u003ca class="ci-action-icon-wrapper js-ci-action-icon" href="#"
\
u003e
\
u003c/a
\
u003e
\
n
\
u003c/li
\
u003e
\
n'
,
});
});
new
gl
.
MiniPipelineGraph
({
container
:
'.js-builds-dropdown-tests'
}).
bindEvents
();
document
.
querySelector
(
'.js-builds-dropdown-button'
).
click
();
document
.
querySelector
(
'a.mini-pipeline-graph-dropdown-item'
).
click
();
expect
(
$
(
'.js-builds-dropdown-list'
).
is
(
':visible'
)).
toEqual
(
true
);
});
});
});
});
});
})();
})();
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