Skip to content
Snippets Groups Projects
Commit 759bab05 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 61f0c589
No related branches found
No related tags found
No related merge requests found
Showing
with 185 additions and 49 deletions
Loading
Loading
@@ -23,7 +23,7 @@
 
.signup-heading h2 {
font-weight: $gl-font-weight-bold;
padding: 0 10px;
padding: 0 $gl-padding;
 
@include media-breakpoint-down(md) {
font-size: $gl-font-size-large;
Loading
Loading
Loading
Loading
@@ -17,7 +17,7 @@ class ApplicationController < ActionController::Base
include Gitlab::Tracking::ControllerConcern
include Gitlab::Experimentation::ControllerConcern
 
before_action :authenticate_user!
before_action :authenticate_user!, except: [:route_not_found]
before_action :enforce_terms!, if: :should_enforce_terms?
before_action :validate_user_service_ticket!
before_action :check_password_expiration
Loading
Loading
@@ -30,7 +30,7 @@ class ApplicationController < ActionController::Base
before_action :active_user_check, unless: :devise_controller?
before_action :set_usage_stats_consent_flag
before_action :check_impersonation_availability
before_action :require_role
before_action :required_signup_info
 
around_action :set_locale
around_action :set_session_storage
Loading
Loading
@@ -95,11 +95,13 @@ class ApplicationController < ActionController::Base
end
 
def route_not_found
# We need to call #authenticate_user! here because sometimes this is called from another action
# and not from our wildcard fallback route
authenticate_user!
if current_user
not_found
else
store_location_for(:user, request.fullpath) unless request.xhr?
 
not_found
redirect_to new_user_session_path, alert: I18n.t('devise.failure.unauthenticated')
end
end
 
def render(*args)
Loading
Loading
@@ -536,10 +538,13 @@ class ApplicationController < ActionController::Base
@current_user_mode ||= Gitlab::Auth::CurrentUserMode.new(current_user)
end
 
# A user requires a role when they are part of the experimental signup flow (executed by the Growth team). Users
# are redirected to the welcome page when their role is required and the experiment is enabled for the current user.
def require_role
return unless current_user && current_user.role_required? && experiment_enabled?(:signup_flow)
# A user requires a role and have the setup_for_company attribute set when they are part of the experimental signup
# flow (executed by the Growth team). Users are redirected to the welcome page when their role is required and the
# experiment is enabled for the current user.
def required_signup_info
return unless current_user
return unless current_user.role_required?
return unless experiment_enabled?(:signup_flow)
 
store_location_for :user, request.fullpath
 
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ class RegistrationsController < Devise::RegistrationsController
 
layout :choose_layout
 
skip_before_action :require_role, only: [:welcome, :update_role]
skip_before_action :required_signup_info, only: [:welcome, :update_registration]
prepend_before_action :check_captcha, only: :create
before_action :whitelist_query_limiting, only: [:destroy]
before_action :ensure_terms_accepted,
Loading
Loading
@@ -53,22 +53,22 @@ class RegistrationsController < Devise::RegistrationsController
 
def welcome
return redirect_to new_user_registration_path unless current_user
return redirect_to stored_location_or_dashboard_or_almost_there_path(current_user) if current_user.role.present?
return redirect_to stored_location_or_dashboard_or_almost_there_path(current_user) if current_user.role.present? && !current_user.setup_for_company.nil?
 
current_user.name = nil
current_user.name = nil if current_user.name == current_user.username
render layout: 'devise_experimental_separate_sign_up_flow'
end
 
def update_role
user_params = params.require(:user).permit(:name, :role)
result = ::Users::UpdateService.new(current_user, user_params.merge(user: current_user)).execute
def update_registration
user_params = params.require(:user).permit(:name, :role, :setup_for_company)
result = ::Users::SignupService.new(current_user, user_params).execute
 
if result[:status] == :success
track_experiment_event(:signup_flow, 'end') # We want this event to be tracked when the user is _in_ the experimental group
set_flash_message! :notice, :signed_up
redirect_to stored_location_or_dashboard_or_almost_there_path(current_user)
else
redirect_to users_sign_up_welcome_path, alert: result[:message]
render :welcome, layout: 'devise_experimental_separate_sign_up_flow'
end
end
 
Loading
Loading
Loading
Loading
@@ -385,6 +385,9 @@ class IssuableFinder
end
 
def count_key(value)
# value may be an array if the finder used in `count_by_state` added an
# additional `group by`. Anyway we are sure that state will be always the
# last item because it's added as the last one to the query.
value = Array(value).last
klass.available_states.key(value)
end
Loading
Loading
Loading
Loading
@@ -18,6 +18,11 @@ class LfsObject < ApplicationRecord
 
after_save :update_file_store, if: :saved_change_to_file?
 
def self.not_linked_to_project(project)
where('NOT EXISTS (?)',
project.lfs_objects_projects.select(1).where('lfs_objects_projects.lfs_object_id = lfs_objects.id'))
end
def update_file_store
# The file.object_store is set during `uploader.store!`
# which happens after object is inserted/updated
Loading
Loading
Loading
Loading
@@ -240,6 +240,7 @@ class User < ApplicationRecord
delegate :time_display_relative, :time_display_relative=, to: :user_preference
delegate :time_format_in_24h, :time_format_in_24h=, to: :user_preference
delegate :show_whitespace_in_diffs, :show_whitespace_in_diffs=, to: :user_preference
delegate :setup_for_company, :setup_for_company=, to: :user_preference
 
accepts_nested_attributes_for :user_preference, update_only: true
 
Loading
Loading
Loading
Loading
@@ -4,6 +4,9 @@
module Projects
module LfsPointers
class LfsLinkService < BaseService
TooManyOidsError = Class.new(StandardError)
MAX_OIDS = 100_000
BATCH_SIZE = 1000
 
# Accept an array of oids to link
Loading
Loading
@@ -12,6 +15,10 @@ module Projects
def execute(oids)
return [] unless project&.lfs_enabled?
 
if oids.size > MAX_OIDS
raise TooManyOidsError, 'Too many LFS object ids to link, please push them manually'
end
# Search and link existing LFS Object
link_existing_lfs_objects(oids)
end
Loading
Loading
@@ -20,22 +27,27 @@ module Projects
 
# rubocop: disable CodeReuse/ActiveRecord
def link_existing_lfs_objects(oids)
all_existing_objects = []
linked_existing_objects = []
iterations = 0
 
LfsObject.where(oid: oids).each_batch(of: BATCH_SIZE) do |existent_lfs_objects|
oids.each_slice(BATCH_SIZE) do |oids_batch|
# Load all existing LFS Objects immediately so we don't issue an extra
# query for the `.any?`
existent_lfs_objects = LfsObject.where(oid: oids_batch).load
next unless existent_lfs_objects.any?
 
rows = existent_lfs_objects
.not_linked_to_project(project)
.map { |existing_lfs_object| { project_id: project.id, lfs_object_id: existing_lfs_object.id } }
Gitlab::Database.bulk_insert(:lfs_objects_projects, rows)
iterations += 1
not_linked_lfs_objects = existent_lfs_objects.where.not(id: project.all_lfs_objects)
project.all_lfs_objects << not_linked_lfs_objects
 
all_existing_objects += existent_lfs_objects.pluck(:oid)
linked_existing_objects += existent_lfs_objects.map(&:oid)
end
 
log_lfs_link_results(all_existing_objects.count, iterations)
log_lfs_link_results(linked_existing_objects.count, iterations)
 
all_existing_objects
linked_existing_objects
end
# rubocop: enable CodeReuse/ActiveRecord
 
Loading
Loading
# frozen_string_literal: true
module Users
class SignupService < BaseService
def initialize(current_user, params = {})
@user = current_user
@params = params.dup
end
def execute
assign_attributes
inject_validators
if @user.save
success
else
error(@user.errors.full_messages.join('. '))
end
end
private
def assign_attributes
@user.assign_attributes(params) unless params.empty?
end
def inject_validators
class << @user
validates :role, presence: true
validates :setup_for_company, inclusion: { in: [true, false], message: :blank }
end
end
end
end
- content_for(:page_title, _('Welcome to GitLab %{username}!') % { username: current_user.username })
- content_for(:page_title, _('Welcome to GitLab @%{username}!') % { username: current_user.username })
- max_name_length = 128
.text-center.mb-3
= _('In order to tailor your experience with GitLab<br>we would like to know a bit more about you.').html_safe
= _('In order to tailor your experience with GitLab we<br>would like to know a bit more about you.').html_safe
.signup-box.p-3.mb-2
.signup-body
= form_for(current_user, url: users_sign_up_update_role_path, html: { class: 'new_new_user gl-show-field-errors', 'aria-live' => 'assertive' }) do |f|
= form_for(current_user, url: users_sign_up_update_registration_path, html: { class: 'new_new_user gl-show-field-errors', 'aria-live' => 'assertive' }) do |f|
.devise-errors.mt-0
= render 'devise/shared/error_messages', resource: current_user
.name.form-group
Loading
Loading
@@ -13,5 +13,14 @@
.form-group
= f.label :role, _('Role'), class: 'label-bold'
= f.select :role, ::User.roles.keys.map { |role| [role.titleize, role] }, {}, class: 'form-control'
.form-group
= f.label :setup_for_company, _('Are you setting up GitLab for a company?'), class: 'label-bold'
.d-flex.justify-content-center
.w-25
= f.radio_button :setup_for_company, true
= f.label :setup_for_company, _('Yes'), value: 'true'
.w-25
= f.radio_button :setup_for_company, false
= f.label :setup_for_company, _('No'), value: 'false'
.submit-container.mt-3
= f.submit _('Get started!'), class: 'btn-register btn btn-block mb-0 p-2'
---
title: Fix JSON responses returning 302 instead of 401
merge_request: 19412
author:
type: fixed
---
title: Improve performance of linking LFS objects during import
merge_request: 19709
author:
type: performance
---
title: Ask if the user is setting up GitLab for a company during signup
merge_request: 17999
author:
type: changed
Loading
Loading
@@ -57,7 +57,7 @@ Rails.application.routes.draw do
 
# Sign up
get 'users/sign_up/welcome' => 'registrations#welcome'
patch 'users/sign_up/update_role' => 'registrations#update_role'
patch 'users/sign_up/update_registration' => 'registrations#update_registration'
 
# Search
get 'search' => 'search#show'
Loading
Loading
Loading
Loading
@@ -52,7 +52,7 @@ scope(path: '*namespace_id/:project_id',
# /info/refs?service=git-receive-pack, but nothing else.
#
git_http_handshake = lambda do |request|
::Constraints::ProjectUrlConstrainer.new.matches?(request) &&
::Constraints::ProjectUrlConstrainer.new.matches?(request, existence_check: false) &&
(request.query_string.blank? ||
request.query_string.match(/\Aservice=git-(upload|receive)-pack\z/))
end
Loading
Loading
Loading
Loading
@@ -245,6 +245,12 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
post :validate_query, on: :collection
end
end
Gitlab.ee do
resources :alerts, constraints: { id: /\d+/ }, only: [:index, :create, :show, :update, :destroy] do
post :notify, on: :collection
end
end
end
 
resources :merge_requests, concerns: :awardable, except: [:new, :create, :show], constraints: { id: /\d+/ } do
Loading
Loading
@@ -347,6 +353,17 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
 
Gitlab.ee do
resources :path_locks, only: [:index, :destroy] do
collection do
post :toggle
end
end
get '/service_desk' => 'service_desk#show', as: :service_desk
put '/service_desk' => 'service_desk#update', as: :service_desk_refresh
end
resource :variables, only: [:show, :update]
 
resources :triggers, only: [:index, :create, :edit, :update, :destroy]
Loading
Loading
@@ -380,6 +397,11 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :failures
get :status
get :test_report
Gitlab.ee do
get :security
get :licenses
end
end
 
member do
Loading
Loading
@@ -514,11 +536,24 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :realtime_changes
post :create_merge_request
get :discussions, format: :json
Gitlab.ee do
get 'designs(/*vueroute)', to: 'issues#designs', as: :designs, format: false
end
end
 
collection do
post :bulk_update
post :import_csv
Gitlab.ee do
post :export_csv
get :service_desk
end
end
Gitlab.ee do
resources :issue_links, only: [:index, :create, :destroy], as: 'links', path: 'links'
end
end
 
Loading
Loading
@@ -594,15 +629,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
Gitlab.ee do
resources :managed_licenses, only: [:index, :show, :new, :create, :edit, :update, :destroy]
end
# Legacy routes.
# Introduced in 12.0.
# Should be removed after 12.1
Gitlab::Routing.redirect_legacy_paths(self, :settings, :branches, :tags,
:network, :graphs, :autocomplete_sources,
:project_members, :deploy_keys, :deploy_tokens,
:labels, :milestones, :services, :boards, :releases,
:forks, :group_links, :import, :avatar)
end
 
resources(:projects,
Loading
Loading
@@ -627,4 +653,22 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
end
# Legacy routes.
# Introduced in 12.0.
# Should be removed after 12.1
scope(path: '*namespace_id',
as: :namespace,
namespace_id: Gitlab::PathRegex.full_namespace_route_regex) do
scope(path: ':project_id',
constraints: { project_id: Gitlab::PathRegex.project_route_regex },
module: :projects,
as: :project) do
Gitlab::Routing.redirect_legacy_paths(self, :settings, :branches, :tags,
:network, :graphs, :autocomplete_sources,
:project_members, :deploy_keys, :deploy_tokens,
:labels, :milestones, :services, :boards, :releases,
:forks, :group_links, :import, :avatar)
end
end
end
# frozen_string_literal: true
class AddSetupForCompanyToUserPreferences < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :user_preferences, :setup_for_company, :boolean
end
end
Loading
Loading
@@ -3754,6 +3754,7 @@ ActiveRecord::Schema.define(version: 2019_11_05_094625) do
t.boolean "time_format_in_24h"
t.string "projects_sort", limit: 64
t.boolean "show_whitespace_in_diffs", default: true, null: false
t.boolean "setup_for_company"
t.index ["user_id"], name: "index_user_preferences_on_user_id", unique: true
end
 
Loading
Loading
Loading
Loading
@@ -2,12 +2,17 @@
 
module Constraints
class ProjectUrlConstrainer
def matches?(request)
def matches?(request, existence_check: true)
namespace_path = request.params[:namespace_id]
project_path = request.params[:project_id] || request.params[:id]
full_path = [namespace_path, project_path].join('/')
 
ProjectPathValidator.valid_path?(full_path)
return false unless ProjectPathValidator.valid_path?(full_path)
return true unless existence_check
# We intentionally allow SELECT(*) here so result of this query can be used
# as cache for further Project.find_by_full_path calls within request
Project.find_by_full_path(full_path, follow_redirects: request.get?).present?
end
end
end
Loading
Loading
@@ -10,7 +10,7 @@ module Gitlab
RoutesNotFound = Class.new(StandardError)
 
def draw(routes_name)
drawn_any = draw_ee(routes_name) | draw_ce(routes_name)
drawn_any = draw_ce(routes_name) | draw_ee(routes_name)
 
drawn_any || raise(RoutesNotFound.new("Cannot find #{routes_name}"))
end
Loading
Loading
Loading
Loading
@@ -1947,6 +1947,9 @@ msgstr ""
msgid "Archiving the project will make it entirely read-only. It is hidden from the dashboard and doesn't show up in searches. <strong>The repository cannot be committed to, and no issues, comments or other entities can be created.</strong>"
msgstr ""
 
msgid "Are you setting up GitLab for a company?"
msgstr ""
msgid "Are you sure that you want to archive this project?"
msgstr ""
 
Loading
Loading
@@ -9143,7 +9146,7 @@ msgstr ""
msgid "In order to gather accurate feature usage data, it can take 1 to 2 weeks to see your index."
msgstr ""
 
msgid "In order to tailor your experience with GitLab<br>we would like to know a bit more about you."
msgid "In order to tailor your experience with GitLab we<br>would like to know a bit more about you."
msgstr ""
 
msgid "In the next step, you'll be able to select the projects you want to import."
Loading
Loading
@@ -19090,7 +19093,7 @@ msgstr ""
msgid "Welcome to GitLab"
msgstr ""
 
msgid "Welcome to GitLab %{username}!"
msgid "Welcome to GitLab @%{username}!"
msgstr ""
 
msgid "Welcome to the Guided GitLab Tour"
Loading
Loading
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