Commit 03ef2912 authored by Peter Hegman's avatar Peter Hegman

Merge branch '342626-move-pages-js' into 'master'

Move JS code out of pages directory

See merge request gitlab-org/gitlab!72189
parents 0c153c03 b485f5d4
import Vue from 'vue'; import { initNewProjectCreation, initNewProjectUrlSelect } from '~/projects/new';
import VueApollo from 'vue-apollo'; import initProjectVisibilitySelector from '~/project_visibility';
import createDefaultClient from '~/lib/graphql'; import initProjectNew from '~/projects/project_new';
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),
}),
);
}
initProjectVisibilitySelector(); initProjectVisibilitySelector();
initProjectNew.bindEvents(); 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 $ from 'jquery';
import { Rails } from '~/lib/utils/rails_ujs'; 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'; import projectNew from '~/projects/project_new';
const bindEvents = () => { const bindEvents = () => {
......
...@@ -5,7 +5,7 @@ module QA ...@@ -5,7 +5,7 @@ module QA
module Project module Project
module Import module Import
class RepoByURL < Page::Base 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
element :select_namespace_dropdown_search_field element :select_namespace_dropdown_search_field
end end
......
...@@ -26,7 +26,7 @@ module QA ...@@ -26,7 +26,7 @@ module QA
element :template_option_row element :template_option_row
end 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
element :select_namespace_dropdown_search_field element :select_namespace_dropdown_search_field
end end
......
import { shallowMount } from '@vue/test-utils'; 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'; import NewNamespacePage from '~/vue_shared/new_namespace/new_namespace_page.vue';
describe('Experimental new project creation app', () => { describe('Experimental new project creation app', () => {
......
import { GlPopover, GlFormInputGroup } from '@gitlab/ui'; import { GlPopover, GlFormInputGroup } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; 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'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
describe('New project push tip popover', () => { describe('New project push tip popover', () => {
......
...@@ -10,9 +10,9 @@ import VueApollo from 'vue-apollo'; ...@@ -10,9 +10,9 @@ import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import eventHub from '~/pages/projects/new/event_hub'; import eventHub from '~/projects/new/event_hub';
import NewProjectUrlSelect from '~/pages/projects/new/components/new_project_url_select.vue'; import NewProjectUrlSelect from '~/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 searchQuery from '~/projects/new/queries/search_namespaces_where_user_can_create_projects.query.graphql';
describe('NewProjectUrlSelect component', () => { describe('NewProjectUrlSelect component', () => {
let wrapper; 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