diff --git a/app/assets/javascripts/projects/new_v2/components/app.vue b/app/assets/javascripts/projects/new_v2/components/app.vue index f851a37f1dcfb709705570fc02fd69899e2f614f..86aaa3d75ac0ff02dd5dd24b38553ef409494c45 100644 --- a/app/assets/javascripts/projects/new_v2/components/app.vue +++ b/app/assets/javascripts/projects/new_v2/components/app.vue @@ -42,6 +42,9 @@ export default { userNamespaceId: { default: null, }, + userNamespaceFullPath: { + default: null, + }, isCiCdAvailable: { default: false, }, @@ -61,7 +64,7 @@ export default { default: null, }, namespaceId: { - default: null, + default: '', }, trackLabel: { default: null, @@ -72,23 +75,30 @@ export default { newProjectGuidelines: { default: null, }, + visibilityLevel: { + default: null, + }, }, data() { return { - selectedNamespace: - this.namespaceId && this.canSelectNamespace ? this.namespaceId : this.userNamespaceId, + rootUrl: this.rootPath, + namespace: { + id: this.namespaceId && this.canSelectNamespace ? this.namespaceId : this.userNamespaceId, + visibility: this.visibilityLevel, + fullPath: + this.namespaceFullPath && this.canSelectNamespace + ? this.namespaceFullPath + : this.userNamespaceFullPath, + isPersonal: this.namespaceId === '', + }, selectedProjectType: OPTIONS.blank.value, currentStep: 1, - rootUrl: this.rootPath, }; }, computed: { - isPersonalProject() { - return this.selectedNamespace === this.userNamespaceId; - }, canChooseOption() { - if (!this.isPersonalProject) return true; + if (!this.namespace.isPersonal) return true; return this.canCreateProject && this.userProjectLimit > 0; }, errorMessage() { @@ -131,11 +141,18 @@ export default { }, methods: { - choosePersonalNamespace() { - this.selectedNamespace = this.userNamespaceId; - }, - chooseGroupNamespace() { - this.selectedNamespace = null; + onSelectNamespaceType(isPersonal) { + if (isPersonal) { + this.namespace.id = this.userNamespaceId; + this.namespace.visibility = this.visibilityLevel; + this.namespace.fullPath = this.userNamespaceFullPath; + this.namespace.isPersonal = true; + } else { + this.namespace.id = this.namespaceId || null; + this.namespace.visibility = this.namespaceId !== null ? this.visibilityLevel : null; + this.namespace.fullPath = this.namespaceFullPath; + this.namespace.isPersonal = false; + } }, selectProjectType(value) { this.selectedProjectType = value; @@ -145,9 +162,16 @@ export default { setLocationHash(); }, onNext() { + if (this.namespace.id === null) return; + this.currentStep += 1; setLocationHash(this.selectedProjectType); }, + onSelectNamespace(newNamespace) { + this.namespace.id = newNamespace.id; + this.namespace.visibility = newNamespace.visibility; + this.namespace.fullPath = newNamespace.fullPath; + }, setStepFromLocationHash() { const hash = getLocationHash(); if (this.availableProjectTypes.some((type) => type.value === hash)) { @@ -178,10 +202,10 @@ export default { category="primary" variant="default" size="medium" - :selected="isPersonalProject" + :selected="namespace.isPersonal" class="gl-w-full" data-testid="personal-namespace-button" - @click="choosePersonalNamespace" + @click="onSelectNamespaceType(true)" > {{ s__('ProjectsNew|A personal project') }} @@ -189,24 +213,32 @@ export default { category="primary" variant="default" size="medium" - :selected="!isPersonalProject" + :selected="!namespace.isPersonal" class="gl-w-full" data-testid="group-namespace-button" - @click="chooseGroupNamespace" + @click="onSelectNamespaceType(false)" > {{ s__('ProjectsNew|A project within a group') }} - + @@ -242,7 +274,7 @@ export default { @@ -251,7 +283,7 @@ export default { v-if="currentStep === 2" :key="selectedProjectOption.key" :option="selectedProjectOption" - :namespace-id="selectedNamespace" + :namespace="namespace" data-testid="new-project-step2" @back="onBack" @next="onNext" diff --git a/app/assets/javascripts/projects/new_v2/components/blank_project_form.vue b/app/assets/javascripts/projects/new_v2/components/blank_project_form.vue index 8b67a233b2f96a95f55060f4200b314bead58640..eba77e93d1298c876474269a470d340387bf78e5 100644 --- a/app/assets/javascripts/projects/new_v2/components/blank_project_form.vue +++ b/app/assets/javascripts/projects/new_v2/components/blank_project_form.vue @@ -1,11 +1,72 @@ diff --git a/app/assets/javascripts/projects/new_v2/components/import_project_form.vue b/app/assets/javascripts/projects/new_v2/components/import_project_form.vue index 3824ab085f47c80d92d09dc9fcaef0731a9e81c7..441cc4a88017f73e8c35214e766001c122f5fa9a 100644 --- a/app/assets/javascripts/projects/new_v2/components/import_project_form.vue +++ b/app/assets/javascripts/projects/new_v2/components/import_project_form.vue @@ -73,10 +73,10 @@ export default { required: false, default: () => ({}), }, - namespaceId: { - type: String, + namespace: { + type: Object, required: false, - default: null, + default: () => ({}), }, }, data() { @@ -89,8 +89,8 @@ export default { return [ { isAvailable: this.importGitlabEnabled, - path: this.namespaceId - ? `${this.importGitlabImportPath}?namespace_id=${this.namespaceId}` + path: this.namespace.id + ? `${this.importGitlabImportPath}?namespace_id=${this.namespace.id}` : this.importGitlabImportPath, icon: 'tanuki', title: s__('ProjectImport|GitLab'), diff --git a/app/assets/javascripts/projects/new_v2/components/project_destination_select.vue b/app/assets/javascripts/projects/new_v2/components/project_destination_select.vue index 7675e1c9ed3facb5f7f3e43d779703765029a5ea..8b93ce1812ab73ebd46d95ce146bad469f3b59e8 100644 --- a/app/assets/javascripts/projects/new_v2/components/project_destination_select.vue +++ b/app/assets/javascripts/projects/new_v2/components/project_destination_select.vue @@ -1,13 +1,13 @@