summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/projects/storage_counter/index.js
blob: 10668f08402b133f8cedb9d06c18b347077180e8 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
import StorageCounterApp from './components/app.vue';

Vue.use(VueApollo);

export default (containerId = 'js-project-storage-count-app') => {
  const el = document.getElementById(containerId);

  if (!el) {
    return false;
  }

  const {
    projectPath,
    usageQuotasHelpPagePath,
    buildArtifactsHelpPagePath,
    lfsObjectsHelpPagePath,
    packagesHelpPagePath,
    repositoryHelpPagePath,
    snippetsHelpPagePath,
    uploadsHelpPagePath,
    wikiHelpPagePath,
  } = el.dataset;

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

  return new Vue({
    el,
    apolloProvider,
    provide: {
      projectPath,
      helpLinks: {
        usageQuotasHelpPagePath,
        buildArtifactsHelpPagePath,
        lfsObjectsHelpPagePath,
        packagesHelpPagePath,
        repositoryHelpPagePath,
        snippetsHelpPagePath,
        uploadsHelpPagePath,
        wikiHelpPagePath,
      },
    },
    render(createElement) {
      return createElement(StorageCounterApp);
    },
  });
};