summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/admin/users/index.js
blob: 0365d054fc9cf1f730fe72611c5c9a82abf6eb4d (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
import Vue from 'vue';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import AdminUsersApp from './components/app.vue';
import UsagePingDisabled from './components/usage_ping_disabled.vue';

export const initAdminUsersApp = (el = document.querySelector('#js-admin-users-app')) => {
  if (!el) {
    return false;
  }

  const { users, paths } = el.dataset;

  return new Vue({
    el,
    render: (createElement) =>
      createElement(AdminUsersApp, {
        props: {
          users: convertObjectPropsToCamelCase(JSON.parse(users), { deep: true }),
          paths: convertObjectPropsToCamelCase(JSON.parse(paths)),
        },
      }),
  });
};

export const initCohortsEmptyState = (el = document.querySelector('#js-cohorts-empty-state')) => {
  if (!el) {
    return false;
  }

  const { emptyStateSvgPath, enableUsagePingLink, docsLink } = el.dataset;

  return new Vue({
    el,
    provide: {
      svgPath: emptyStateSvgPath,
      primaryButtonPath: enableUsagePingLink,
      docsLink,
    },
    render(h) {
      return h(UsagePingDisabled);
    },
  });
};