debian-mirror-gitlab/app/assets/javascripts/pipelines/pipeline_details_bundle.js

70 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-09-10 17:25:29 +05:30
import Vue from 'vue';
2018-03-17 18:26:18 +05:30
import Flash from '../flash';
2017-09-10 17:25:29 +05:30
import PipelinesMediator from './pipeline_details_mediatior';
import pipelineGraph from './components/graph/graph_component.vue';
import pipelineHeader from './components/header_component.vue';
import eventHub from './event_hub';
document.addEventListener('DOMContentLoaded', () => {
const dataset = document.querySelector('.js-pipeline-details-vue').dataset;
const mediator = new PipelinesMediator({ endpoint: dataset.endpoint });
mediator.fetchPipeline();
// eslint-disable-next-line
new Vue({
el: '#js-pipeline-graph-vue',
2018-03-17 18:26:18 +05:30
components: {
pipelineGraph,
},
2017-09-10 17:25:29 +05:30
data() {
return {
mediator,
};
},
render(createElement) {
return createElement('pipeline-graph', {
props: {
isLoading: this.mediator.state.isLoading,
pipeline: this.mediator.store.state.pipeline,
},
});
},
});
// eslint-disable-next-line
new Vue({
el: '#js-pipeline-header-vue',
2018-03-17 18:26:18 +05:30
components: {
pipelineHeader,
},
2017-09-10 17:25:29 +05:30
data() {
return {
mediator,
};
},
created() {
eventHub.$on('headerPostAction', this.postAction);
},
beforeDestroy() {
eventHub.$off('headerPostAction', this.postAction);
},
methods: {
postAction(action) {
this.mediator.service.postAction(action.path)
.then(() => this.mediator.refreshPipeline())
.catch(() => new Flash('An error occurred while making the request.'));
},
},
render(createElement) {
return createElement('pipeline-header', {
props: {
isLoading: this.mediator.state.isLoading,
pipeline: this.mediator.store.state.pipeline,
},
});
},
});
});