debian-mirror-gitlab/app/assets/javascripts/behaviors/shortcuts.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-12-05 23:21:45 +05:30
export default function initPageShortcuts() {
const { page } = document.body.dataset;
const pagesWithCustomShortcuts = [
'projects:activity',
'projects:artifacts:browse',
'projects:artifacts:file',
'projects:blame:show',
'projects:blob:show',
'projects:commit:show',
'projects:commits:show',
'projects:find_file:show',
'projects:issues:edit',
'projects:issues:index',
'projects:issues:new',
'projects:issues:show',
'projects:merge_requests:creations:diffs',
'projects:merge_requests:creations:new',
'projects:merge_requests:edit',
'projects:merge_requests:index',
'projects:merge_requests:show',
'projects:network:show',
'projects:show',
'projects:tree:show',
'groups:show',
];
// the pages above have their own shortcuts sub-classes instantiated elsewhere
// TODO: replace this whitelist with something more automated/maintainable
2023-05-27 22:25:52 +05:30
// https://gitlab.com/gitlab-org/gitlab/-/issues/392845
2018-12-05 23:21:45 +05:30
if (page && !pagesWithCustomShortcuts.includes(page)) {
2020-11-24 15:15:51 +05:30
import(/* webpackChunkName: 'shortcutsBundle' */ './shortcuts/shortcuts')
2023-05-27 22:25:52 +05:30
.then(({ default: Shortcuts }) => new Shortcuts())
2020-11-24 15:15:51 +05:30
.catch(() => {});
2018-12-05 23:21:45 +05:30
}
return false;
}