2020-10-24 23:57:45 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
|
|
|
import AddContextCommitsModalTrigger from './components/add_context_commits_modal_trigger.vue';
|
|
|
|
import AddContextCommitsModalWrapper from './components/add_context_commits_modal_wrapper.vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
import createStore from './store';
|
2020-10-24 23:57:45 +05:30
|
|
|
|
|
|
|
export default function initAddContextCommitsTriggers() {
|
|
|
|
const addContextCommitsModalTriggerEl = document.querySelector('.add-review-item-modal-trigger');
|
|
|
|
const addContextCommitsModalWrapperEl = document.querySelector('.add-review-item-modal-wrapper');
|
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
if (addContextCommitsModalTriggerEl) {
|
2020-10-24 23:57:45 +05:30
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: addContextCommitsModalTriggerEl,
|
|
|
|
data() {
|
|
|
|
const { commitsEmpty, contextCommitsEmpty } = this.$options.el.dataset;
|
|
|
|
return {
|
|
|
|
commitsEmpty: parseBoolean(commitsEmpty),
|
|
|
|
contextCommitsEmpty: parseBoolean(contextCommitsEmpty),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement(AddContextCommitsModalTrigger, {
|
|
|
|
props: {
|
|
|
|
commitsEmpty: this.commitsEmpty,
|
|
|
|
contextCommitsEmpty: this.contextCommitsEmpty,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2022-08-13 15:12:31 +05:30
|
|
|
}
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
if (addContextCommitsModalWrapperEl) {
|
2020-10-24 23:57:45 +05:30
|
|
|
const store = createStore();
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: addContextCommitsModalWrapperEl,
|
|
|
|
store,
|
|
|
|
data() {
|
|
|
|
const {
|
|
|
|
contextCommitsPath,
|
|
|
|
targetBranch,
|
|
|
|
mergeRequestIid,
|
|
|
|
projectId,
|
|
|
|
} = this.$options.el.dataset;
|
|
|
|
return {
|
|
|
|
contextCommitsPath,
|
|
|
|
targetBranch,
|
|
|
|
mergeRequestIid: Number(mergeRequestIid),
|
|
|
|
projectId: Number(projectId),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement(AddContextCommitsModalWrapper, {
|
|
|
|
props: {
|
|
|
|
contextCommitsPath: this.contextCommitsPath,
|
|
|
|
targetBranch: this.targetBranch,
|
|
|
|
mergeRequestIid: this.mergeRequestIid,
|
|
|
|
projectId: this.projectId,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|