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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 21:18:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 21:18:33 +0300
commitf64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch)
treea2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /app/models/concerns
parentbfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff)
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'app/models/concerns')
-rw-r--r--app/models/concerns/analytics/cycle_analytics/stage.rb19
-rw-r--r--app/models/concerns/avatarable.rb8
-rw-r--r--app/models/concerns/boards/listable.rb20
-rw-r--r--app/models/concerns/ci/contextable.rb16
-rw-r--r--app/models/concerns/ci/has_status.rb6
-rw-r--r--app/models/concerns/ci/has_variable.rb1
-rw-r--r--app/models/concerns/issuable.rb1
-rw-r--r--app/models/concerns/project_features_compatibility.rb12
8 files changed, 50 insertions, 33 deletions
diff --git a/app/models/concerns/analytics/cycle_analytics/stage.rb b/app/models/concerns/analytics/cycle_analytics/stage.rb
index 080ff07ec0c..f1c39dda49d 100644
--- a/app/models/concerns/analytics/cycle_analytics/stage.rb
+++ b/app/models/concerns/analytics/cycle_analytics/stage.rb
@@ -49,14 +49,6 @@ module Analytics
end
end
- def start_event_identifier
- backward_compatible_identifier(:start_event_identifier) || super
- end
-
- def end_event_identifier
- backward_compatible_identifier(:end_event_identifier) || super
- end
-
def start_event_label_based?
start_event_identifier && start_event.label_based?
end
@@ -136,17 +128,6 @@ module Analytics
.id_in(label_id)
.exists?
end
-
- # Temporary, will be removed in 13.10
- def backward_compatible_identifier(attribute_name)
- removed_identifier = 6 # References IssueFirstMentionedInCommit removed on https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51975
- replacement_identifier = :issue_first_mentioned_in_commit
-
- # ActiveRecord returns nil if the column value is not part of the Enum definition
- if self[attribute_name].nil? && read_attribute_before_type_cast(attribute_name) == removed_identifier
- replacement_identifier
- end
- end
end
end
end
diff --git a/app/models/concerns/avatarable.rb b/app/models/concerns/avatarable.rb
index d342b526677..c106c08c04a 100644
--- a/app/models/concerns/avatarable.rb
+++ b/app/models/concerns/avatarable.rb
@@ -20,6 +20,7 @@ module Avatarable
mount_uploader :avatar, AvatarUploader
after_initialize :add_avatar_to_batch
+ after_commit :clear_avatar_caches
end
module ShadowMethods
@@ -127,4 +128,11 @@ module Avatarable
def avatar_mounter
strong_memoize(:avatar_mounter) { _mounter(:avatar) }
end
+
+ def clear_avatar_caches
+ return unless respond_to?(:verified_emails) && verified_emails.any? && avatar_changed?
+ return unless Feature.enabled?(:avatar_cache_for_email, self, type: :development)
+
+ Gitlab::AvatarCache.delete_by_email(*verified_emails)
+ end
end
diff --git a/app/models/concerns/boards/listable.rb b/app/models/concerns/boards/listable.rb
index b7c0a8b3489..d6863e87261 100644
--- a/app/models/concerns/boards/listable.rb
+++ b/app/models/concerns/boards/listable.rb
@@ -13,6 +13,14 @@ module Boards
scope :ordered, -> { order(:list_type, :position) }
scope :destroyable, -> { where(list_type: list_types.slice(*destroyable_types).values) }
scope :movable, -> { where(list_type: list_types.slice(*movable_types).values) }
+
+ class << self
+ def preload_preferences_for_user(lists, user)
+ return unless user
+
+ lists.each { |list| list.preferences_for(user) }
+ end
+ end
end
class_methods do
@@ -33,6 +41,18 @@ module Boards
self.class.movable_types.include?(list_type&.to_sym)
end
+ def collapsed?(user)
+ preferences = preferences_for(user)
+
+ preferences.collapsed?
+ end
+
+ def update_preferences_for(user, preferences = {})
+ return unless user
+
+ preferences_for(user).update(preferences)
+ end
+
def title
if label?
label.name
diff --git a/app/models/concerns/ci/contextable.rb b/app/models/concerns/ci/contextable.rb
index c8b55e7b39f..bdba2d3e251 100644
--- a/app/models/concerns/ci/contextable.rb
+++ b/app/models/concerns/ci/contextable.rb
@@ -20,7 +20,7 @@ module Ci
variables.concat(user_variables)
variables.concat(dependency_variables) if dependencies
variables.concat(secret_instance_variables)
- variables.concat(secret_group_variables)
+ variables.concat(secret_group_variables(environment: environment))
variables.concat(secret_project_variables(environment: environment))
variables.concat(trigger_request.user_variables) if trigger_request
variables.concat(pipeline.variables)
@@ -29,14 +29,6 @@ module Ci
end
##
- # Regular Ruby hash of scoped variables, without duplicates that are
- # possible to be present in an array of hashes returned from `variables`.
- #
- def scoped_variables_hash
- scoped_variables.to_hash
- end
-
- ##
# Variables that do not depend on the environment name.
#
def simple_variables
@@ -93,13 +85,13 @@ module Ci
project.ci_instance_variables_for(ref: git_ref)
end
- def secret_group_variables
+ def secret_group_variables(environment: expanded_environment_name)
return [] unless project.group
- project.group.ci_variables_for(git_ref, project)
+ project.group.ci_variables_for(git_ref, project, environment: environment)
end
- def secret_project_variables(environment: persisted_environment)
+ def secret_project_variables(environment: expanded_environment_name)
project.ci_variables_for(ref: git_ref, environment: environment)
end
diff --git a/app/models/concerns/ci/has_status.rb b/app/models/concerns/ci/has_status.rb
index 1cc2e8a51e3..0412f7a072b 100644
--- a/app/models/concerns/ci/has_status.rb
+++ b/app/models/concerns/ci/has_status.rb
@@ -20,9 +20,11 @@ module Ci
UnknownStatusError = Class.new(StandardError)
class_methods do
- def composite_status
+ # The parameter `project` is only used for the feature flag check, and will be removed with
+ # https://gitlab.com/gitlab-org/gitlab/-/issues/321972
+ def composite_status(project: nil)
Gitlab::Ci::Status::Composite
- .new(all, with_allow_failure: columns_hash.key?('allow_failure'))
+ .new(all, with_allow_failure: columns_hash.key?('allow_failure'), project: project)
.status
end
diff --git a/app/models/concerns/ci/has_variable.rb b/app/models/concerns/ci/has_variable.rb
index 9bf2b409080..7309469c77e 100644
--- a/app/models/concerns/ci/has_variable.rb
+++ b/app/models/concerns/ci/has_variable.rb
@@ -16,6 +16,7 @@ module Ci
format: { with: /\A[a-zA-Z0-9_]+\z/,
message: "can contain only letters, digits and '_'." }
+ scope :by_key, -> (key) { where(key: key) }
scope :order_key_asc, -> { reorder(key: :asc) }
attr_encrypted :value,
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 83ff5b16efe..e1be0665452 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -86,6 +86,7 @@ module Issuable
before_validation :truncate_description_on_import!
scope :authored, ->(user) { where(author_id: user) }
+ scope :not_authored, ->(user) { where.not(author_id: user) }
scope :recent, -> { reorder(id: :desc) }
scope :of_projects, ->(ids) { where(project_id: ids) }
scope :opened, -> { with_state(:opened) }
diff --git a/app/models/concerns/project_features_compatibility.rb b/app/models/concerns/project_features_compatibility.rb
index 07bec07e556..7c774d8bad7 100644
--- a/app/models/concerns/project_features_compatibility.rb
+++ b/app/models/concerns/project_features_compatibility.rb
@@ -34,6 +34,10 @@ module ProjectFeaturesCompatibility
write_feature_attribute_boolean(:snippets_access_level, value)
end
+ def security_and_compliance_enabled=(value)
+ write_feature_attribute_boolean(:security_and_compliance_access_level, value)
+ end
+
def repository_access_level=(value)
write_feature_attribute_string(:repository_access_level, value)
end
@@ -78,6 +82,14 @@ module ProjectFeaturesCompatibility
write_feature_attribute_string(:operations_access_level, value)
end
+ def security_and_compliance_access_level=(value)
+ write_feature_attribute_string(:security_and_compliance_access_level, value)
+ end
+
+ def container_registry_access_level=(value)
+ write_feature_attribute_string(:container_registry_access_level, value)
+ end
+
private
def write_feature_attribute_boolean(field, value)