Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r--app/controllers/concerns/authenticates_with_two_factor.rb2
-rw-r--r--app/controllers/concerns/creates_commit.rb24
-rw-r--r--app/controllers/concerns/enforces_admin_authentication.rb2
-rw-r--r--app/controllers/concerns/labels_as_hash.rb2
-rw-r--r--app/controllers/concerns/membership_actions.rb11
-rw-r--r--app/controllers/concerns/milestone_actions.rb2
-rw-r--r--app/controllers/concerns/redis_tracking.rb15
-rw-r--r--app/controllers/concerns/renders_commits.rb3
-rw-r--r--app/controllers/concerns/runner_setup_scripts.rb4
-rw-r--r--app/controllers/concerns/service_params.rb3
-rw-r--r--app/controllers/concerns/sessionless_authentication.rb2
11 files changed, 44 insertions, 26 deletions
diff --git a/app/controllers/concerns/authenticates_with_two_factor.rb b/app/controllers/concerns/authenticates_with_two_factor.rb
index 5c74d79951f..87555a28eb8 100644
--- a/app/controllers/concerns/authenticates_with_two_factor.rb
+++ b/app/controllers/concerns/authenticates_with_two_factor.rb
@@ -70,7 +70,7 @@ module AuthenticatesWithTwoFactor
elsif !user.confirmed?
I18n.t('devise.failure.unconfirmed')
else
- _('Invalid Login or password')
+ _('Invalid login or password')
end
end
diff --git a/app/controllers/concerns/creates_commit.rb b/app/controllers/concerns/creates_commit.rb
index e8e681ce649..7bfcda67aa2 100644
--- a/app/controllers/concerns/creates_commit.rb
+++ b/app/controllers/concerns/creates_commit.rb
@@ -5,19 +5,23 @@ module CreatesCommit
include Gitlab::Utils::StrongMemoize
# rubocop:disable Gitlab/ModuleWithInstanceVariables
- def create_commit(service, success_path:, failure_path:, failure_view: nil, success_notice: nil)
- if user_access(@project).can_push_to_branch?(branch_name_or_ref)
- @project_to_commit_into = @project
+ def create_commit(service, success_path:, failure_path:, failure_view: nil, success_notice: nil, target_project: nil)
+ target_project ||= @project
+
+ if user_access(target_project).can_push_to_branch?(branch_name_or_ref)
+ @project_to_commit_into = target_project
@branch_name ||= @ref
else
- @project_to_commit_into = current_user.fork_of(@project)
+ @project_to_commit_into = current_user.fork_of(target_project)
@branch_name ||= @project_to_commit_into.repository.next_branch('patch')
end
@start_branch ||= @ref || @branch_name
+ start_project = Feature.enabled?(:pick_into_project, @project, default_enabled: :yaml) ? @project_to_commit_into : @project
+
commit_params = @commit_params.merge(
- start_project: @project,
+ start_project: start_project,
start_branch: @start_branch,
branch_name: @branch_name
)
@@ -27,7 +31,7 @@ module CreatesCommit
if result[:status] == :success
update_flash_notice(success_notice)
- success_path = final_success_path(success_path)
+ success_path = final_success_path(success_path, target_project)
respond_to do |format|
format.html { redirect_to success_path }
@@ -79,9 +83,9 @@ module CreatesCommit
end
end
- def final_success_path(success_path)
+ def final_success_path(success_path, target_project)
if create_merge_request?
- merge_request_exists? ? existing_merge_request_path : new_merge_request_path
+ merge_request_exists? ? existing_merge_request_path : new_merge_request_path(target_project)
else
success_path = success_path.call if success_path.respond_to?(:call)
@@ -90,12 +94,12 @@ module CreatesCommit
end
# rubocop:disable Gitlab/ModuleWithInstanceVariables
- def new_merge_request_path
+ def new_merge_request_path(target_project)
project_new_merge_request_path(
@project_to_commit_into,
merge_request: {
source_project_id: @project_to_commit_into.id,
- target_project_id: @project.id,
+ target_project_id: target_project.id,
source_branch: @branch_name,
target_branch: @start_branch
}
diff --git a/app/controllers/concerns/enforces_admin_authentication.rb b/app/controllers/concerns/enforces_admin_authentication.rb
index 527759de0bb..94c0e98c91a 100644
--- a/app/controllers/concerns/enforces_admin_authentication.rb
+++ b/app/controllers/concerns/enforces_admin_authentication.rb
@@ -15,7 +15,7 @@ module EnforcesAdminAuthentication
def authenticate_admin!
return render_404 unless current_user.admin?
- return unless Feature.enabled?(:user_mode_in_session)
+ return unless Gitlab::CurrentSettings.admin_mode
unless current_user_mode.admin_mode?
current_user_mode.request_admin_mode!
diff --git a/app/controllers/concerns/labels_as_hash.rb b/app/controllers/concerns/labels_as_hash.rb
index 1171aa9cf44..e428520f709 100644
--- a/app/controllers/concerns/labels_as_hash.rb
+++ b/app/controllers/concerns/labels_as_hash.rb
@@ -11,7 +11,7 @@ module LabelsAsHash
label_hashes = available_labels.as_json(only: [:title, :color])
- if target&.respond_to?(:labels)
+ if target.respond_to?(:labels)
already_set_labels = available_labels & target.labels
if already_set_labels.present?
titles = already_set_labels.map(&:title)
diff --git a/app/controllers/concerns/membership_actions.rb b/app/controllers/concerns/membership_actions.rb
index 9e3625d1b36..7bbee8ba79e 100644
--- a/app/controllers/concerns/membership_actions.rb
+++ b/app/controllers/concerns/membership_actions.rb
@@ -6,7 +6,7 @@ module MembershipActions
def create
create_params = params.permit(:user_ids, :access_level, :expires_at)
- result = Members::CreateService.new(current_user, create_params).execute(membershipable)
+ result = Members::CreateService.new(current_user, create_params.merge({ source: membershipable })).execute
if result[:status] == :success
redirect_to members_page_url, notice: _('Users were successfully added.')
@@ -43,10 +43,11 @@ module MembershipActions
def destroy
member = membershipable.members_and_requesters.find(params[:id])
+ skip_subresources = !ActiveRecord::Type::Boolean.new.cast(params.delete(:remove_sub_memberships))
# !! is used in case unassign_issuables contains empty string which would result in nil
unassign_issuables = !!ActiveRecord::Type::Boolean.new.cast(params.delete(:unassign_issuables))
- Members::DestroyService.new(current_user).execute(member, unassign_issuables: unassign_issuables)
+ Members::DestroyService.new(current_user).execute(member, skip_subresources: skip_subresources, unassign_issuables: unassign_issuables)
respond_to do |format|
format.html do
@@ -54,7 +55,11 @@ module MembershipActions
begin
case membershipable
when Namespace
- _("User was successfully removed from group and any subresources.")
+ if skip_subresources
+ _("User was successfully removed from group.")
+ else
+ _("User was successfully removed from group and any subgroups and projects.")
+ end
else
_("User was successfully removed from project.")
end
diff --git a/app/controllers/concerns/milestone_actions.rb b/app/controllers/concerns/milestone_actions.rb
index 6470c75dfbd..0a859bd3af9 100644
--- a/app/controllers/concerns/milestone_actions.rb
+++ b/app/controllers/concerns/milestone_actions.rb
@@ -20,7 +20,7 @@ module MilestoneActions
format.html { redirect_to milestone_redirect_path }
format.json do
render json: tabs_json("shared/milestones/_merge_requests_tab", {
- merge_requests: @milestone.sorted_merge_requests(current_user), # rubocop:disable Gitlab/ModuleWithInstanceVariables
+ merge_requests: @milestone.sorted_merge_requests(current_user).preload_milestoneish_associations, # rubocop:disable Gitlab/ModuleWithInstanceVariables
show_project_name: Gitlab::Utils.to_boolean(params[:show_project_name])
})
end
diff --git a/app/controllers/concerns/redis_tracking.rb b/app/controllers/concerns/redis_tracking.rb
index a7e75f802a8..3155208f47c 100644
--- a/app/controllers/concerns/redis_tracking.rb
+++ b/app/controllers/concerns/redis_tracking.rb
@@ -10,26 +10,31 @@
# track_redis_hll_event :index, :show, name: 'i_analytics_dev_ops_score'
#
# You can also pass custom conditions using `if:`, using the same format as with Rails callbacks.
+# You can also pass an optional block that calculates and returns a custom id to track.
module RedisTracking
extend ActiveSupport::Concern
class_methods do
- def track_redis_hll_event(*controller_actions, name:, if: nil)
+ def track_redis_hll_event(*controller_actions, name:, if: nil, &block)
custom_conditions = Array.wrap(binding.local_variable_get('if'))
conditions = [:trackable_request?, *custom_conditions]
after_action only: controller_actions, if: conditions do
- track_unique_redis_hll_event(name)
+ track_unique_redis_hll_event(name, &block)
end
end
end
private
- def track_unique_redis_hll_event(event_name)
- return unless visitor_id
+ def track_unique_redis_hll_event(event_name, &block)
+ custom_id = block_given? ? yield(self) : nil
- Gitlab::UsageDataCounters::HLLRedisCounter.track_event(event_name, values: visitor_id)
+ unique_id = custom_id || visitor_id
+
+ return unless unique_id
+
+ Gitlab::UsageDataCounters::HLLRedisCounter.track_event(event_name, values: unique_id)
end
def trackable_request?
diff --git a/app/controllers/concerns/renders_commits.rb b/app/controllers/concerns/renders_commits.rb
index 826fae834fa..4ea07c814ef 100644
--- a/app/controllers/concerns/renders_commits.rb
+++ b/app/controllers/concerns/renders_commits.rb
@@ -17,12 +17,13 @@ module RendersCommits
def set_commits_for_rendering(commits, commits_count: nil)
@total_commit_count = commits_count || commits.size
limited, @hidden_commit_count = limited_commits(commits, @total_commit_count)
- commits.each(&:lazy_author) # preload authors
prepare_commits_for_rendering(limited)
end
# rubocop: enable Gitlab/ModuleWithInstanceVariables
def prepare_commits_for_rendering(commits)
+ commits.each(&:lazy_author) # preload commits' authors
+
Banzai::CommitRenderer.render(commits, @project, current_user) # rubocop:disable Gitlab/ModuleWithInstanceVariables
commits
diff --git a/app/controllers/concerns/runner_setup_scripts.rb b/app/controllers/concerns/runner_setup_scripts.rb
index c0e657a32d1..ccae15b824f 100644
--- a/app/controllers/concerns/runner_setup_scripts.rb
+++ b/app/controllers/concerns/runner_setup_scripts.rb
@@ -5,8 +5,8 @@ module RunnerSetupScripts
private
- def private_runner_setup_scripts(**kwargs)
- instructions = Gitlab::Ci::RunnerInstructions.new(current_user: current_user, os: script_params[:os], arch: script_params[:arch], **kwargs)
+ def private_runner_setup_scripts
+ instructions = Gitlab::Ci::RunnerInstructions.new(os: script_params[:os], arch: script_params[:arch])
output = {
install: instructions.install_script,
register: instructions.register_command
diff --git a/app/controllers/concerns/service_params.rb b/app/controllers/concerns/service_params.rb
index 3cab198c1f9..7c57d321c80 100644
--- a/app/controllers/concerns/service_params.rb
+++ b/app/controllers/concerns/service_params.rb
@@ -44,6 +44,8 @@ module ServiceParams
# make those event names plural as special case.
:issues_events,
:issues_url,
+ :jenkins_url,
+ :jira_issue_transition_automatic,
:jira_issue_transition_id,
:manual_configuration,
:merge_requests_events,
@@ -55,6 +57,7 @@ module ServiceParams
:password,
:priority,
:project_key,
+ :project_name,
:project_url,
:recipients,
:restrict_to_branch,
diff --git a/app/controllers/concerns/sessionless_authentication.rb b/app/controllers/concerns/sessionless_authentication.rb
index a9ef33bf3b9..882fef7a342 100644
--- a/app/controllers/concerns/sessionless_authentication.rb
+++ b/app/controllers/concerns/sessionless_authentication.rb
@@ -27,7 +27,7 @@ module SessionlessAuthentication
end
def sessionless_bypass_admin_mode!(&block)
- return yield unless Feature.enabled?(:user_mode_in_session)
+ return yield unless Gitlab::CurrentSettings.admin_mode
Gitlab::Auth::CurrentUserMode.bypass_session!(current_user.id, &block)
end