All files / app/assets/javascripts/invite_members init_invite_members_modal.js

0% Statements 0/9
0% Branches 0/8
0% Functions 0/3
0% Lines 0/9

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                                                                                                       
import { GlToast } from '@gitlab/ui';
import Vue from 'vue';
import InviteMembersModal from '~/invite_members/components/invite_members_modal.vue';
import { parseBoolean, convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
 
Vue.use(GlToast);
 
export default (function initInviteMembersModal() {
  let inviteMembersModal;
 
  return () => {
    if (!inviteMembersModal) {
      // https://gitlab.com/gitlab-org/gitlab/-/issues/344955
      // bug lying in wait here for someone to put group and project invite in same screen
      // once that happens we'll need to mount these differently, perhaps split
      // group/project to each mount one, with many ways to open it.
      const el = document.querySelector('.js-invite-members-modal');
 
      if (!el) {
        return false;
      }
 
      inviteMembersModal = new Vue({
        el,
        name: 'InviteMembersModalRoot',
        provide: {
          name: el.dataset.name,
        },
        render: (createElement) =>
          createElement(InviteMembersModal, {
            props: {
              ...el.dataset,
              isProject: parseBoolean(el.dataset.isProject),
              accessLevels: JSON.parse(el.dataset.accessLevels),
              defaultAccessLevel: parseInt(el.dataset.defaultAccessLevel, 10),
              usersFilter: el.dataset.usersFilter,
              filterId: parseInt(el.dataset.filterId, 10),
              usersLimitDataset: convertObjectPropsToCamelCase(
                JSON.parse(el.dataset.usersLimitDataset || '{}'),
              ),
              activeTrialDataset: convertObjectPropsToCamelCase(
                JSON.parse(el.dataset.activeTrialDataset || '{}'),
              ),
              reloadPageOnSubmit: parseBoolean(el.dataset.reloadPageOnSubmit),
            },
          }),
      });
    }
    return inviteMembersModal;
  };
})();