summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/add_context_commits_modal/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/add_context_commits_modal/index.js')
-rw-r--r--app/assets/javascripts/add_context_commits_modal/index.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/app/assets/javascripts/add_context_commits_modal/index.js b/app/assets/javascripts/add_context_commits_modal/index.js
new file mode 100644
index 00000000000..b5cd111fabc
--- /dev/null
+++ b/app/assets/javascripts/add_context_commits_modal/index.js
@@ -0,0 +1,64 @@
+import Vue from 'vue';
+import { parseBoolean } from '~/lib/utils/common_utils';
+import createStore from './store';
+import AddContextCommitsModalTrigger from './components/add_context_commits_modal_trigger.vue';
+import AddContextCommitsModalWrapper from './components/add_context_commits_modal_wrapper.vue';
+
+export default function initAddContextCommitsTriggers() {
+ const addContextCommitsModalTriggerEl = document.querySelector('.add-review-item-modal-trigger');
+ const addContextCommitsModalWrapperEl = document.querySelector('.add-review-item-modal-wrapper');
+
+ if (addContextCommitsModalTriggerEl || addContextCommitsModalWrapperEl) {
+ // 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,
+ },
+ });
+ },
+ });
+
+ 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,
+ },
+ });
+ },
+ });
+ }
+}