{"size": 1499, "ext": "js", "max_stars_repo_path": "ee/app/assets/javascripts/test_case_list/test_case_list_bundle.js", "max_stars_repo_name": "samg/a-gl", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ee/app/assets/javascripts/test_case_list/test_case_list_bundle.js", "max_issues_repo_name": "samg/a-gl", "max_issues_repo_issues_event_min_datetime": "2020-05-19T00:04:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T22:05:57.000Z", "max_forks_repo_path": "ee/app/assets/javascripts/test_case_list/test_case_list_bundle.js", "max_forks_repo_name": "samg/a-gl", "max_forks_repo_forks_event_min_datetime": "2020-11-04T05:27:00.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-01T11:21:10.000Z"}
{"max_stars_count": null, "max_issues_count": 21, "max_forks_count": 2, "avg_line_length": 23.0615384615, "max_line_length": 93, "alphanum_fraction": 0.6697798532}
import Vue from 'vue';
import VueApollo from 'vue-apollo';

import createDefaultClient from '~/lib/graphql';
import {
  urlParamsToObject,
  convertObjectPropsToCamelCase,
  parseBoolean,
} from '~/lib/utils/common_utils';

import TestCaseListApp from './components/test_case_list_root.vue';

import { TestCaseStates } from './constants';

Vue.use(VueApollo);

const initTestCaseList = ({ mountPointSelector }) => {
  const mountPointEl = document.querySelector(mountPointSelector);

  if (!mountPointEl) {
    return null;
  }

  const apolloProvider = new VueApollo({
    defaultClient: createDefaultClient(),
  });

  const {
    canCreateTestCase,
    page = 1,
    prev = '',
    next = '',
    initialState = TestCaseStates.Opened,
    initialSortBy = 'created_desc',
  } = mountPointEl.dataset;

  const initialFilterParams = Object.assign(
    convertObjectPropsToCamelCase(urlParamsToObject(window.location.search.substring(1)), {
      dropKeys: ['scope', 'utf8', 'state', 'sort'], // These keys are unsupported/unnecessary
    }),
  );

  return new Vue({
    el: mountPointEl,
    apolloProvider,
    provide: {
      ...mountPointEl.dataset,
      canCreateTestCase: parseBoolean(canCreateTestCase),
      page: parseInt(page, 10),
      prev,
      next,
      initialState,
      initialSortBy,
    },
    render: (createElement) =>
      createElement(TestCaseListApp, {
        props: {
          initialFilterParams,
        },
      }),
  });
};

export default initTestCaseList;
