diff --git a/app/assets/javascripts/projects/new_v2/components/app.vue b/app/assets/javascripts/projects/new_v2/components/app.vue index 3a9a386d1084ea20966668d579bb5a9ffd98428a..6ee636d86bf5e033917ecc1db4ce5b7a40da467a 100644 --- a/app/assets/javascripts/projects/new_v2/components/app.vue +++ b/app/assets/javascripts/projects/new_v2/components/app.vue @@ -76,9 +76,9 @@ export default { data() { return { namespace: { - id: this.namespaceId, - fullPath: this.namespaceFullPath, - isPersonal: this.namespaceId === '', + id: this.namespaceId ? this.namespaceId : this.userNamespaceId, + fullPath: this.namespaceFullPath ? this.namespaceFullPath : this.userNamespaceFullPath, + isPersonal: this.namespaceId ? this.userNamespaceId === this.namespaceId : true, }, selectedProjectType: OPTIONS.blank.value, currentStep: 1, 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 3378b253374b320e3721f559578f2afc5cf379b6..3d37ba7c9177a1692bc70ce50e3e33220360cda8 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,5 +1,6 @@ diff --git a/app/assets/javascripts/projects/new_v2/components/project_name_validator.vue b/app/assets/javascripts/projects/new_v2/components/project_name_validator.vue new file mode 100644 index 0000000000000000000000000000000000000000..064c339963291054909911c990ef6089d78cd681 --- /dev/null +++ b/app/assets/javascripts/projects/new_v2/components/project_name_validator.vue @@ -0,0 +1,92 @@ + + + diff --git a/app/assets/javascripts/projects/new_v2/components/shared_project_creation_fields.vue b/app/assets/javascripts/projects/new_v2/components/shared_project_creation_fields.vue index ceda513e33ead0bec55b05f47c9ac4a40c4760e6..83a216c12c2b225e10c43d7c5e29b9862ebcfcbc 100644 --- a/app/assets/javascripts/projects/new_v2/components/shared_project_creation_fields.vue +++ b/app/assets/javascripts/projects/new_v2/components/shared_project_creation_fields.vue @@ -13,11 +13,11 @@ import { VISIBILITY_LEVEL_PUBLIC_STRING, VISIBILITY_TYPE_ICON, PROJECT_VISIBILITY_LEVEL_DESCRIPTIONS, - VISIBILITY_LEVELS_INTEGER_TO_STRING, VISIBILITY_LEVELS_STRING_TO_INTEGER, } from '~/visibility_level/constants'; import { K8S_OPTION, DEPLOYMENT_TARGET_SELECTIONS } from '../form_constants'; import NewProjectDestinationSelect from './project_destination_select.vue'; +import ProjectNameValidator from './project_name_validator.vue'; export default { components: { @@ -28,6 +28,7 @@ export default { GlLink, GlIcon, NewProjectDestinationSelect, + ProjectNameValidator, SingleChoiceSelector, SingleChoiceSelectorItem, }, @@ -67,9 +68,6 @@ export default { isK8sOptionSelected() { return this.selectedTarget === K8S_OPTION.value; }, - defaultVisibilityLevel() { - return VISIBILITY_LEVELS_INTEGER_TO_STRING[this.defaultProjectVisibility]; - }, }, mounted() { this.setVisibilityLevelsOptions(); @@ -98,7 +96,8 @@ export default { 'VisibilityLevel|This visibility level has been restricted by your administrator.', ); } else if ( - visibilityLevelInteger > VISIBILITY_LEVELS_STRING_TO_INTEGER[this.namespace.visibility] + visibilityLevelInteger > + VISIBILITY_LEVELS_STRING_TO_INTEGER[this.selectedNamespace.visibility] ) { disableMessage = s__( 'VisibilityLevel|This visibility level is not allowed because the parent group has a more restrictive visibility level.', @@ -109,12 +108,16 @@ export default { title: VISIBILITY_LEVEL_LABELS[visibilityLevelString], description: PROJECT_VISIBILITY_LEVEL_DESCRIPTIONS[visibilityLevelString], icon: VISIBILITY_TYPE_ICON[visibilityLevelString], - value: visibilityLevelString, + value: String(visibilityLevelInteger), + name: visibilityLevelString, disabled: disableMessage !== '', disabledMessage: disableMessage, id: 1, }; }, + updateProjectNameValidationStatus(status) { + this.$emit('onValidateForm', status && this.form.state); + }, }, helpPageK8s: helpPagePath('user/clusters/agent/_index'), DEPLOYMENT_TARGET_SELECTIONS, @@ -194,6 +197,13 @@ export default { + + - + {{ title }} diff --git a/app/assets/javascripts/projects/new_v2/index.js b/app/assets/javascripts/projects/new_v2/index.js index 0238f3190731102396137b605856906e92de8096..4cbd724ad531c4eb8a739ed735b6ac77aaec86ce 100644 --- a/app/assets/javascripts/projects/new_v2/index.js +++ b/app/assets/javascripts/projects/new_v2/index.js @@ -51,6 +51,7 @@ export function initNewProjectForm() { importManifestEnabled, importManifestImportPath, importByUrlValidatePath, + formPath, } = el.dataset; const provide = { @@ -93,6 +94,7 @@ export function initNewProjectForm() { importManifestEnabled: parseBoolean(importManifestEnabled), importManifestImportPath, importByUrlValidatePath, + formPath, }; return new Vue({ diff --git a/app/assets/javascripts/projects/new_v2/queries/search_project_name_availability.query.graphql b/app/assets/javascripts/projects/new_v2/queries/search_project_name_availability.query.graphql new file mode 100644 index 0000000000000000000000000000000000000000..7e3ef5f326702b3e5592efe815daad39a6b1adaf --- /dev/null +++ b/app/assets/javascripts/projects/new_v2/queries/search_project_name_availability.query.graphql @@ -0,0 +1,12 @@ +query searchProjectNameAvailability($namespacePath: ID!, $search: String) { + namespace(fullPath: $namespacePath) { + id + projects(search: $search) { + nodes { + id + path + name + } + } + } +} diff --git a/app/assets/javascripts/vue_shared/components/single_choice_selector.vue b/app/assets/javascripts/vue_shared/components/single_choice_selector.vue index 9d7716a794c20276b577edcd4fd62552bf2f7b9d..062417c8483d5e2ffc2a9863b9ffa35bab838591 100644 --- a/app/assets/javascripts/vue_shared/components/single_choice_selector.vue +++ b/app/assets/javascripts/vue_shared/components/single_choice_selector.vue @@ -9,6 +9,11 @@ export default { required: false, default: undefined, }, + name: { + type: String, + required: false, + default: undefined, + }, }, methods: { onChange(value) { @@ -21,6 +26,7 @@ export default {