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

index.js « new « projects « pages « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 477a1ab887b2024b16f352032f064756b6dce3c5 (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
36
37
38
39
40
41
42
43
44
45
46
47
import initProjectVisibilitySelector from '../../../project_visibility';
import initProjectNew from '../../../projects/project_new';
import { __ } from '~/locale';
import { deprecatedCreateFlash as createFlash } from '~/flash';
import Tracking from '~/tracking';
import { isExperimentEnabled } from '~/lib/utils/experimentation';

document.addEventListener('DOMContentLoaded', () => {
  initProjectVisibilitySelector();
  initProjectNew.bindEvents();

  const { category, property } = gon.tracking_data ?? { category: 'projects:new' };
  const hasNewCreateProjectUi = isExperimentEnabled('newCreateProjectUi');

  if (!hasNewCreateProjectUi) {
    // Setting additional tracking for HAML template

    Array.from(
      document.querySelectorAll('.project-edit-container [data-experiment-track-label]'),
    ).forEach(node =>
      node.addEventListener('click', event => {
        const { experimentTrackLabel: label } = event.currentTarget.dataset;
        Tracking.event(category, 'click_tab', { property, label });
      }),
    );
  } else {
    import(
      /* webpackChunkName: 'experiment_new_project_creation' */ '../../../projects/experiment_new_project_creation'
    )
      .then(m => {
        const el = document.querySelector('.js-experiment-new-project-creation');

        if (!el) {
          return;
        }

        const config = {
          hasErrors: 'hasErrors' in el.dataset,
          isCiCdAvailable: 'isCiCdAvailable' in el.dataset,
        };
        m.default(el, config);
      })
      .catch(() => {
        createFlash(__('An error occurred while loading project creation UI'));
      });
  }
});