2020-04-22 19:07:51 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
2020-05-24 23:13:21 +05:30
|
|
|
import IntegrationForm from './components/integration_form.vue';
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
export default el => {
|
|
|
|
if (!el) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
function parseBooleanInData(data) {
|
|
|
|
const result = {};
|
|
|
|
Object.entries(data).forEach(([key, value]) => {
|
|
|
|
result[key] = parseBoolean(value);
|
|
|
|
});
|
|
|
|
return result;
|
2020-04-22 19:07:51 +05:30
|
|
|
}
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
const { type, commentDetail, triggerEvents, ...booleanAttributes } = el.dataset;
|
|
|
|
const {
|
|
|
|
showActive,
|
|
|
|
activated,
|
|
|
|
commitEvents,
|
|
|
|
mergeRequestEvents,
|
|
|
|
enableComments,
|
|
|
|
} = parseBooleanInData(booleanAttributes);
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
render(createElement) {
|
2020-05-24 23:13:21 +05:30
|
|
|
return createElement(IntegrationForm, {
|
2020-04-22 19:07:51 +05:30
|
|
|
props: {
|
2020-05-24 23:13:21 +05:30
|
|
|
activeToggleProps: {
|
|
|
|
initialActivated: activated,
|
|
|
|
},
|
|
|
|
showActive,
|
|
|
|
type,
|
|
|
|
triggerFieldsProps: {
|
|
|
|
initialTriggerCommit: commitEvents,
|
|
|
|
initialTriggerMergeRequest: mergeRequestEvents,
|
|
|
|
initialEnableComments: enableComments,
|
|
|
|
initialCommentDetail: commentDetail,
|
|
|
|
},
|
|
|
|
triggerEvents: JSON.parse(triggerEvents),
|
2020-04-22 19:07:51 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|