Welcome to mirror list, hosted at ThFree Co, Russian Federation.

shortcuts.js « behaviors « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7352be0dbd58513436e0dd206db430a2d990ac0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
  if (page && !pagesWithCustomShortcuts.includes(page)) {
    import(/* webpackChunkName: 'shortcutsBundle' */ './shortcuts/shortcuts')
      .then(({ default: Shortcuts }) => new Shortcuts())
      .catch(() => {});
  }
  return false;
}