gitlab-org--gitlab-foss/app/assets/javascripts/visibility_select.js.es6

30 lines
1004 B
JavaScript
Raw Normal View History

(() => {
const global = window.gl || (window.gl = {});
const VISIBILITY_DESCRIPTIONS = {
0: 'Project access must be granted explicitly to each user.',
2016-11-22 14:51:49 +00:00
10: 'This project can be cloned by any logged in user.',
20: 'The project can be cloned without any authentication.',
};
class VisibilitySelect {
constructor() {
this.visibilitySelect = document.querySelector('.js-visibility-select');
this.helpBlock = this.visibilitySelect.querySelector('.help-block');
this.select = this.visibilitySelect.querySelector('select');
if (this.select) {
this.visibilityChanged();
this.select.addEventListener('change', this.visibilityChanged.bind(this));
} else {
this.helpBlock.textContent = this.visibilitySelect.querySelector('.js-locked').dataset.helpBlock;
}
}
visibilityChanged() {
this.helpBlock.innerText = VISIBILITY_DESCRIPTIONS[this.select.value];
}
}
global.VisibilitySelect = VisibilitySelect;
})();