Commit b485f5d4 authored by Coung Ngo's avatar Coung Ngo

Move JS code out of pages directory

parent 94aeceba
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
import { parseBoolean } from '~/lib/utils/common_utils';
import initProjectVisibilitySelector from '../../../project_visibility';
import initProjectNew from '../../../projects/project_new';
import NewProjectCreationApp from './components/app.vue';
import NewProjectUrlSelect from './components/new_project_url_select.vue';
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 });
},
});
}
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({
defaultClient: createDefaultClient({}, { assumeImmutableResults: true }),
}),
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),
}),
);
}
import { initNewProjectCreation, initNewProjectUrlSelect } from '~/projects/new';
import initProjectVisibilitySelector from '~/project_visibility';
import initProjectNew from '~/projects/project_new';
initProjectVisibilitySelector();
initProjectNew.bindEvents();
......
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({
defaultClient: createDefaultClient({}, { assumeImmutableResults: true }),
}),
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),
}),
);
}
import $ from 'jquery';
import { Rails } from '~/lib/utils/rails_ujs';
import eventHub from '~/pages/projects/new/event_hub';
import eventHub from '~/projects/new/event_hub';
import projectNew from '~/projects/project_new';
const bindEvents = () => {
......
......@@ -5,7 +5,7 @@ module QA
module Project
module Import
class RepoByURL < Page::Base
view 'app/assets/javascripts/pages/projects/new/components/new_project_url_select.vue' do
view 'app/assets/javascripts/projects/new/components/new_project_url_select.vue' do
element :select_namespace_dropdown
element :select_namespace_dropdown_search_field
end
......
......@@ -26,7 +26,7 @@ module QA
element :template_option_row
end
view 'app/assets/javascripts/pages/projects/new/components/new_project_url_select.vue' do
view 'app/assets/javascripts/projects/new/components/new_project_url_select.vue' do
element :select_namespace_dropdown
element :select_namespace_dropdown_search_field
end
......
import { shallowMount } from '@vue/test-utils';
import App from '~/pages/projects/new/components/app.vue';
import App from '~/projects/new/components/app.vue';
import NewNamespacePage from '~/vue_shared/new_namespace/new_namespace_page.vue';
describe('Experimental new project creation app', () => {
......
import { GlPopover, GlFormInputGroup } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import NewProjectPushTipPopover from '~/pages/projects/new/components/new_project_push_tip_popover.vue';
import NewProjectPushTipPopover from '~/projects/new/components/new_project_push_tip_popover.vue';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
describe('New project push tip popover', () => {
......
......@@ -10,9 +10,9 @@ import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper';
import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import eventHub from '~/pages/projects/new/event_hub';
import NewProjectUrlSelect from '~/pages/projects/new/components/new_project_url_select.vue';
import searchQuery from '~/pages/projects/new/queries/search_namespaces_where_user_can_create_projects.query.graphql';
import eventHub from '~/projects/new/event_hub';
import NewProjectUrlSelect from '~/projects/new/components/new_project_url_select.vue';
import searchQuery from '~/projects/new/queries/search_namespaces_where_user_can_create_projects.query.graphql';
describe('NewProjectUrlSelect component', () => {
let wrapper;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment