2022-07-23 23:45:48 +05:30
|
|
|
import Vue from 'vue';
|
2022-08-27 11:52:29 +05:30
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
2022-07-23 23:45:48 +05:30
|
|
|
import { parseRailsFormFields } from '~/lib/utils/forms';
|
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
|
|
|
import GroupNameAndPath from './components/group_name_and_path.vue';
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
Vue.use(VueApollo);
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
export const initGroupNameAndPath = () => {
|
|
|
|
const elements = document.querySelectorAll('.js-group-name-and-path');
|
|
|
|
|
|
|
|
if (!elements.length) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
elements.forEach((element) => {
|
|
|
|
const fields = parseRailsFormFields(element);
|
2022-08-27 11:52:29 +05:30
|
|
|
const { basePath, newSubgroup, mattermostEnabled } = element.dataset;
|
2022-07-23 23:45:48 +05:30
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el: element,
|
2022-08-27 11:52:29 +05:30
|
|
|
apolloProvider: new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(),
|
|
|
|
}),
|
2022-07-23 23:45:48 +05:30
|
|
|
provide: {
|
|
|
|
fields,
|
|
|
|
basePath,
|
2022-08-27 11:52:29 +05:30
|
|
|
newSubgroup: parseBoolean(newSubgroup),
|
2022-07-23 23:45:48 +05:30
|
|
|
mattermostEnabled: parseBoolean(mattermostEnabled),
|
|
|
|
},
|
|
|
|
render(h) {
|
|
|
|
return h(GroupNameAndPath);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|