debian-mirror-gitlab/app/assets/javascripts/projects/new/index.js

67 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-11-18 22:05:49 +05:30
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
import { parseBoolean } from '~/lib/utils/common_utils';
import NewProjectCreationApp from './components/app.vue';
import NewProjectUrlSelect from './components/new_project_url_select.vue';
export function initNewProjectCreation() {
const el = document.querySelector('.js-new-project-creation');
const {
pushToCreateProjectCommand,
workingWithProjectsHelpPath,
newProjectGuidelines,
hasErrors,
isCiCdAvailable,
} = el.dataset;
const props = {
hasErrors: parseBoolean(hasErrors),
isCiCdAvailable: parseBoolean(isCiCdAvailable),
newProjectGuidelines,
};
const provide = {
workingWithProjectsHelpPath,
pushToCreateProjectCommand,
};
return new Vue({
el,
provide,
render(h) {
return h(NewProjectCreationApp, { props });
},
});
}
export function initNewProjectUrlSelect() {
const elements = document.querySelectorAll('.js-vue-new-project-url-select');
if (!elements.length) {
return;
}
Vue.use(VueApollo);
elements.forEach(
(el) =>
new Vue({
el,
apolloProvider: new VueApollo({
2021-12-11 22:18:48 +05:30
defaultClient: createDefaultClient(),
2021-11-18 22:05:49 +05:30
}),
provide: {
namespaceFullPath: el.dataset.namespaceFullPath,
namespaceId: el.dataset.namespaceId,
rootUrl: el.dataset.rootUrl,
trackLabel: el.dataset.trackLabel,
userNamespaceFullPath: el.dataset.userNamespaceFullPath,
userNamespaceId: el.dataset.userNamespaceId,
},
render: (createElement) => createElement(NewProjectUrlSelect),
}),
);
}