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
266d51b6
Commit
266d51b6
authored
Dec 15, 2021
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefetches Issue, MR and ToDo Lists
parent
92b65146
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
4 deletions
+47
-4
app/assets/javascripts/lib/utils/navigation_utility.js
app/assets/javascripts/lib/utils/navigation_utility.js
+41
-0
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+2
-0
app/views/layouts/header/_default.html.haml
app/views/layouts/header/_default.html.haml
+4
-4
No files found.
app/assets/javascripts/lib/utils/navigation_utility.js
View file @
266d51b6
...
...
@@ -13,3 +13,44 @@ export default function findAndFollowLink(selector) {
visitUrl
(
link
);
}
}
export
function
prefetchDocument
(
url
)
{
const
newPrefetchLink
=
document
.
createElement
(
"
link
"
);
newPrefetchLink
.
rel
=
"
prefetch
"
;
newPrefetchLink
.
href
=
url
;
newPrefetchLink
.
as
=
"
document
"
;
document
.
head
.
appendChild
(
newPrefetchLink
);
}
export
function
initPrefetchLinks
(
selector
)
{
document
.
querySelectorAll
(
selector
)
.
forEach
((
el
)
=>
{
let
mouseOverTimer
;
const
mouseOutHandler
=
()
=>
{
if
(
mouseOverTimer
)
{
clearTimeout
(
mouseOverTimer
);
mouseOverTimer
=
undefined
;
}
};
const
mouseOverHandler
=
()
=>
{
el
.
addEventListener
(
'
mouseout
'
,
mouseOutHandler
,
{
passive
:
true
});
mouseOverTimer
=
setTimeout
(()
=>
{
if
(
el
.
href
)
prefetchDocument
(
el
.
href
);
// Only execute once
el
.
removeEventListener
(
'
mouseover
'
,
mouseOverHandler
,
true
);
el
.
removeEventListener
(
'
mouseout
'
,
mouseOutHandler
);
mouseOverTimer
=
undefined
;
},
100
);
};
el
.
addEventListener
(
'
mouseover
'
,
mouseOverHandler
,
{
capture
:
true
,
passive
:
true
,
});
});
}
app/assets/javascripts/main.js
View file @
266d51b6
...
...
@@ -14,6 +14,7 @@ import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import
{
initRails
}
from
'
~/lib/utils/rails_ujs
'
;
import
*
as
popovers
from
'
~/popovers
'
;
import
*
as
tooltips
from
'
~/tooltips
'
;
import
{
initPrefetchLinks
}
from
'
~/lib/utils/navigation_utility
'
;
import
initAlertHandler
from
'
./alert_handler
'
;
import
{
addDismissFlashClickListener
}
from
'
./flash
'
;
import
initTodoToggle
from
'
./header
'
;
...
...
@@ -90,6 +91,7 @@ function deferredInitialisation() {
initTopNav
();
initBreadcrumbs
();
initTodoToggle
();
initPrefetchLinks
(
'
.js-prefetch-document
'
);
initLogoAnimation
();
initServicePingConsent
();
initUserPopovers
();
...
...
app/views/layouts/header/_default.html.haml
View file @
266d51b6
...
...
@@ -46,7 +46,7 @@
=
sprite_icon
(
search_menu_item
.
fetch
(
:icon
))
-
if
header_link?
(
:issues
)
=
nav_link
(
path:
'dashboard#issues'
,
html_options:
{
class:
"user-counter"
})
do
=
link_to
assigned_issues_dashboard_path
,
title:
_
(
'Issues'
),
class:
'dashboard-shortcuts-issues'
,
aria:
{
label:
_
(
'Issues'
)
},
=
link_to
assigned_issues_dashboard_path
,
title:
_
(
'Issues'
),
class:
'dashboard-shortcuts-issues
js-prefetch-document
'
,
aria:
{
label:
_
(
'Issues'
)
},
data:
{
qa_selector:
'issues_shortcut_button'
,
toggle:
'tooltip'
,
placement:
'bottom'
,
track_label:
'main_navigation'
,
track_action:
'click_issues_link'
,
...
...
@@ -75,18 +75,18 @@
%li
.dropdown-header
=
_
(
'Merge requests'
)
%li
=
link_to
assigned_mrs_dashboard_path
,
class:
'gl-display-flex! gl-align-items-center'
do
=
link_to
assigned_mrs_dashboard_path
,
class:
'gl-display-flex! gl-align-items-center
js-prefetch-document
'
do
=
_
(
'Assigned to you'
)
%span
.badge.gl-badge.badge-pill.badge-muted.merge-request-badge.gl-ml-auto.js-assigned-mr-count
{
class:
""
}
=
user_merge_requests_counts
[
:assigned
]
%li
=
link_to
reviewer_mrs_dashboard_path
,
class:
'gl-display-flex! gl-align-items-center'
do
=
link_to
reviewer_mrs_dashboard_path
,
class:
'gl-display-flex! gl-align-items-center
js-prefetch-document
'
do
=
_
(
'Review requests for you'
)
%span
.badge.gl-badge.badge-pill.badge-muted.merge-request-badge.gl-ml-auto.js-reviewer-mr-count
{
class:
""
}
=
user_merge_requests_counts
[
:review_requested
]
-
if
header_link?
(
:todos
)
=
nav_link
(
controller:
'dashboard/todos'
,
html_options:
{
class:
"user-counter"
})
do
=
link_to
dashboard_todos_path
,
title:
_
(
'To-Do List'
),
aria:
{
label:
_
(
'To-Do List'
)
},
class:
'shortcuts-todos'
,
=
link_to
dashboard_todos_path
,
title:
_
(
'To-Do List'
),
aria:
{
label:
_
(
'To-Do List'
)
},
class:
'shortcuts-todos
js-prefetch-document
'
,
data:
{
qa_selector:
'todos_shortcut_button'
,
toggle:
'tooltip'
,
placement:
'bottom'
,
track_label:
'main_navigation'
,
track_action:
'click_to_do_link'
,
...
...
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