dispatcher.js 21.0 KB
Newer Older
1
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, wrap-iife, no-shadow, consistent-return, one-var, one-var-declaration-per-line, camelcase, default-case, no-new, quotes, no-duplicate-case, no-case-declarations, no-fallthrough, max-len */
P
Phil Hughes 已提交
2
import MergeRequest from './merge_request';
3
import Flash from './flash';
4
import GfmAutoComplete from './gfm_auto_complete';
5
import ZenMode from './zen_mode';
P
Phil Hughes 已提交
6 7
import initNotes from './init_notes';
import initIssuableSidebar from './init_issuable_sidebar';
C
Clement Ho 已提交
8
import { convertPermissionToBoolean } from './lib/utils/common_utils';
9
import GlFieldErrors from './gl_field_errors';
10 11
import Shortcuts from './shortcuts';
import ShortcutsIssuable from './shortcuts_issuable';
12
import Diff from './diff';
F
Filipa Lacerda 已提交
13
import SearchAutocomplete from './search_autocomplete';
14

F
Fatih Acet 已提交
15 16 17 18 19 20
(function() {
  var Dispatcher;

  Dispatcher = (function() {
    function Dispatcher() {
      this.initSearch();
21
      this.initFieldErrors();
F
Fatih Acet 已提交
22 23 24 25
      this.initPageScripts();
    }

    Dispatcher.prototype.initPageScripts = function() {
26
      var path, shortcut_handler;
27
      const page = $('body').attr('data-page');
F
Fatih Acet 已提交
28 29 30
      if (!page) {
        return false;
      }
31

32
      const fail = () => Flash('Error loading dynamic module');
33
      const callDefault = m => m.default();
34

F
Fatih Acet 已提交
35 36
      path = page.split(':');
      shortcut_handler = null;
37

F
Filipa Lacerda 已提交
38
      $('.js-gfm-input:not(.js-vue-textarea)').each((i, el) => {
39
        const gfm = new GfmAutoComplete(gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources);
40
        const enableGFM = convertPermissionToBoolean(el.dataset.supportsAutocomplete);
41 42 43 44 45 46 47 48 49
        gfm.setup($(el), {
          emojis: true,
          members: enableGFM,
          issues: enableGFM,
          milestones: enableGFM,
          mergeRequests: enableGFM,
          labels: enableGFM,
        });
      });
50

F
Fatih Acet 已提交
51
      switch (page) {
52
        case 'sessions:new':
C
Clement Ho 已提交
53 54 55
          import('./pages/sessions/new')
            .then(callDefault)
            .catch(fail);
56
          break;
57
        case 'projects:boards:show':
58
        case 'projects:boards:index':
59 60 61 62
          import('./pages/projects/boards/index')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
63
          break;
64 65 66 67 68
        case 'projects:environments:metrics':
          import('./pages/projects/environments/metrics')
            .then(callDefault)
            .catch(fail);
          break;
69
        case 'projects:merge_requests:index':
70 71 72 73
          import('./pages/projects/merge_requests/index')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
74
          break;
S
Simon Knox 已提交
75 76 77 78 79 80
        case 'projects:issues:index':
          import('./pages/projects/issues/index')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
          break;
F
Fatih Acet 已提交
81
        case 'projects:issues:show':
S
Simon Knox 已提交
82 83 84 85
          import('./pages/projects/issues/show')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
86
          break;
P
Phil Hughes 已提交
87
        case 'dashboard:milestones:index':
88 89 90
          import('./pages/dashboard/milestones/index')
            .then(callDefault)
            .catch(fail);
P
Phil Hughes 已提交
91
          break;
F
Fatih Acet 已提交
92
        case 'projects:milestones:show':
93 94 95 96
          import('./pages/projects/milestones/show')
            .then(callDefault)
            .catch(fail);
          break;
F
Fatih Acet 已提交
97
        case 'groups:milestones:show':
98 99 100
          import('./pages/groups/milestones/show')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
101
          break;
102 103 104 105 106
        case 'dashboard:milestones:show':
          import('./pages/dashboard/milestones/show')
            .then(callDefault)
            .catch(fail);
          break;
107
        case 'dashboard:issues':
C
Clement Ho 已提交
108 109 110
          import('./pages/dashboard/issues')
            .then(callDefault)
            .catch(fail);
C
Clement Ho 已提交
111
          break;
112
        case 'dashboard:merge_requests':
113 114 115
          import('./pages/dashboard/merge_requests')
            .then(callDefault)
            .catch(fail);
116
          break;
117
        case 'groups:issues':
S
Simon Knox 已提交
118 119 120 121
          import('./pages/groups/issues')
            .then(callDefault)
            .catch(fail);
          break;
122
        case 'groups:merge_requests':
S
Simon Knox 已提交
123 124 125
          import('./pages/groups/merge_requests')
            .then(callDefault)
            .catch(fail);
126
          break;
F
Fatih Acet 已提交
127
        case 'dashboard:todos:index':
C
Clement Ho 已提交
128 129 130
          import('./pages/dashboard/todos/index')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
131
          break;
132 133 134 135 136
        case 'admin:jobs:index':
          import('./pages/admin/jobs/index')
            .then(callDefault)
            .catch(fail);
          break;
137 138
        case 'dashboard:projects:index':
        case 'dashboard:projects:starred':
C
Clement Ho 已提交
139 140 141
          import('./pages/dashboard/projects')
            .then(callDefault)
            .catch(fail);
142
          break;
143 144 145
        case 'explore:projects:index':
        case 'explore:projects:trending':
        case 'explore:projects:starred':
146
          import('./pages/explore/projects')
J
Jacob Schatz 已提交
147
            .then(callDefault)
J
Jacob Schatz 已提交
148 149
            .catch(fail);
          break;
F
Filipa Lacerda 已提交
150
        case 'explore:groups:index':
151
          import('./pages/explore/groups')
J
Jacob Schatz 已提交
152
            .then(callDefault)
J
Jacob Schatz 已提交
153
            .catch(fail);
F
Filipa Lacerda 已提交
154
          break;
F
Fatih Acet 已提交
155
        case 'projects:milestones:new':
156 157 158 159 160
        case 'projects:milestones:create':
          import('./pages/projects/milestones/new')
            .then(callDefault)
            .catch(fail);
          break;
F
Fatih Acet 已提交
161
        case 'projects:milestones:edit':
162
        case 'projects:milestones:update':
163 164 165
          import('./pages/projects/milestones/edit')
            .then(callDefault)
            .catch(fail);
166
          break;
167
        case 'groups:milestones:new':
168 169 170 171 172
        case 'groups:milestones:create':
          import('./pages/groups/milestones/new')
            .then(callDefault)
            .catch(fail);
          break;
173 174
        case 'groups:milestones:edit':
        case 'groups:milestones:update':
175 176 177
          import('./pages/groups/milestones/edit')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
178 179
          break;
        case 'projects:compare:show':
180 181 182
          import('./pages/projects/compare/show')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
183
          break;
184
        case 'projects:branches:new':
185 186 187 188
          import('./pages/projects/branches/new')
            .then(callDefault)
            .catch(fail);
          break;
189
        case 'projects:branches:create':
190 191 192
          import('./pages/projects/branches/new')
            .then(callDefault)
            .catch(fail);
193
          break;
194
        case 'projects:branches:index':
195 196 197
          import('./pages/projects/branches/index')
            .then(callDefault)
            .catch(fail);
198
          break;
F
Fatih Acet 已提交
199
        case 'projects:issues:new':
S
Simon Knox 已提交
200 201 202 203 204
          import('./pages/projects/issues/new')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
          break;
F
Fatih Acet 已提交
205
        case 'projects:issues:edit':
S
Simon Knox 已提交
206 207 208 209
          import('./pages/projects/issues/edit')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
210
          break;
D
Douwe Maan 已提交
211
        case 'projects:merge_requests:creations:new':
212 213 214
          import('./pages/projects/merge_requests/creations/new')
            .then(callDefault)
            .catch(fail);
D
Douwe Maan 已提交
215
        case 'projects:merge_requests:creations:diffs':
216 217 218 219 220
          import('./pages/projects/merge_requests/creations/diffs')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
          break;
F
Fatih Acet 已提交
221
        case 'projects:merge_requests:edit':
222 223 224 225
          import('./pages/projects/merge_requests/edit')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
226 227
          break;
        case 'projects:tags:new':
228 229 230
          import('./pages/projects/tags/new')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
231
          break;
232
        case 'projects:snippets:show':
J
Jacob Schatz 已提交
233 234 235
          import('./pages/projects/snippets/show')
            .then(callDefault)
            .catch(fail);
236
          break;
237 238
        case 'projects:snippets:new':
        case 'projects:snippets:create':
C
Clement Ho 已提交
239
          import('./pages/projects/snippets/new')
J
Jacob Schatz 已提交
240 241 242
            .then(callDefault)
            .catch(fail);
          break;
C
Clement Ho 已提交
243
        case 'projects:snippets:edit':
244
        case 'projects:snippets:update':
C
Clement Ho 已提交
245
          import('./pages/projects/snippets/edit')
J
Jacob Schatz 已提交
246 247
            .then(callDefault)
            .catch(fail);
248
          break;
249
        case 'snippets:new':
250 251 252 253
          import('./pages/snippets/new')
            .then(callDefault)
            .catch(fail);
          break;
254
        case 'snippets:edit':
255 256 257 258
          import('./pages/snippets/edit')
            .then(callDefault)
            .catch(fail);
          break;
259
        case 'snippets:create':
C
Clement Ho 已提交
260
          import('./pages/snippets/new')
261 262 263
            .then(callDefault)
            .catch(fail);
          break;
264
        case 'snippets:update':
C
Clement Ho 已提交
265
          import('./pages/snippets/edit')
266 267
            .then(callDefault)
            .catch(fail);
268
          break;
F
Fatih Acet 已提交
269
        case 'projects:releases:edit':
C
Clement Ho 已提交
270
          import('./pages/projects/releases/edit')
J
Jacob Schatz 已提交
271 272
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
273 274
          break;
        case 'projects:merge_requests:show':
275
          new Diff();
F
Fatih Acet 已提交
276
          new ZenMode();
277

278 279
          initIssuableSidebar();
          initNotes();
280

281 282 283 284
          const mrShowNode = document.querySelector('.merge-request');
          window.mergeRequest = new MergeRequest({
            action: mrShowNode.dataset.mrAction,
          });
285
          shortcut_handler = new ShortcutsIssuable(true);
F
Fatih Acet 已提交
286 287
          break;
        case 'dashboard:activity':
C
Clement Ho 已提交
288 289 290
          import('./pages/dashboard/activity')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
291 292
          break;
        case 'projects:commit:show':
293 294 295 296
          import('./pages/projects/commit/show')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
297
          break;
298
        case 'projects:commit:pipelines':
299 300 301
          import('./pages/projects/commit/pipelines')
            .then(callDefault)
            .catch(fail);
302
          break;
303
        case 'projects:activity':
304
          import('./pages/projects/activity')
305 306
            .then(callDefault)
            .catch(fail);
307
          shortcut_handler = true;
308
          break;
309
        case 'projects:commits:show':
310 311 312 313
          import('./pages/projects/commits/show')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
314 315
          break;
        case 'projects:show':
316 317 318
          import('./pages/projects/show')
            .then(callDefault)
            .catch(fail);
C
Clement Ho 已提交
319
          shortcut_handler = true;
F
Fatih Acet 已提交
320
          break;
321
        case 'projects:edit':
S
Simon Knox 已提交
322 323 324
          import('./pages/projects/edit')
            .then(callDefault)
            .catch(fail);
325
          break;
326
        case 'projects:imports:show':
S
Simon Knox 已提交
327 328 329
          import('./pages/projects/imports/show')
            .then(callDefault)
            .catch(fail);
330
          break;
331
        case 'projects:pipelines:new':
332
        case 'projects:pipelines:create':
333 334 335
          import('./pages/projects/pipelines/new')
            .then(callDefault)
            .catch(fail);
336
          break;
F
Filipa Lacerda 已提交
337
        case 'projects:pipelines:builds':
338
        case 'projects:pipelines:failures':
L
Luke Bennett 已提交
339
        case 'projects:pipelines:show':
340 341 342
          import('./pages/projects/pipelines/builds')
            .then(callDefault)
            .catch(fail);
L
Luke Bennett 已提交
343
          break;
F
Fatih Acet 已提交
344
        case 'groups:activity':
S
Simon Knox 已提交
345 346 347
          import('./pages/groups/activity')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
348 349
          break;
        case 'groups:show':
S
Simon Knox 已提交
350 351 352 353
          import('./pages/groups/show')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
354 355
          break;
        case 'groups:group_members:index':
S
Simon Knox 已提交
356 357 358
          import('./pages/groups/group_members/index')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
359
          break;
360
        case 'projects:project_members:index':
361 362 363
          import('./pages/projects/project_members/')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
364
          break;
365
        case 'groups:create':
S
Simon Knox 已提交
366 367 368 369 370 371 372 373 374
        case 'groups:new':
          import('./pages/groups/new')
            .then(callDefault)
            .catch(fail);
          break;
        case 'groups:edit':
          import('./pages/groups/edit')
            .then(callDefault)
            .catch(fail);
375
          break;
P
Phil Hughes 已提交
376 377
        case 'admin:groups:create':
        case 'admin:groups:new':
P
Phil Hughes 已提交
378 379 380
          import('./pages/admin/groups/new')
            .then(callDefault)
            .catch(fail);
P
Phil Hughes 已提交
381
          break;
F
Fatih Acet 已提交
382
        case 'admin:groups:edit':
P
Phil Hughes 已提交
383 384 385
          import('./pages/admin/groups/edit')
            .then(callDefault)
            .catch(fail);
P
Phil Hughes 已提交
386
          break;
387
        case 'projects:tree:show':
388
          import('./pages/projects/tree/show')
389
            .then(callDefault)
390
            .catch(fail);
391
          shortcut_handler = true;
392
          break;
F
Fatih Acet 已提交
393
        case 'projects:find_file:show':
S
Simon Knox 已提交
394 395 396
          import('./pages/projects/find_file/show')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
397 398
          shortcut_handler = true;
          break;
399
        case 'projects:blob:show':
400 401 402 403
          import('./pages/projects/blob/show')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
404
          break;
F
Fatih Acet 已提交
405
        case 'projects:blame:show':
406 407 408 409
          import('./pages/projects/blame/show')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
410
          break;
411
        case 'groups:labels:new':
S
Simon Knox 已提交
412 413 414 415
          import('./pages/groups/labels/new')
            .then(callDefault)
            .catch(fail);
          break;
416
        case 'groups:labels:edit':
S
Simon Knox 已提交
417 418 419
          import('./pages/groups/labels/edit')
            .then(callDefault)
            .catch(fail);
C
Clement Ho 已提交
420
          break;
F
Fatih Acet 已提交
421
        case 'projects:labels:new':
J
Jacob Schatz 已提交
422 423 424 425
          import('./pages/projects/labels/new')
            .then(callDefault)
            .catch(fail);
          break;
F
Fatih Acet 已提交
426
        case 'projects:labels:edit':
C
Clement Ho 已提交
427
          import('./pages/projects/labels/edit')
J
Jacob Schatz 已提交
428 429
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
430
          break;
S
Simon Knox 已提交
431 432 433 434 435
        case 'groups:labels:index':
          import('./pages/groups/labels/index')
            .then(callDefault)
            .catch(fail);
          break;
F
Fatih Acet 已提交
436
        case 'projects:labels:index':
J
Jacob Schatz 已提交
437 438 439 440
          import('./pages/projects/labels/index')
            .then(callDefault)
            .catch(fail);
          break;
F
Fatih Acet 已提交
441
        case 'projects:network:show':
442 443
          // Ensure we don't create a particular shortcut handler here. This is
          // already created, where the network graph is created.
F
Fatih Acet 已提交
444 445 446
          shortcut_handler = true;
          break;
        case 'projects:forks:new':
S
Simon Knox 已提交
447
          import('./pages/projects/forks/new')
J
Jacob Schatz 已提交
448 449
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
450 451
          break;
        case 'projects:artifacts:browse':
452
          import('./pages/projects/artifacts/browse')
453 454
            .then(callDefault)
            .catch(fail);
455
          shortcut_handler = true;
F
Fatih Acet 已提交
456
          break;
457
        case 'projects:artifacts:file':
458
          import('./pages/projects/artifacts/file')
459 460
            .then(callDefault)
            .catch(fail);
461
          shortcut_handler = true;
462
          break;
463
        case 'help:index':
464 465 466
          import('./pages/help')
            .then(callDefault)
            .catch(fail);
467
          break;
F
Fatih Acet 已提交
468
        case 'search:show':
C
Clement Ho 已提交
469 470 471
          import('./pages/search/show')
            .then(callDefault)
            .catch(fail);
472
          break;
D
Douwe Maan 已提交
473
        case 'projects:settings:repository:show':
474 475 476
          import('./pages/projects/settings/repository/show')
            .then(callDefault)
            .catch(fail);
477
          break;
D
Douwe Maan 已提交
478
        case 'projects:settings:ci_cd:show':
479 480 481 482
          import('./pages/projects/settings/ci_cd/show')
            .then(callDefault)
            .catch(fail);
          break;
S
Shinya Maeda 已提交
483
        case 'groups:settings:ci_cd:show':
S
Simon Knox 已提交
484 485 486
          import('./pages/groups/settings/ci_cd/show')
            .then(callDefault)
            .catch(fail);
S
Stan Hu 已提交
487
          break;
488 489
        case 'ci:lints:create':
        case 'ci:lints:show':
C
Clement Ho 已提交
490 491 492
          import('./pages/ci/lints')
            .then(callDefault)
            .catch(fail);
493
          break;
494
        case 'users:show':
C
Clement Ho 已提交
495 496 497
          import('./pages/users/show')
            .then(callDefault)
            .catch(fail);
498
          break;
499
        case 'admin:conversational_development_index:show':
C
Clement Ho 已提交
500 501 502
          import('./pages/admin/conversational_development_index/show')
            .then(callDefault)
            .catch(fail);
503
          break;
D
Douwe Maan 已提交
504
        case 'snippets:show':
C
Clement Ho 已提交
505 506 507
          import('./pages/snippets/show')
            .then(callDefault)
            .catch(fail);
D
Douwe Maan 已提交
508
          break;
509
        case 'import:fogbugz:new_user_map':
C
Clement Ho 已提交
510 511 512
          import('./pages/import/fogbugz/new_user_map')
            .then(callDefault)
            .catch(fail);
513
          break;
514
        case 'profiles:personal_access_tokens:index':
515 516 517 518
          import('./pages/profiles/personal_access_tokens')
            .then(callDefault)
            .catch(fail);
          break;
519
        case 'admin:impersonation_tokens:index':
P
Phil Hughes 已提交
520 521 522
          import('./pages/admin/impersonation_tokens')
            .then(callDefault)
            .catch(fail);
P
Phil Hughes 已提交
523
          break;
F
Filipa Lacerda 已提交
524
        case 'projects:clusters:show':
525 526
        case 'projects:clusters:update':
        case 'projects:clusters:destroy':
527 528 529
          import('./pages/projects/clusters/show')
            .then(callDefault)
            .catch(fail);
530 531
          break;
        case 'projects:clusters:index':
532 533 534
          import('./pages/projects/clusters/index')
            .then(callDefault)
            .catch(fail);
F
Filipa Lacerda 已提交
535
          break;
536 537 538 539 540
        case 'dashboard:groups:index':
          import('./pages/dashboard/groups/index')
            .then(callDefault)
            .catch(fail);
          break;
F
Fatih Acet 已提交
541
      }
542
      switch (path[0]) {
543
        case 'sessions':
544 545 546 547
          import('./pages/sessions')
            .then(callDefault)
            .catch(fail);
          break;
548
        case 'omniauth_callbacks':
549 550 551 552
          import('./pages/omniauth_callbacks')
            .then(callDefault)
            .catch(fail);
          break;
F
Fatih Acet 已提交
553
        case 'admin':
P
Phil Hughes 已提交
554 555 556
          import('./pages/admin')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
557
          switch (path[1]) {
M
Mike Greiling 已提交
558
            case 'broadcast_messages':
P
Phil Hughes 已提交
559 560 561
              import('./pages/admin/broadcast_messages')
                .then(callDefault)
                .catch(fail);
M
Mike Greiling 已提交
562
              break;
S
Sean McGivern 已提交
563
            case 'cohorts':
P
Phil Hughes 已提交
564 565 566
              import('./pages/admin/cohorts')
                .then(callDefault)
                .catch(fail);
567
              break;
F
Fatih Acet 已提交
568
            case 'groups':
P
Phil Hughes 已提交
569 570
              switch (path[2]) {
                case 'show':
P
Phil Hughes 已提交
571 572 573
                  import('./pages/admin/groups/show')
                    .then(callDefault)
                    .catch(fail);
P
Phil Hughes 已提交
574 575
                  break;
              }
F
Fatih Acet 已提交
576 577
              break;
            case 'projects':
P
Phil Hughes 已提交
578 579 580
              import('./pages/admin/projects')
                .then(callDefault)
                .catch(fail);
581 582
              break;
            case 'labels':
583
              switch (path[2]) {
584
                case 'new':
P
Phil Hughes 已提交
585 586 587
                  import('./pages/admin/labels/new')
                    .then(callDefault)
                    .catch(fail);
P
Phil Hughes 已提交
588
                  break;
589
                case 'edit':
P
Phil Hughes 已提交
590 591 592
                  import('./pages/admin/labels/edit')
                    .then(callDefault)
                    .catch(fail);
P
Phil Hughes 已提交
593
                  break;
594
              }
595
            case 'abuse_reports':
P
Phil Hughes 已提交
596 597 598
              import('./pages/admin/abuse_reports')
                .then(callDefault)
                .catch(fail);
599
              break;
F
Fatih Acet 已提交
600 601 602
          }
          break;
        case 'profiles':
603 604 605
          import('./pages/profiles/index/')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
606 607
          break;
        case 'projects':
608 609 610 611
          import('./pages/projects')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
612 613
          switch (path[1]) {
            case 'compare':
614 615 616
              import('./pages/projects/compare')
                .then(callDefault)
                .catch(fail);
F
Fatih Acet 已提交
617
              break;
618 619 620
            case 'create':
            case 'new':
              import('./pages/projects/new')
J
Jacob Schatz 已提交
621 622
                .then(callDefault)
                .catch(fail);
F
Fatih Acet 已提交
623 624
              break;
            case 'wikis':
625 626 627 628
              import('./pages/projects/wikis')
                .then(callDefault)
                .catch(fail);
              shortcut_handler = true;
F
Fatih Acet 已提交
629 630
              break;
          }
631
          break;
F
Fatih Acet 已提交
632
      }
633
      // If we haven't installed a custom shortcut handler, install the default one
F
Fatih Acet 已提交
634
      if (!shortcut_handler) {
635
        new Shortcuts();
F
Fatih Acet 已提交
636
      }
637 638

      if (document.querySelector('#peek')) {
639 640 641
        import('./performance_bar')
          .then(m => new m.default({ container: '#peek' })) // eslint-disable-line new-cap
          .catch(fail);
642
      }
F
Fatih Acet 已提交
643 644 645
    };

    Dispatcher.prototype.initSearch = function() {
646
      // Only when search form is present
F
Fatih Acet 已提交
647
      if ($('.search').length) {
F
Filipa Lacerda 已提交
648
        return new SearchAutocomplete();
F
Fatih Acet 已提交
649 650 651
      }
    };

652
    Dispatcher.prototype.initFieldErrors = function() {
653
      $('.gl-show-field-errors').each((i, form) => {
654
        new GlFieldErrors(form);
655
      });
656 657
    };

F
Fatih Acet 已提交
658 659
    return Dispatcher;
  })();
660

661
  $(window).on('load', function() {
662 663
    new Dispatcher();
  });
664
}).call(window);