Commit 2c9e66bd authored by samdbeckham's avatar samdbeckham

Adds checks for the pipeline app elements

Makes sure the elements that the pipeline vue apps mount to actually
exist before trying to mount to them
parent 60a89b28
...@@ -14,10 +14,20 @@ import createTestReportsStore from './stores/test_reports'; ...@@ -14,10 +14,20 @@ import createTestReportsStore from './stores/test_reports';
Vue.use(Translate); Vue.use(Translate);
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',
};
const createPipelinesDetailApp = mediator => { const createPipelinesDetailApp = mediator => {
if (!document.querySelector(SELECTORS.PIPELINE_GRAPH)) {
return;
}
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
el: '#js-pipeline-graph-vue', el: SELECTORS.PIPELINE_GRAPH,
components: { components: {
pipelineGraph, pipelineGraph,
}, },
...@@ -47,9 +57,12 @@ const createPipelinesDetailApp = mediator => { ...@@ -47,9 +57,12 @@ const createPipelinesDetailApp = mediator => {
}; };
const createPipelineHeaderApp = mediator => { const createPipelineHeaderApp = mediator => {
if (!document.querySelector(SELECTORS.PIPELINE_HEADER)) {
return;
}
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
el: '#js-pipeline-header-vue', el: SELECTORS.PIPELINE_HEADER,
components: { components: {
pipelineHeader, pipelineHeader,
}, },
...@@ -93,9 +106,8 @@ const createPipelineHeaderApp = mediator => { ...@@ -93,9 +106,8 @@ const createPipelineHeaderApp = mediator => {
}; };
const createTestDetails = () => { const createTestDetails = () => {
const el = document.querySelector('#js-pipeline-tests-detail'); const el = document.querySelector(SELECTORS.PIPELINE_TESTS);
const { summaryEndpoint, suiteEndpoint } = el?.dataset || {}; const { summaryEndpoint, suiteEndpoint } = el?.dataset || {};
const testReportsStore = createTestReportsStore({ const testReportsStore = createTestReportsStore({
summaryEndpoint, summaryEndpoint,
suiteEndpoint, suiteEndpoint,
...@@ -115,7 +127,7 @@ const createTestDetails = () => { ...@@ -115,7 +127,7 @@ const createTestDetails = () => {
}; };
export default () => { export default () => {
const { dataset } = document.querySelector('.js-pipeline-details-vue'); const { dataset } = document.querySelector(SELECTORS.PIPELINE_DETAILS);
const mediator = new PipelinesMediator({ endpoint: dataset.endpoint }); const mediator = new PipelinesMediator({ endpoint: dataset.endpoint });
mediator.fetchPipeline(); mediator.fetchPipeline();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment