Welcome to mirror list, hosted at ThFree Co, Russian Federation.

init_transfer_group_form.js « groups « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f055b9269184ee897adf2c5d183f9e1fa93a6629 (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
52
import Vue from 'vue';
import { sprintf } from '~/locale';
import { parseBoolean } from '~/lib/utils/common_utils';
import TransferGroupForm, { i18n } from './components/transfer_group_form.vue';

const prepareGroups = (rawGroups) => {
  if (!rawGroups) {
    return [];
  }

  return JSON.parse(rawGroups).map(({ id, text: humanName }) => ({
    id,
    humanName,
  }));
};

export default () => {
  const el = document.querySelector('.js-transfer-group-form');
  if (!el) {
    return false;
  }

  const {
    targetFormId = null,
    buttonText: confirmButtonText = '',
    groupName = '',
    parentGroups,
    isPaidGroup,
  } = el.dataset;

  return new Vue({
    el,
    provide: {
      confirmDangerMessage: sprintf(i18n.confirmationMessage, { group_name: groupName }),
    },
    render(createElement) {
      return createElement(TransferGroupForm, {
        props: {
          groupNamespaces: prepareGroups(parentGroups),
          isPaidGroup: parseBoolean(isPaidGroup),
          confirmButtonText,
          confirmationPhrase: groupName,
        },
        on: {
          confirm: () => {
            document.getElementById(targetFormId)?.submit();
          },
        },
      });
    },
  });
};