diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /app/models/concerns | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) | |
download | gitlab-ce-983a0bba5d2a042c4a3bbb22432ec192c7501d82.tar.gz |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/ci/has_ref.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/ci/pipeline_delegator.rb | 20 | ||||
-rw-r--r-- | app/models/concerns/issuable.rb | 21 | ||||
-rw-r--r-- | app/models/concerns/notification_branch_selection.rb | 14 | ||||
-rw-r--r-- | app/models/concerns/project_features_compatibility.rb | 4 |
5 files changed, 30 insertions, 31 deletions
diff --git a/app/models/concerns/ci/has_ref.rb b/app/models/concerns/ci/has_ref.rb index cf57ff47743..e2d459ea70e 100644 --- a/app/models/concerns/ci/has_ref.rb +++ b/app/models/concerns/ci/has_ref.rb @@ -2,7 +2,7 @@ ## # We will disable `ref` and `sha` attributes in `Ci::Build` in the future -# and remove this module in favor of Ci::PipelineDelegator. +# and remove this module in favor of Ci::Processable. module Ci module HasRef extend ActiveSupport::Concern diff --git a/app/models/concerns/ci/pipeline_delegator.rb b/app/models/concerns/ci/pipeline_delegator.rb deleted file mode 100644 index 68ad0fcee31..00000000000 --- a/app/models/concerns/ci/pipeline_delegator.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -## -# This module is mainly used by child associations of `Ci::Pipeline` that needs to look up -# single source of truth. For example, `Ci::Build` has `git_ref` method, which behaves -# slightly different from `Ci::Pipeline`'s `git_ref`. This is very confusing as -# the system could behave differently time to time. -# We should have a single interface in `Ci::Pipeline` and access the method always. -module Ci - module PipelineDelegator - extend ActiveSupport::Concern - - included do - delegate :merge_request?, - :merge_request_ref?, - :legacy_detached_merge_request_pipeline?, - :merge_train_pipeline?, to: :pipeline - end - end -end diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 7300283f086..37f2209b9d2 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -116,6 +116,7 @@ module Issuable # rubocop:enable GitlabSecurity/SqlInjection scope :without_label, -> { joins("LEFT OUTER JOIN label_links ON label_links.target_type = '#{name}' AND label_links.target_id = #{table_name}.id").where(label_links: { id: nil }) } + scope :with_label_ids, ->(label_ids) { joins(:label_links).where(label_links: { label_id: label_ids }) } scope :any_label, -> { joins(:label_links).group(:id) } scope :join_project, -> { joins(:project) } scope :inc_notes_with_associations, -> { includes(notes: [:project, :author, :award_emoji]) } @@ -131,8 +132,21 @@ module Issuable strip_attributes :title - def self.locking_enabled? - false + class << self + def labels_hash + issue_labels = Hash.new { |h, k| h[k] = [] } + + relation = unscoped.where(id: self.select(:id)).eager_load(:labels) + relation.pluck(:id, 'labels.title').each do |issue_id, label| + issue_labels[issue_id] << label if label.present? + end + + issue_labels + end + + def locking_enabled? + false + end end # We want to use optimistic lock for cases when only title or description are involved @@ -478,5 +492,4 @@ module Issuable end end -Issuable.prepend_if_ee('EE::Issuable') # rubocop: disable Cop/InjectEnterpriseEditionModule -Issuable::ClassMethods.prepend_if_ee('EE::Issuable::ClassMethods') +Issuable.prepend_if_ee('EE::Issuable') diff --git a/app/models/concerns/notification_branch_selection.rb b/app/models/concerns/notification_branch_selection.rb index 7f00b652530..2354335469a 100644 --- a/app/models/concerns/notification_branch_selection.rb +++ b/app/models/concerns/notification_branch_selection.rb @@ -6,12 +6,14 @@ module NotificationBranchSelection extend ActiveSupport::Concern - BRANCH_CHOICES = [ - [_('All branches'), 'all'], - [_('Default branch'), 'default'], - [_('Protected branches'), 'protected'], - [_('Default branch and protected branches'), 'default_and_protected'] - ].freeze + def branch_choices + [ + [_('All branches'), 'all'].freeze, + [_('Default branch'), 'default'].freeze, + [_('Protected branches'), 'protected'].freeze, + [_('Default branch and protected branches'), 'default_and_protected'].freeze + ].freeze + end def notify_for_branch?(data) ref = if data[:ref] diff --git a/app/models/concerns/project_features_compatibility.rb b/app/models/concerns/project_features_compatibility.rb index 76d26500267..cedcf164a49 100644 --- a/app/models/concerns/project_features_compatibility.rb +++ b/app/models/concerns/project_features_compatibility.rb @@ -66,6 +66,10 @@ module ProjectFeaturesCompatibility write_feature_attribute_string(:pages_access_level, value) end + def metrics_dashboard_access_level=(value) + write_feature_attribute_string(:metrics_dashboard_access_level, value) + end + private def write_feature_attribute_boolean(field, value) |