debian-mirror-gitlab/app/assets/javascripts/groups/settings/init_access_dropdown.js
2022-07-29 14:03:07 +02:00

36 lines
767 B
JavaScript

import * as Sentry from '@sentry/browser';
import Vue from 'vue';
import AccessDropdown from './components/access_dropdown.vue';
export const initAccessDropdown = (el) => {
if (!el) {
return false;
}
const { label, disabled, preselectedItems } = el.dataset;
let preselected = [];
try {
preselected = JSON.parse(preselectedItems);
} catch (e) {
Sentry.captureException(e);
}
return new Vue({
el,
render(createElement) {
const vm = this;
return createElement(AccessDropdown, {
props: {
preselectedItems: preselected,
label,
disabled,
},
on: {
select(selected) {
vm.$emit('select', selected);
},
},
});
},
});
};