All files / app/assets/javascripts/projects/commit_box/info init_commit_pipeline_mini_graph.js

0% Statements 0/10
0% Branches 0/5
0% Functions 0/2
0% Lines 0/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                                                         
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
 
Vue.use(VueApollo);
 
const apolloProvider = new VueApollo({
  defaultClient: createDefaultClient(),
});
 
export const initCommitPipelineMiniGraph = async (selector = '.js-commit-pipeline-mini-graph') => {
  const el = document.querySelector(selector);
 
  if (!el) {
    return;
  }
 
  const { stages, fullPath, iid, graphqlResourceEtag } = el.dataset;
 
  // Some commits have no pipeline, code splitting to load the pipeline optionally
  const { default: CommitBoxPipelineMiniGraph } = await import(
    /* webpackChunkName: 'commitBoxPipelineMiniGraph' */ './components/commit_box_pipeline_mini_graph.vue'
  );
 
  // eslint-disable-next-line no-new
  new Vue({
    el,
    apolloProvider,
    provide: {
      fullPath,
      iid,
      dataMethod: 'graphql',
      graphqlResourceEtag,
    },
    render(createElement) {
      return createElement(CommitBoxPipelineMiniGraph, {
        props: {
          // if stages do not exist for some reason, protect JSON.parse from erroring out
          stages: stages ? JSON.parse(stages) : [],
        },
      });
    },
  });
};