Skip to content
Snippets Groups Projects
Commit ed1d8d7c authored by Doug Stull's avatar Doug Stull 2️⃣
Browse files

Merge branch '372454-rename-groups-projects-controller' into 'master'

Rename GroupProjectsController file

See merge request !119772



Merged-by: Doug Stull's avatarDoug Stull <dstull@gitlab.com>
Approved-by: default avatarGregory Havenga <11164960-ghavenga@users.noreply.gitlab.com>
Approved-by: default avatarMinahil Nichols <minahilnichols@gitlab.com>
Approved-by: Doug Stull's avatarDoug Stull <dstull@gitlab.com>
Reviewed-by: Doug Stull's avatarDoug Stull <dstull@gitlab.com>
Reviewed-by: default avatarMehmet Emin INAC <minac@gitlab.com>
Co-authored-by: default avatarsyarynovskyi <syarynovskyi@gitlab.com>
parents 0a7464ee 9fc722d9
No related branches found
No related tags found
1 merge request!119772Rename GroupProjectsController file
Pipeline #878598813 failed
Showing
with 108 additions and 83 deletions
......@@ -1359,7 +1359,6 @@ Layout/ArgumentAlignment:
- 'ee/spec/requests/groups/protected_environments_controller_spec.rb'
- 'ee/spec/requests/groups/settings/domain_verification_controller_spec.rb'
- 'ee/spec/requests/groups/two_factor_auths_controller_spec.rb'
- 'ee/spec/requests/registrations/project_creation_spec.rb'
- 'ee/spec/requests/smartcard_controller_spec.rb'
- 'ee/spec/requests/users/identity_verification_controller_spec.rb'
- 'ee/spec/services/analytics/cycle_analytics/aggregator_service_spec.rb'
......
......@@ -224,7 +224,7 @@ RSpec/FactoryBot/AvoidCreate:
- 'ee/spec/views/projects/security/policies/index.html.haml_spec.rb'
- 'ee/spec/views/projects/security/sast_configuration/show.html.haml_spec.rb'
- 'ee/spec/views/projects/settings/subscriptions/_index.html.haml_spec.rb'
- 'ee/spec/views/registrations/groups_projects/new.html.haml_spec.rb'
- 'ee/spec/views/registrations/groups/new.html.haml_spec.rb'
- 'ee/spec/views/shared/_clone_panel.html.haml_spec.rb'
- 'ee/spec/views/shared/_kerberos_clone_button.html.haml_spec.rb'
- 'ee/spec/views/shared/_mirror_status.html.haml_spec.rb'
......
......@@ -1573,7 +1573,6 @@ RSpec/MissingFeatureCategory:
- 'ee/spec/views/projects/security/sast_configuration/show.html.haml_spec.rb'
- 'ee/spec/views/projects/settings/merge_requests/_merge_request_approvals.html.haml_spec.rb'
- 'ee/spec/views/projects/settings/subscriptions/_index.html.haml_spec.rb'
- 'ee/spec/views/registrations/groups_projects/new.html.haml_spec.rb'
- 'ee/spec/views/shared/_clone_panel.html.haml_spec.rb'
- 'ee/spec/views/shared/_kerberos_clone_button.html.haml_spec.rb'
- 'ee/spec/views/shared/_mirror_status.html.haml_spec.rb'
......
......@@ -66,7 +66,12 @@
Gitlab.ee do
resource :company, only: [:new, :create], controller: 'company'
resources :groups_projects, only: [:new, :create] do
# TODO: remove next line and the controller after the deployment
# https://gitlab.com/gitlab-org/gitlab/-/issues/411208
resources :groups_projects, only: [:create] do
post :import, on: :collection
end
resources :groups, only: [:new, :create] do
post :import, on: :collection
end
draw :verification
......
import mountComponents from 'ee/registrations/groups_projects/new';
import mountComponents from 'ee/registrations/groups/new';
import Group from '~/group';
import { trackCombinedGroupProjectForm, trackProjectImport } from '~/google_tag_manager';
......
/* eslint-disable no-new */
import mountComponents from 'ee/registrations/groups_projects/new';
import mountComponents from 'ee/registrations/groups/new';
import Group from '~/group';
import { trackCombinedGroupProjectForm, trackProjectImport } from '~/google_tag_manager';
......
......@@ -64,7 +64,7 @@ def signup_onboarding_path
save_onboarding_step_url(path, current_user)
path
else
path = new_users_sign_up_groups_project_path
path = new_users_sign_up_group_path
save_onboarding_step_url(path, current_user)
path
end
......
......@@ -31,7 +31,7 @@ def create
label: tracking_label)
end
path = new_users_sign_up_groups_project_path(redirect_params)
path = new_users_sign_up_group_path(redirect_params)
save_onboarding_step_url(path, current_user)
redirect_to path
else
......
# frozen_string_literal: true
module Registrations
class GroupsController < ApplicationController
include OneTrustCSP
include GoogleAnalyticsCSP
include Onboarding::SetRedirect
skip_before_action :set_confirm_warning
before_action :check_if_gl_com_or_dev
before_action :authorize_create_group!, only: :new
before_action only: [:new] do
push_frontend_feature_flag(:gitlab_gtm_datalayer, type: :ops)
end
layout 'minimal'
feature_category :onboarding
urgency :low, [:create, :import]
def new
@group = Group.new(visibility_level: Gitlab::CurrentSettings.default_group_visibility)
@project = Project.new(namespace: @group)
track_event('view_new_group_action')
end
def create
result = Registrations::StandardNamespaceCreateService.new(current_user, params).execute
if result.success?
track_event('successfully_submitted_form')
finish_onboarding(current_user)
redirect_successful_namespace_creation(result.payload[:project])
else
@group = result.payload[:group]
@project = result.payload[:project]
render :new
end
end
def import
result = Registrations::ImportNamespaceCreateService.new(current_user, params).execute
if result.success?
finish_onboarding(current_user)
import_url = URI.join(root_url, params[:import_url], "?namespace_id=#{result.payload[:group].id}").to_s
redirect_to import_url
else
@group = result.payload[:group]
@project = result.payload[:project]
render :new
end
end
private
def authorize_create_group!
access_denied! unless can?(current_user, :create_group)
end
def redirect_successful_namespace_creation(project)
redirect_path = onboarding_project_learn_gitlab_path(project,
trial_onboarding_flow: params[:trial_onboarding_flow]
)
experiment(:registration_verification, user: current_user) do |e|
e.control { redirect_to redirect_path }
e.candidate do
store_location_for(:user, redirect_path)
redirect_to new_users_sign_up_verification_path(project_id: project.id)
end
end
end
def track_event(action)
::Gitlab::Tracking.event(self.class.name, action, user: current_user, label: helpers.onboarding_track_label)
end
end
end
# frozen_string_literal: true
# TODO: remove after the deployment
# https://gitlab.com/gitlab-org/gitlab/-/issues/411208
module Registrations
class GroupsProjectsController < ApplicationController
include OneTrustCSP
include GoogleAnalyticsCSP
include Onboarding::SetRedirect
skip_before_action :set_confirm_warning
before_action :check_if_gl_com_or_dev
before_action :authorize_create_group!, only: :new
before_action only: [:new] do
push_frontend_feature_flag(:gitlab_gtm_datalayer, type: :ops)
end
layout 'minimal'
feature_category :onboarding
urgency :low, [:create, :import]
def new
@group = Group.new(visibility_level: Gitlab::CurrentSettings.default_group_visibility)
@project = Project.new(namespace: @group)
track_event('view_new_group_action')
end
# redirect post requests for stale pages during release of new code/routes
def create
result = Registrations::StandardNamespaceCreateService.new(current_user, params).execute
if result.success?
track_event('successfully_submitted_form')
finish_onboarding(current_user)
redirect_successful_namespace_creation(result.payload[:project])
else
@group = result.payload[:group]
@project = result.payload[:project]
render :new
end
redirect_to new_users_sign_up_group_path(permitted_params)
end
def import
result = Registrations::ImportNamespaceCreateService.new(current_user, params).execute
if result.success?
finish_onboarding(current_user)
import_url = URI.join(root_url, params[:import_url], "?namespace_id=#{result.payload[:group].id}").to_s
redirect_to import_url
else
@group = result.payload[:group]
@project = result.payload[:project]
render :new
end
redirect_to new_users_sign_up_group_path
end
private
def authorize_create_group!
access_denied! unless can?(current_user, :create_group)
end
def redirect_successful_namespace_creation(project)
redirect_path = onboarding_project_learn_gitlab_path(project,
trial_onboarding_flow: params[:trial_onboarding_flow]
)
experiment(:registration_verification, user: current_user) do |e|
e.control { redirect_to redirect_path }
e.candidate do
store_location_for(:user, redirect_path)
redirect_to new_users_sign_up_verification_path(project_id: project.id)
end
end
end
def track_event(action)
::Gitlab::Tracking.event(self.class.name, action, user: current_user, label: helpers.onboarding_track_label)
def permitted_params
params.permit(:trial_onboarding_flow, :glm_source, :glm_content, :trial)
end
end
end
Registrations::GroupsProjectsController.prepend_mod
......@@ -26,7 +26,7 @@
.tab-content.gitlab-tab-content.gl-bg-white.js-group-project-tab-contents
#blank-project-pane.tab-pane.js-toggle-container.active{ role: 'tabpanel' }
= form_tag users_sign_up_groups_projects_path(form_params), class: 'gl-show-field-errors gl-w-full gl-p-4 js-groups-projects-form' do
= form_tag users_sign_up_groups_path(form_params), class: 'gl-show-field-errors gl-w-full gl-p-4 js-groups-projects-form' do
= form_errors(@group, type: "Group")
= form_errors(@project, type: "Project")
= render 'layouts/flash'
......@@ -48,7 +48,7 @@
#import-project-pane.tab-pane.import-project-pane.js-toggle-container{ role: 'tabpanel' }
- if import_sources_enabled?
= form_tag import_users_sign_up_groups_projects_path, class: 'gl-show-field-errors gl-w-full gl-p-4 js-import-project-form' do
= form_tag import_users_sign_up_groups_path, class: 'gl-show-field-errors gl-w-full gl-p-4 js-import-project-form' do
= form_errors(@group, type: "Group")
= render 'layouts/flash'
......
......@@ -244,7 +244,7 @@
specify do
patch_update
user.reload
path = new_users_sign_up_groups_project_path
path = new_users_sign_up_group_path
expect(user.onboarding_in_progress).to be_truthy
expect(user.user_detail.onboarding_step_url).to eq(path)
......@@ -282,7 +282,7 @@
specify do
patch_update
user.reload
path = new_users_sign_up_groups_project_path
path = new_users_sign_up_group_path
expect(user.onboarding_in_progress).to be_truthy
expect(user.user_detail.onboarding_step_url).to eq(path)
......@@ -319,7 +319,7 @@
allow(controller.helpers).to receive(:in_subscription_flow?).and_return(true)
end
it { is_expected.not_to redirect_to new_users_sign_up_groups_project_path }
it { is_expected.not_to redirect_to new_users_sign_up_group_path }
end
context 'when in invitation flow' do
......@@ -327,7 +327,7 @@
allow(controller.helpers).to receive(:user_has_memberships?).and_return(true)
end
it { is_expected.not_to redirect_to new_users_sign_up_groups_project_path }
it { is_expected.not_to redirect_to new_users_sign_up_group_path }
it 'tracks successful submission event' do
patch_update
......@@ -344,7 +344,7 @@
context 'when in trial flow' do
let(:extra_params) { { trial: 'true' } }
it { is_expected.not_to redirect_to new_users_sign_up_groups_project_path }
it { is_expected.not_to redirect_to new_users_sign_up_group_path }
it 'tracks successful submission event' do
patch_update
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment