From 0e044efe6b2fa2e2a609ca24a5291bd258653f75 Mon Sep 17 00:00:00 2001 From: david hamp-gonsalves Date: Tue, 1 Jul 2025 08:05:23 -0300 Subject: [PATCH 1/2] Surface group and project model validations fixes https://gitlab.com/gitlab-org/gitlab/-/issues/538417 EE: true --- config/routes.rb | 2 +- .../components/create_trial_welcome_form.vue | 80 ++++-- .../trials/welcome/trial_form_component.rb | 22 +- .../registrations/trial_welcome_controller.rb | 36 +++ .../trials/welcome_create_service.rb | 10 +- .../welcome/trial_form_component_spec.rb | 266 +++++++++++++++++- .../create_trial_welcome_form_spec.js | 46 ++- .../trial_welcome_controller_spec.rb | 132 ++++++++- .../trials/welcome_create_service_spec.rb | 4 +- 9 files changed, 546 insertions(+), 52 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index f5e255e810cd50..5b6105b6527a1e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -62,7 +62,7 @@ scope path: '/users/sign_up', module: :registrations, as: :users_sign_up do Gitlab.ee do resource :welcome, only: [:show, :update], controller: 'welcome' - resource :trial_welcome, only: [:new], controller: 'trial_welcome' + resource :trial_welcome, only: [:new, :create], controller: 'trial_welcome' resource :company, only: [:new, :create], controller: 'company' resources :groups, only: [:new, :create] end diff --git a/ee/app/assets/javascripts/trials/components/create_trial_welcome_form.vue b/ee/app/assets/javascripts/trials/components/create_trial_welcome_form.vue index 9777744f409387..7c049bae41ad30 100644 --- a/ee/app/assets/javascripts/trials/components/create_trial_welcome_form.vue +++ b/ee/app/assets/javascripts/trials/components/create_trial_welcome_form.vue @@ -58,20 +58,22 @@ export default { type: String, required: true, }, + namespaceId: { + type: Number, + required: false, + default: () => null, + }, + serverValidations: { + type: Object, + required: false, + default: () => ({}), + }, }, data() { return { - formValues: { - first_name: this.userData.firstName, - last_name: this.userData.lastName, - company_name: this.userData.companyName, - country: this.userData.country, - state: this.userData.state, - group_name: '', - project_name: '', - }, countries: [], states: [], + formValues: {}, }; }, computed: { @@ -162,17 +164,19 @@ export default { } } + let groupNameValidators = []; + if (this.namespaceId === null) + groupNameValidators = [formValidators.required(__('Group name is required.'))]; + result.group_name = { label: ' ', groupAttrs: { class: 'gl-col-span-12', }, inputAttrs: { - name: 'group_name', - 'data-testid': 'group-name-input', - placeholder: __('You use groups to organize your projects'), + disabled: this.namespaceId !== null, }, - validators: [formValidators.required(__('Group name is required.'))], + validators: groupNameValidators, }; result.project_name = { @@ -180,14 +184,15 @@ export default { groupAttrs: { class: 'gl-col-span-12', }, - inputAttrs: { - name: 'project_name', - 'data-testid': 'project-name-input', - placeholder: __('Projects contain the resources for your repository'), - }, validators: [formValidators.required(__('Project name is required.'))], }; + result.namespace_id = { + groupAttrs: { + class: 'gl-hidden', + }, + }; + return result; }, }, @@ -196,6 +201,18 @@ export default { this.resetSelectedState(); }, }, + mounted() { + this.formValues = { + first_name: this.userData.firstName, + last_name: this.userData.lastName, + company_name: this.userData.companyName, + country: this.userData.country, + state: this.userData.state, + group_name: this.userData.groupName || '', + project_name: this.userData.projectName || '', + namespace_id: this.namespaceId, + }; + }, methods: { onSubmit() { trackSaasTrialLeadSubmit(this.gtmSubmitEventLabel, this.userData.emailDomain); @@ -266,6 +283,7 @@ export default { :form-id="$options.formId" :fields="fields" class="gl-grid md:gl-gap-x-4" + :server-validations="serverValidations" @submit="onSubmit" > -