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
Léo-Paul Géneau
gitlab-ce
Commits
25fec0f8
Commit
25fec0f8
authored
Feb 09, 2017
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix regression where cmd-click stopped working for todos and merge request tabs
parent
059f47b6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
18 deletions
+112
-18
app/assets/javascripts/merge_request_tabs.js.es6
app/assets/javascripts/merge_request_tabs.js.es6
+3
-2
app/assets/javascripts/todos.js.es6
app/assets/javascripts/todos.js.es6
+7
-10
changelogs/unreleased/27922-cmd-click-todo-doesn-t-work.yml
changelogs/unreleased/27922-cmd-click-todo-doesn-t-work.yml
+5
-0
spec/javascripts/merge_request_tabs_spec.js
spec/javascripts/merge_request_tabs_spec.js
+34
-6
spec/javascripts/todos_spec.js
spec/javascripts/todos_spec.js
+63
-0
No files found.
app/assets/javascripts/merge_request_tabs.js.es6
View file @
25fec0f8
...
...
@@ -102,9 +102,10 @@ require('./flash');
}
clickTab(e) {
if (e.
t
arget && gl.utils.isMetaClick(e)) {
const targetLink = e.
t
arget.getAttribute('href');
if (e.
currentT
arget && gl.utils.isMetaClick(e)) {
const targetLink = e.
currentT
arget.getAttribute('href');
e.stopImmediatePropagation();
e.preventDefault();
window.open(targetLink, '_blank');
}
}
...
...
app/assets/javascripts/todos.js.es6
View file @
25fec0f8
...
...
@@ -147,24 +147,21 @@
goToTodoUrl(e) {
const todoLink = this.dataset.url;
let targetLink = e.target.getAttribute('href');
if (e.target.tagName === 'IMG') { // See if clicked target was Avatar
targetLink = e.target.parentElement.getAttribute('href'); // Parent of Avatar is link
}
if (!todoLink) {
return;
}
if (gl.utils.isMetaClick(e)) {
const windowTarget = '_blank';
const selected = e.target;
e.preventDefault();
// Meta-Click on username leads to different URL than todoLink.
// Turbolinks can resolve that URL, but window.open requires URL manually.
if (targetLink !== todoLink) {
return window.open(
targetLink, '_blank'
);
if (selected.tagName === 'IMG') {
const avatarUrl = selected.parentElement.getAttribute('href');
return window.open(
avatarUrl, windowTarget
);
} else {
return window.open(todoLink,
'_blank'
);
return window.open(todoLink,
windowTarget
);
}
} else {
return gl.utils.visitUrl(todoLink);
...
...
changelogs/unreleased/27922-cmd-click-todo-doesn-t-work.yml
0 → 100644
View file @
25fec0f8
---
title
:
Fix regression where cmd-click stopped working for todos and merge request
tabs
merge_request
:
author
:
spec/javascripts/merge_request_tabs_spec.js
View file @
25fec0f8
...
...
@@ -62,19 +62,47 @@ require('vendor/jquery.scrollTo');
});
});
describe
(
'
#opensInNewTab
'
,
function
()
{
var
commitsLink
;
var
tabUrl
;
var
windowTarget
=
'
_blank
'
;
beforeEach
(
function
()
{
commitsLink
=
'
.commits-tab li a
'
;
tabUrl
=
$
(
commitsLink
).
attr
(
'
href
'
);
loadFixtures
(
'
merge_requests/merge_request_with_task_list.html.raw
'
);
tabUrl
=
$
(
'
.commits-tab a
'
).
attr
(
'
href
'
);
spyOn
(
$
.
fn
,
'
attr
'
).
and
.
returnValue
(
tabUrl
);
});
describe
(
'
meta click
'
,
()
=>
{
beforeEach
(
function
()
{
spyOn
(
gl
.
utils
,
'
isMetaClick
'
).
and
.
returnValue
(
true
);
});
it
(
'
opens page when commits link is clicked
'
,
function
()
{
spyOn
(
window
,
'
open
'
).
and
.
callFake
(
function
(
url
,
name
)
{
expect
(
url
).
toEqual
(
tabUrl
);
expect
(
name
).
toEqual
(
windowTarget
);
});
this
.
class
.
bindEvents
();
document
.
querySelector
(
'
.merge-request-tabs .commits-tab a
'
).
click
();
});
it
(
'
opens page when commits badge is clicked
'
,
function
()
{
spyOn
(
window
,
'
open
'
).
and
.
callFake
(
function
(
url
,
name
)
{
expect
(
url
).
toEqual
(
tabUrl
);
expect
(
name
).
toEqual
(
windowTarget
);
});
this
.
class
.
bindEvents
();
document
.
querySelector
(
'
.merge-request-tabs .commits-tab a .badge
'
).
click
();
});
});
it
(
'
opens page tab in a new browser tab with Ctrl+Click - Windows/Linux
'
,
function
()
{
spyOn
(
window
,
'
open
'
).
and
.
callFake
(
function
(
url
,
name
)
{
expect
(
url
).
toEqual
(
tabUrl
);
expect
(
name
).
toEqual
(
'
_blank
'
);
expect
(
name
).
toEqual
(
windowTarget
);
});
this
.
class
.
clickTab
({
...
...
@@ -87,7 +115,7 @@ require('vendor/jquery.scrollTo');
it
(
'
opens page tab in a new browser tab with Cmd+Click - Mac
'
,
function
()
{
spyOn
(
window
,
'
open
'
).
and
.
callFake
(
function
(
url
,
name
)
{
expect
(
url
).
toEqual
(
tabUrl
);
expect
(
name
).
toEqual
(
'
_blank
'
);
expect
(
name
).
toEqual
(
windowTarget
);
});
this
.
class
.
clickTab
({
...
...
@@ -100,7 +128,7 @@ require('vendor/jquery.scrollTo');
it
(
'
opens page tab in a new browser tab with Middle-click - Mac/PC
'
,
function
()
{
spyOn
(
window
,
'
open
'
).
and
.
callFake
(
function
(
url
,
name
)
{
expect
(
url
).
toEqual
(
tabUrl
);
expect
(
name
).
toEqual
(
'
_blank
'
);
expect
(
name
).
toEqual
(
windowTarget
);
});
this
.
class
.
clickTab
({
...
...
spec/javascripts/todos_spec.js
0 → 100644
View file @
25fec0f8
require
(
'
~/todos
'
);
require
(
'
~/lib/utils/common_utils
'
);
describe
(
'
Todos
'
,
()
=>
{
preloadFixtures
(
'
todos/todos.html.raw
'
);
let
todoItem
;
beforeEach
(()
=>
{
loadFixtures
(
'
todos/todos.html.raw
'
);
todoItem
=
document
.
querySelector
(
'
.todos-list .todo
'
);
return
new
gl
.
Todos
();
});
describe
(
'
goToTodoUrl
'
,
()
=>
{
it
(
'
opens the todo url
'
,
(
done
)
=>
{
const
todoLink
=
todoItem
.
dataset
.
url
;
spyOn
(
gl
.
utils
,
'
visitUrl
'
).
and
.
callFake
((
url
)
=>
{
expect
(
url
).
toEqual
(
todoLink
);
done
();
});
todoItem
.
click
();
});
describe
(
'
meta click
'
,
()
=>
{
let
visitUrlSpy
;
beforeEach
(()
=>
{
spyOn
(
gl
.
utils
,
'
isMetaClick
'
).
and
.
returnValue
(
true
);
visitUrlSpy
=
spyOn
(
gl
.
utils
,
'
visitUrl
'
).
and
.
callFake
(()
=>
{});
});
it
(
'
opens the todo url in another tab
'
,
(
done
)
=>
{
const
todoLink
=
todoItem
.
dataset
.
url
;
spyOn
(
window
,
'
open
'
).
and
.
callFake
((
url
,
target
)
=>
{
expect
(
todoLink
).
toEqual
(
url
);
expect
(
target
).
toEqual
(
'
_blank
'
);
done
();
});
todoItem
.
click
();
expect
(
visitUrlSpy
).
not
.
toHaveBeenCalled
();
});
it
(
'
opens the avatar
\'
s url in another tab when the avatar is clicked
'
,
(
done
)
=>
{
const
avatarImage
=
todoItem
.
querySelector
(
'
img
'
);
const
avatarUrl
=
avatarImage
.
parentElement
.
getAttribute
(
'
href
'
);
spyOn
(
window
,
'
open
'
).
and
.
callFake
((
url
,
target
)
=>
{
expect
(
avatarUrl
).
toEqual
(
url
);
expect
(
target
).
toEqual
(
'
_blank
'
);
done
();
});
avatarImage
.
click
();
expect
(
visitUrlSpy
).
not
.
toHaveBeenCalled
();
});
});
});
});
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