1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<script>
import $ from 'jquery';
import { mapGetters, mapState } from 'vuex';
import Icon from '../../../vue_shared/components/icon.vue';
import TitleComponent from '../../../issue_show/components/title.vue';
import DescriptionComponent from '../../../issue_show/components/description.vue';
import { setTimeout, setInterval, clearInterval } from 'timers';
import store from '../../stores';
function onIframeReady(iframe, callback) {
let i = setInterval(() => {
try {
if (iframe.contentWindow.location.href === 'about:blank') return;
callback(iframe);
clearInterval(i);
}
catch (e) {}
}, 1000 / 60)
setTimeout(clearInterval, 10000, i);
}
function modifyMergeRequestPage(iframe) {
iframe.contentDocument.body.className += ' create-merge-request-iframe';
}
export default {
components: {
Icon,
TitleComponent,
DescriptionComponent,
},
computed: {
...mapState(['currentBranchId', 'currentProjectId', 'currentMergeRequestId']),
mergeRequestSrc() {
if (this.currentMergeRequestId) {
return `/${this.currentProjectId}/merge_requests/${this.currentMergeRequestId}`;
}
return `/${this.currentProjectId}/merge_requests/new?merge_request%5Bsource_branch%5D=${this.currentBranchId}&merge_request%5Btarget_branch%5D=master`;
},
},
watch: {
},
methods: {
onload() {
modifyMergeRequestPage($('#js-create-mr-sidebar').get(0));
store.dispatch('getMergeRequestsForBranch', {
projectId: this.currentProjectId,
branchId: this.currentBranchId,
});
}
},
mounted: () => {
onIframeReady($('#js-create-mr-sidebar').get(0), modifyMergeRequestPage)
}
};
</script>
<template>
<div class="ide-create-merge-request d-flex flex-column h-100">
<iframe
id="js-create-mr-sidebar"
:src="mergeRequestSrc"
class="h-100 border-0"
style="margin: -8px -16px;"
@load=onload()>
</iframe>
</div>
</template>
|