2021-03-11 19:13:27 +05:30
|
|
|
import { GlToast } from '@gitlab/ui';
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
|
|
|
import NotificationsDropdown from './components/notifications_dropdown.vue';
|
2023-03-17 16:20:25 +05:30
|
|
|
import NotificationEmailListboxInput from './components/notification_email_listbox_input.vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
Vue.use(GlToast);
|
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
const initNotificationEmailListboxInputs = () => {
|
|
|
|
const els = [...document.querySelectorAll('.js-notification-email-listbox-input')];
|
|
|
|
|
|
|
|
els.forEach((el, index) => {
|
|
|
|
const { label, name, emptyValueText, value = '' } = el.dataset;
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
name: `NotificationEmailListboxInputRoot${index + 1}`,
|
|
|
|
provide: {
|
|
|
|
label,
|
|
|
|
name,
|
|
|
|
emails: JSON.parse(el.dataset.emails),
|
|
|
|
emptyValueText,
|
|
|
|
value,
|
|
|
|
disabled: parseBoolean(el.dataset.disabled),
|
|
|
|
},
|
|
|
|
render(h) {
|
|
|
|
return h(NotificationEmailListboxInput);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
export default () => {
|
2023-03-17 16:20:25 +05:30
|
|
|
initNotificationEmailListboxInputs();
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
const containers = document.querySelectorAll('.js-vue-notification-dropdown');
|
|
|
|
|
|
|
|
if (!containers.length) return false;
|
|
|
|
|
|
|
|
return containers.forEach((el) => {
|
|
|
|
const {
|
|
|
|
containerClass,
|
|
|
|
buttonSize,
|
|
|
|
disabled,
|
|
|
|
dropdownItems,
|
|
|
|
notificationLevel,
|
|
|
|
helpPagePath,
|
|
|
|
projectId,
|
|
|
|
groupId,
|
|
|
|
showLabel,
|
2022-04-04 11:22:00 +05:30
|
|
|
noFlip,
|
2021-03-11 19:13:27 +05:30
|
|
|
} = el.dataset;
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
provide: {
|
|
|
|
containerClass,
|
|
|
|
buttonSize,
|
|
|
|
disabled: parseBoolean(disabled),
|
|
|
|
dropdownItems: JSON.parse(dropdownItems),
|
|
|
|
initialNotificationLevel: notificationLevel,
|
|
|
|
helpPagePath,
|
|
|
|
projectId,
|
|
|
|
groupId,
|
|
|
|
showLabel: parseBoolean(showLabel),
|
2022-04-04 11:22:00 +05:30
|
|
|
noFlip: parseBoolean(noFlip),
|
2021-03-11 19:13:27 +05:30
|
|
|
},
|
|
|
|
render(h) {
|
|
|
|
return h(NotificationsDropdown);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|