2018-03-17 18:26:18 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
import Translate from '~/vue_shared/translate';
|
2019-12-21 20:55:43 +05:30
|
|
|
import ModalManager from './components/user_modal_manager.vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
import csrf from '~/lib/utils/csrf';
|
2021-01-29 00:20:46 +05:30
|
|
|
import initConfirmModal from '~/confirm_modal';
|
2021-02-22 17:27:13 +05:30
|
|
|
import initAdminUsersApp from '~/admin/users';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
const MODAL_TEXTS_CONTAINER_SELECTOR = '#js-modal-texts';
|
|
|
|
const MODAL_MANAGER_SELECTOR = '#js-delete-user-modal';
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
function loadModalsConfigurationFromHtml(modalsElement) {
|
|
|
|
const modalsConfiguration = {};
|
|
|
|
|
|
|
|
if (!modalsElement) {
|
2020-04-22 19:07:51 +05:30
|
|
|
/* eslint-disable-next-line @gitlab/require-i18n-strings */
|
2019-12-21 20:55:43 +05:30
|
|
|
throw new Error('Modals content element not found!');
|
|
|
|
}
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
Array.from(modalsElement.children).forEach((node) => {
|
2019-12-21 20:55:43 +05:30
|
|
|
const { modal, ...config } = node.dataset;
|
|
|
|
modalsConfiguration[modal] = {
|
|
|
|
title: node.dataset.title,
|
|
|
|
...config,
|
|
|
|
content: node.innerHTML,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
return modalsConfiguration;
|
|
|
|
}
|
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
|
|
|
Vue.use(Translate);
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
const modalConfiguration = loadModalsConfigurationFromHtml(
|
|
|
|
document.querySelector(MODAL_TEXTS_CONTAINER_SELECTOR),
|
|
|
|
);
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: MODAL_MANAGER_SELECTOR,
|
|
|
|
functional: true,
|
|
|
|
methods: {
|
|
|
|
show(...args) {
|
|
|
|
this.$refs.manager.show(...args);
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
render(h) {
|
|
|
|
return h(ModalManager, {
|
|
|
|
ref: 'manager',
|
2018-03-17 18:26:18 +05:30
|
|
|
props: {
|
2019-12-21 20:55:43 +05:30
|
|
|
modalConfiguration,
|
2018-03-17 18:26:18 +05:30
|
|
|
csrfToken: csrf.token,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
initConfirmModal();
|
2021-02-22 17:27:13 +05:30
|
|
|
initAdminUsersApp();
|
2018-03-27 19:54:05 +05:30
|
|
|
});
|