All files / app/assets/javascripts/vue_merge_request_widget index.js

33.33% Statements 3/9
0% Branches 0/2
0% Functions 0/1
37.5% Lines 3/8

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                      1x 1x   1x                                                    
// This is a false violation of @gitlab/no-runtime-template-compiler, since it
// creates a new Vue instance by spreading a _valid_ Vue component definition
// into the Vue constructor.
/* eslint-disable @gitlab/no-runtime-template-compiler */
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import MrWidgetOptions from 'ee_else_ce/vue_merge_request_widget/mr_widget_options.vue';
import createDefaultClient from '~/lib/graphql';
import { parseBoolean } from '~/lib/utils/common_utils';
import Translate from '../vue_shared/translate';
 
Vue.use(Translate);
Vue.use(VueApollo);
 
const apolloProvider = new VueApollo({
  defaultClient: createDefaultClient(),
});
 
export default () => {
  if (gl.mrWidget) return;
 
  gl.mrWidgetData.gitlabLogo = gon.gitlab_logo;
  gl.mrWidgetData.defaultAvatarUrl = gon.default_avatar_url;
 
  const vm = new Vue({
    el: '#js-vue-mr-widget',
    provide: {
      artifactsEndpoint: gl.mrWidgetData.artifacts_endpoint,
      artifactsEndpointPlaceholder: gl.mrWidgetData.artifacts_endpoint_placeholder,
      falsePositiveDocUrl: gl.mrWidgetData.false_positive_doc_url,
      canViewFalsePositive: parseBoolean(gl.mrWidgetData.can_view_false_positive),
    },
    ...MrWidgetOptions,
    apolloProvider,
  });
 
  window.gl.mrWidget = {
    checkStatus: vm.checkStatus,
  };
};