debian-mirror-gitlab/app/assets/javascripts/webhooks/index.js
2023-04-23 21:23:45 +05:30

45 lines
984 B
JavaScript

import Vue from 'vue';
import FormUrlApp from './components/form_url_app.vue';
import TestDropdown from './components/test_dropdown.vue';
export default () => {
const el = document.querySelector('.js-vue-webhook-form');
if (!el) {
return null;
}
const { url: initialUrl, urlVariables } = el.dataset;
return new Vue({
el,
name: 'WebhookFormRoot',
render(createElement) {
return createElement(FormUrlApp, {
props: {
initialUrl,
initialUrlVariables: JSON.parse(urlVariables),
},
});
},
});
};
const initHookTestDropdown = (el) => {
const { items, size } = el.dataset;
return new Vue({
el,
render(h) {
return h(TestDropdown, {
props: {
items: JSON.parse(items),
size,
},
});
},
});
};
export const initHookTestDropdowns = (selector = '.js-webhook-test-dropdown') =>
document.querySelectorAll(selector).forEach(initHookTestDropdown);