debian-mirror-gitlab/app/assets/javascripts/integrations/edit/index.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

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-06-23 00:09:42 +05:30
const { type, commentDetail, triggerEvents, fields, ...booleanAttributes } = el.dataset;
2020-05-24 23:13:21 +05:30
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-06-23 00:09:42 +05:30
fields: JSON.parse(fields),
2020-04-22 19:07:51 +05:30
},
});
},
});
};