2017-09-10 17:25:29 +05:30
|
|
|
import Vue from 'vue';
|
2018-03-27 19:54:05 +05:30
|
|
|
import Flash from '~/flash';
|
|
|
|
import Translate from '~/vue_shared/translate';
|
|
|
|
import { __ } from '~/locale';
|
2020-03-13 15:44:24 +05:30
|
|
|
import { setUrlFragment, redirectTo } from '~/lib/utils/url_utility';
|
2019-12-21 20:55:43 +05:30
|
|
|
import pipelineGraph from './components/graph/graph_component.vue';
|
2020-06-23 00:09:42 +05:30
|
|
|
import Dag from './components/dag/dag.vue';
|
2019-12-21 20:55:43 +05:30
|
|
|
import GraphBundleMixin from './mixins/graph_pipeline_bundle_mixin';
|
2018-03-27 19:54:05 +05:30
|
|
|
import PipelinesMediator from './pipeline_details_mediator';
|
2017-09-10 17:25:29 +05:30
|
|
|
import pipelineHeader from './components/header_component.vue';
|
|
|
|
import eventHub from './event_hub';
|
2019-12-26 22:10:19 +05:30
|
|
|
import TestReports from './components/test_reports/test_reports.vue';
|
2020-07-28 23:09:34 +05:30
|
|
|
import createTestReportsStore from './stores/test_reports';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
Vue.use(Translate);
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
const createPipelinesDetailApp = mediator => {
|
2019-12-26 22:10:19 +05:30
|
|
|
// eslint-disable-next-line no-new
|
2017-09-10 17:25:29 +05:30
|
|
|
new Vue({
|
|
|
|
el: '#js-pipeline-graph-vue',
|
2018-03-17 18:26:18 +05:30
|
|
|
components: {
|
|
|
|
pipelineGraph,
|
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
mixins: [GraphBundleMixin],
|
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,
|
2019-07-07 11:18:12 +05:30
|
|
|
mediator: this.mediator,
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
|
|
|
on: {
|
|
|
|
refreshPipelineGraph: this.requestRefreshPipelineGraph,
|
2020-04-22 19:07:51 +05:30
|
|
|
onResetTriggered: (parentPipeline, pipeline) =>
|
|
|
|
this.resetTriggeredPipelines(parentPipeline, pipeline),
|
|
|
|
onClickTriggeredBy: pipeline => this.clickTriggeredByPipeline(pipeline),
|
|
|
|
onClickTriggered: pipeline => this.clickTriggeredPipeline(pipeline),
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2020-05-24 23:13:21 +05:30
|
|
|
};
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
const createPipelineHeaderApp = mediator => {
|
2019-12-26 22:10:19 +05:30
|
|
|
// eslint-disable-next-line no-new
|
2017-09-10 17:25:29 +05:30
|
|
|
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);
|
2020-03-13 15:44:24 +05:30
|
|
|
eventHub.$on('headerDeleteAction', this.deleteAction);
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
eventHub.$off('headerPostAction', this.postAction);
|
2020-03-13 15:44:24 +05:30
|
|
|
eventHub.$off('headerDeleteAction', this.deleteAction);
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
|
|
|
methods: {
|
2020-03-13 15:44:24 +05:30
|
|
|
postAction(path) {
|
2018-10-15 14:42:47 +05:30
|
|
|
this.mediator.service
|
2020-03-13 15:44:24 +05:30
|
|
|
.postAction(path)
|
2017-09-10 17:25:29 +05:30
|
|
|
.then(() => this.mediator.refreshPipeline())
|
2018-03-27 19:54:05 +05:30
|
|
|
.catch(() => Flash(__('An error occurred while making the request.')));
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
2020-03-13 15:44:24 +05:30
|
|
|
deleteAction(path) {
|
|
|
|
this.mediator.stopPipelinePoll();
|
|
|
|
this.mediator.service
|
|
|
|
.deleteAction(path)
|
|
|
|
.then(({ request }) => redirectTo(setUrlFragment(request.responseURL, 'delete_success')))
|
|
|
|
.catch(() => Flash(__('An error occurred while deleting the pipeline.')));
|
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement('pipeline-header', {
|
|
|
|
props: {
|
|
|
|
isLoading: this.mediator.state.isLoading,
|
|
|
|
pipeline: this.mediator.store.state.pipeline,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2020-05-24 23:13:21 +05:30
|
|
|
};
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
const createPipelinesTabs = testReportsStore => {
|
2020-04-08 14:13:33 +05:30
|
|
|
const tabsElement = document.querySelector('.pipelines-tabs');
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
if (tabsElement) {
|
|
|
|
const fetchReportsAction = 'fetchFullReport';
|
2020-03-13 15:44:24 +05:30
|
|
|
const isTestTabActive = Boolean(
|
|
|
|
document.querySelector('.pipelines-tabs > li > a.test-tab.active'),
|
|
|
|
);
|
|
|
|
|
|
|
|
if (isTestTabActive) {
|
|
|
|
testReportsStore.dispatch(fetchReportsAction);
|
|
|
|
} else {
|
|
|
|
const tabClickHandler = e => {
|
|
|
|
if (e.target.className === 'test-tab') {
|
|
|
|
testReportsStore.dispatch(fetchReportsAction);
|
2020-04-08 14:13:33 +05:30
|
|
|
tabsElement.removeEventListener('click', tabClickHandler);
|
2020-03-13 15:44:24 +05:30
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
tabsElement.addEventListener('click', tabClickHandler);
|
2020-03-13 15:44:24 +05:30
|
|
|
}
|
2020-05-24 23:13:21 +05:30
|
|
|
}
|
|
|
|
};
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
const createTestDetails = () => {
|
|
|
|
if (!window.gon?.features?.junitPipelineView) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const el = document.querySelector('#js-pipeline-tests-detail');
|
|
|
|
const { fullReportEndpoint, summaryEndpoint, countEndpoint } = el?.dataset || {};
|
|
|
|
|
|
|
|
const testReportsStore = createTestReportsStore({
|
|
|
|
fullReportEndpoint,
|
|
|
|
summaryEndpoint: summaryEndpoint || countEndpoint,
|
|
|
|
useBuildSummaryReport: window.gon?.features?.buildReportSummary,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!window.gon?.features?.buildReportSummary) {
|
|
|
|
createPipelinesTabs(testReportsStore);
|
|
|
|
}
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
2020-07-28 23:09:34 +05:30
|
|
|
el,
|
2020-05-24 23:13:21 +05:30
|
|
|
components: {
|
|
|
|
TestReports,
|
|
|
|
},
|
2020-07-28 23:09:34 +05:30
|
|
|
store: testReportsStore,
|
2020-05-24 23:13:21 +05:30
|
|
|
render(createElement) {
|
|
|
|
return createElement('test-reports');
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
const createDagApp = () => {
|
|
|
|
if (!window.gon?.features?.dagPipelineTab) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const el = document.querySelector('#js-pipeline-dag-vue');
|
2020-07-28 23:09:34 +05:30
|
|
|
const { pipelineDataPath, emptySvgPath, dagDocPath } = el?.dataset;
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
|
|
|
components: {
|
|
|
|
Dag,
|
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement('dag', {
|
|
|
|
props: {
|
2020-07-28 23:09:34 +05:30
|
|
|
graphUrl: pipelineDataPath,
|
|
|
|
emptySvgPath,
|
|
|
|
dagDocPath,
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
export default () => {
|
|
|
|
const { dataset } = document.querySelector('.js-pipeline-details-vue');
|
|
|
|
const mediator = new PipelinesMediator({ endpoint: dataset.endpoint });
|
|
|
|
mediator.fetchPipeline();
|
|
|
|
|
|
|
|
createPipelinesDetailApp(mediator);
|
|
|
|
createPipelineHeaderApp(mediator);
|
2020-07-28 23:09:34 +05:30
|
|
|
createTestDetails();
|
2020-06-23 00:09:42 +05:30
|
|
|
createDagApp();
|
2018-03-27 19:54:05 +05:30
|
|
|
};
|