summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jobs/components/table/index.js
blob: b6b3bb6d37903adbee240fb07c168977acdbaec1 (plain)
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
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import JobsTableApp from '~/jobs/components/table/jobs_table_app.vue';
import createDefaultClient from '~/lib/graphql';

Vue.use(VueApollo);

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

export default (containerId = 'js-jobs-table') => {
  const containerEl = document.getElementById(containerId);

  if (!containerEl) {
    return false;
  }

  const { fullPath, jobCounts, jobStatuses } = containerEl.dataset;

  return new Vue({
    el: containerEl,
    apolloProvider,
    provide: {
      fullPath,
      jobStatuses: JSON.parse(jobStatuses),
      jobCounts: JSON.parse(jobCounts),
    },
    render(createElement) {
      return createElement(JobsTableApp);
    },
  });
};