2017-09-10 17:25:29 +05:30
|
|
|
import Vue from 'vue';
|
2020-10-24 23:57:45 +05:30
|
|
|
import { deprecatedCreateFlash as Flash } from '~/flash';
|
2018-03-27 19:54:05 +05:30
|
|
|
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-10-24 23:57:45 +05:30
|
|
|
import createDagApp from './pipeline_details_dag';
|
2019-12-21 20:55:43 +05:30
|
|
|
import GraphBundleMixin from './mixins/graph_pipeline_bundle_mixin';
|
2021-01-03 14:25:43 +05:30
|
|
|
import legacyPipelineHeader from './components/legacy_header_component.vue';
|
2017-09-10 17:25:29 +05:30
|
|
|
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-11-24 15:15:51 +05:30
|
|
|
const SELECTORS = {
|
|
|
|
PIPELINE_DETAILS: '.js-pipeline-details-vue',
|
|
|
|
PIPELINE_GRAPH: '#js-pipeline-graph-vue',
|
|
|
|
PIPELINE_HEADER: '#js-pipeline-header-vue',
|
|
|
|
PIPELINE_TESTS: '#js-pipeline-tests-detail',
|
|
|
|
};
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
const createLegacyPipelinesDetailApp = mediator => {
|
2020-11-24 15:15:51 +05:30
|
|
|
if (!document.querySelector(SELECTORS.PIPELINE_GRAPH)) {
|
|
|
|
return;
|
|
|
|
}
|
2019-12-26 22:10:19 +05:30
|
|
|
// eslint-disable-next-line no-new
|
2017-09-10 17:25:29 +05:30
|
|
|
new Vue({
|
2020-11-24 15:15:51 +05:30
|
|
|
el: SELECTORS.PIPELINE_GRAPH,
|
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,
|
2021-01-29 00:20:46 +05:30
|
|
|
onResetDownstream: (parentPipeline, pipeline) =>
|
|
|
|
this.resetDownstreamPipelines(parentPipeline, pipeline),
|
|
|
|
onClickUpstreamPipeline: pipeline => this.clickUpstreamPipeline(pipeline),
|
|
|
|
onClickDownstreamPipeline: pipeline => this.clickDownstreamPipeline(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
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
const createLegacyPipelineHeaderApp = mediator => {
|
2020-11-24 15:15:51 +05:30
|
|
|
if (!document.querySelector(SELECTORS.PIPELINE_HEADER)) {
|
|
|
|
return;
|
|
|
|
}
|
2019-12-26 22:10:19 +05:30
|
|
|
// eslint-disable-next-line no-new
|
2017-09-10 17:25:29 +05:30
|
|
|
new Vue({
|
2020-11-24 15:15:51 +05:30
|
|
|
el: SELECTORS.PIPELINE_HEADER,
|
2018-03-17 18:26:18 +05:30
|
|
|
components: {
|
2021-01-03 14:25:43 +05:30
|
|
|
legacyPipelineHeader,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
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) {
|
2021-01-03 14:25:43 +05:30
|
|
|
return createElement('legacy-pipeline-header', {
|
2017-09-10 17:25:29 +05:30
|
|
|
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 createTestDetails = () => {
|
2020-11-24 15:15:51 +05:30
|
|
|
const el = document.querySelector(SELECTORS.PIPELINE_TESTS);
|
2020-10-24 23:57:45 +05:30
|
|
|
const { summaryEndpoint, suiteEndpoint } = el?.dataset || {};
|
2020-07-28 23:09:34 +05:30
|
|
|
const testReportsStore = createTestReportsStore({
|
2020-10-24 23:57:45 +05:30
|
|
|
summaryEndpoint,
|
|
|
|
suiteEndpoint,
|
2020-07-28 23:09:34 +05:30
|
|
|
});
|
|
|
|
|
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');
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
export default async function() {
|
|
|
|
createTestDetails();
|
|
|
|
createDagApp();
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
const { dataset } = document.querySelector(SELECTORS.PIPELINE_DETAILS);
|
2021-01-29 00:20:46 +05:30
|
|
|
let mediator;
|
|
|
|
|
|
|
|
if (!gon.features.graphqlPipelineHeader || !gon.features.graphqlPipelineDetails) {
|
|
|
|
try {
|
|
|
|
const { default: PipelinesMediator } = await import(
|
|
|
|
/* webpackChunkName: 'PipelinesMediator' */ './pipeline_details_mediator'
|
|
|
|
);
|
|
|
|
mediator = new PipelinesMediator({ endpoint: dataset.endpoint });
|
|
|
|
mediator.fetchPipeline();
|
|
|
|
} catch {
|
|
|
|
Flash(__('An error occurred while loading the pipeline.'));
|
|
|
|
}
|
|
|
|
}
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
if (gon.features.graphqlPipelineDetails) {
|
|
|
|
try {
|
|
|
|
const { createPipelinesDetailApp } = await import(
|
|
|
|
/* webpackChunkName: 'createPipelinesDetailApp' */ './pipeline_details_graph'
|
|
|
|
);
|
|
|
|
createPipelinesDetailApp();
|
|
|
|
} catch {
|
|
|
|
Flash(__('An error occurred while loading the pipeline.'));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
createLegacyPipelinesDetailApp(mediator);
|
|
|
|
}
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
if (gon.features.graphqlPipelineHeader) {
|
2021-01-29 00:20:46 +05:30
|
|
|
try {
|
|
|
|
const { createPipelineHeaderApp } = await import(
|
|
|
|
/* webpackChunkName: 'createPipelineHeaderApp' */ './pipeline_details_header'
|
|
|
|
);
|
|
|
|
createPipelineHeaderApp(SELECTORS.PIPELINE_HEADER);
|
|
|
|
} catch {
|
|
|
|
Flash(__('An error occurred while loading a section of this page.'));
|
|
|
|
}
|
2021-01-03 14:25:43 +05:30
|
|
|
} else {
|
|
|
|
createLegacyPipelineHeaderApp(mediator);
|
|
|
|
}
|
2021-01-29 00:20:46 +05:30
|
|
|
}
|