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 */
F
Filipa Lacerda 已提交
2
import Milestone from './milestone';
P
Phil Hughes 已提交
3
import notificationsDropdown from './notifications_dropdown';
P
Phil Hughes 已提交
4 5 6
import LineHighlighter from './line_highlighter';
import MergeRequest from './merge_request';
import Sidebar from './right_sidebar';
7
import Flash from './flash';
D
Douwe Maan 已提交
8
import BlobViewer from './blob/viewer/index';
9
import GfmAutoComplete from './gfm_auto_complete';
10
import Star from './star';
11
import ZenMode from './zen_mode';
12
import PerformanceBar from './performance_bar';
P
Phil Hughes 已提交
13 14
import initNotes from './init_notes';
import initIssuableSidebar from './init_issuable_sidebar';
C
Clement Ho 已提交
15
import { convertPermissionToBoolean } from './lib/utils/common_utils';
16
import GlFieldErrors from './gl_field_errors';
17 18
import Shortcuts from './shortcuts';
import ShortcutsIssuable from './shortcuts_issuable';
19
import Diff from './diff';
F
Filipa Lacerda 已提交
20
import SearchAutocomplete from './search_autocomplete';
21

F
Fatih Acet 已提交
22 23 24 25 26 27
(function() {
  var Dispatcher;

  Dispatcher = (function() {
    function Dispatcher() {
      this.initSearch();
28
      this.initFieldErrors();
F
Fatih Acet 已提交
29 30 31 32
      this.initPageScripts();
    }

    Dispatcher.prototype.initPageScripts = function() {
33
      var path, shortcut_handler;
34
      const page = $('body').attr('data-page');
F
Fatih Acet 已提交
35 36 37
      if (!page) {
        return false;
      }
38

39
      const fail = () => Flash('Error loading dynamic module');
40
      const callDefault = m => m.default();
41

F
Fatih Acet 已提交
42 43
      path = page.split(':');
      shortcut_handler = null;
44

F
Filipa Lacerda 已提交
45
      $('.js-gfm-input:not(.js-vue-textarea)').each((i, el) => {
46
        const gfm = new GfmAutoComplete(gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources);
47
        const enableGFM = convertPermissionToBoolean(el.dataset.supportsAutocomplete);
48 49 50 51 52 53 54 55 56
        gfm.setup($(el), {
          emojis: true,
          members: enableGFM,
          issues: enableGFM,
          milestones: enableGFM,
          mergeRequests: enableGFM,
          labels: enableGFM,
        });
      });
57

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

275 276
          initIssuableSidebar();
          initNotes();
277

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

      if (document.querySelector('#peek')) {
        new PerformanceBar({ container: '#peek' });
      }
F
Fatih Acet 已提交
644 645 646
    };

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

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

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

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