All files / ee/app/assets/javascripts/external_issues_list index.js

0% Statements 0/8
0% Branches 0/5
0% Functions 0/3
0% Lines 0/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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69                                                                                                                                         
import Vue from 'vue';
 
import { IssuableStates } from '~/vue_shared/issuable/list/constants';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import { queryToObject } from '~/lib/utils/url_utility';
 
import ExternalIssuesListApp from './components/external_issues_list_root.vue';
import getApolloProvider from './graphql';
 
export default function externalIssuesListFactory({
  provides: {
    getIssuesQuery,
    externalIssuesLogo,
    externalIssueTrackerName,
    searchInputPlaceholderText,
    recentSearchesStorageKey,
    createNewIssueText,
    emptyStateNoIssueText,
  },
  externalIssuesQueryResolver,
}) {
  return function initExternalIssuesList({ mountPointSelector }) {
    const mountPointEl = document.querySelector(mountPointSelector);
 
    if (!mountPointEl) {
      return null;
    }
 
    const {
      page = 1,
      initialState = IssuableStates.Opened,
      initialSortBy = 'created_desc',
    } = mountPointEl.dataset;
 
    const initialFilterParams = Object.assign(
      convertObjectPropsToCamelCase(
        queryToObject(window.location.search.substring(1), { gatherArrays: true }),
        {
          dropKeys: ['scope', 'utf8', 'state', 'sort'], // These keys are unsupported/unnecessary
        },
      ),
    );
 
    return new Vue({
      el: mountPointEl,
      provide: {
        ...mountPointEl.dataset,
        page: parseInt(page, 10),
        initialState,
        initialSortBy,
        getIssuesQuery,
        externalIssuesLogo,
        externalIssueTrackerName,
        searchInputPlaceholderText,
        recentSearchesStorageKey,
        createNewIssueText,
        emptyStateNoIssueText,
      },
      apolloProvider: getApolloProvider(externalIssuesQueryResolver),
      render: (createElement) =>
        createElement(ExternalIssuesListApp, {
          props: {
            initialFilterParams,
          },
        }),
    });
  };
}