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

0% Statements 0/10
0% Branches 0/4
0% Functions 0/1
0% Lines 0/9

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 46 47 48 49 50 51 52 53 54 55 56 57 58 59                                                                                                                     
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import MrWidgetOptions from 'any_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(
    {},
    {
      cacheConfig: {
        typePolicies: {
          MergeRequestApprovalState: {
            merge: true,
          },
        },
      },
    },
  ),
});
 
export default () => {
  if (gl.mrWidget) return;
 
  gl.mrWidgetData.gitlabLogo = gon.gitlab_logo;
  gl.mrWidgetData.defaultAvatarUrl = gon.default_avatar_url;
 
  const dismissalDescriptions = JSON.parse(gl.mrWidgetData.dismissal_descriptions || '{}');
 
  // 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-next-line @gitlab/no-runtime-template-compiler
  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),
      canCreatePipelineInTargetProject: parseBoolean(
        gl.mrWidgetData.can_create_pipeline_in_target_project,
      ),
      commitPathTemplate: gl.mrWidgetData.commit_path_template,
      dismissalDescriptions,
    },
    ...MrWidgetOptions,
    apolloProvider,
  });
 
  window.gl.mrWidget = {
    checkStatus: vm.checkStatus,
  };
};