debian-mirror-gitlab/app/assets/javascripts/pages/projects/new/index.js

47 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import initProjectVisibilitySelector from '../../../project_visibility';
import initProjectNew from '../../../projects/project_new';
2020-06-23 00:09:42 +05:30
import { __ } from '~/locale';
import createFlash from '~/flash';
import Tracking from '~/tracking';
2018-03-17 18:26:18 +05:30
2018-03-27 19:54:05 +05:30
document.addEventListener('DOMContentLoaded', () => {
2018-03-17 18:26:18 +05:30
initProjectVisibilitySelector();
initProjectNew.bindEvents();
2020-06-23 00:09:42 +05:30
const { category, property } = gon.tracking_data ?? { category: 'projects:new' };
const hasNewCreateProjectUi = 'newCreateProjectUi' in gon?.features;
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'));
});
}
2018-03-27 19:54:05 +05:30
});