summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-05 12:10:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-05 12:10:33 +0000
commit023e050d82ed11d9060ce5bdaec99c3871b98164 (patch)
treeee89e2c83c2771c635a0c1daaa88fcce25f18612 /lib
parent1c568d834d0cbe1bbbf558ac9a45940f6dbda37a (diff)
downloadgitlab-ce-023e050d82ed11d9060ce5bdaec99c3871b98164.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/entities/issue_basic.rb8
-rw-r--r--lib/gitlab.rb10
-rw-r--r--lib/gitlab/ci/pipeline/chain/skip.rb11
-rw-r--r--lib/gitlab/ci/pipeline/chain/validate/security_orchestration_policy.rb25
-rw-r--r--lib/gitlab/import_export.rb18
-rw-r--r--lib/gitlab/subscription_portal.rb2
-rw-r--r--lib/sidebars/projects/menus/analytics_menu.rb89
-rw-r--r--lib/sidebars/projects/panel.rb1
8 files changed, 157 insertions, 7 deletions
diff --git a/lib/api/entities/issue_basic.rb b/lib/api/entities/issue_basic.rb
index cf96c6556ec..a9ec2632ed4 100644
--- a/lib/api/entities/issue_basic.rb
+++ b/lib/api/entities/issue_basic.rb
@@ -3,6 +3,10 @@
module API
module Entities
class IssueBasic < IssuableEntity
+ format_with(:upcase) do |item|
+ item.upcase if item.respond_to?(:upcase)
+ end
+
expose :closed_at
expose :closed_by, using: Entities::UserBasic
@@ -16,6 +20,10 @@ module API
expose :milestone, using: Entities::Milestone
expose :assignees, :author, using: Entities::UserBasic
+ expose :issue_type,
+ as: :type,
+ format_with: :upcase,
+ documentation: { type: "String", desc: "One of #{Issue.issue_types.keys.map(&:upcase)}" }
expose :assignee, using: ::API::Entities::UserBasic do |issue|
issue.assignees.first
diff --git a/lib/gitlab.rb b/lib/gitlab.rb
index ddf08c8dc20..86bb2f662e5 100644
--- a/lib/gitlab.rb
+++ b/lib/gitlab.rb
@@ -92,6 +92,16 @@ module Gitlab
Rails.env.development? || Rails.env.test?
end
+ def self.extensions
+ if jh?
+ %w[ee jh]
+ elsif ee?
+ %w[ee]
+ else
+ %w[]
+ end
+ end
+
def self.ee?
@is_ee ||=
# We use this method when the Rails environment is not loaded. This
diff --git a/lib/gitlab/ci/pipeline/chain/skip.rb b/lib/gitlab/ci/pipeline/chain/skip.rb
index df92e229f12..bea0c0ea115 100644
--- a/lib/gitlab/ci/pipeline/chain/skip.rb
+++ b/lib/gitlab/ci/pipeline/chain/skip.rb
@@ -11,7 +11,16 @@ module Gitlab
def perform!
if skipped?
- @pipeline.skip if @command.save_incompleted
+ if @command.save_incompleted
+ if Feature.enabled?(:ci_pipeline_ensure_iid_on_skip, @pipeline.project, default_enabled: :yaml)
+ # Project iid must be called outside a transaction, so we ensure it is set here
+ # otherwise it may be set within the state transition transaction of the skip call
+ # which it will lock the InternalId row for the whole transaction
+ @pipeline.ensure_project_iid!
+ end
+
+ @pipeline.skip
+ end
end
end
diff --git a/lib/gitlab/ci/pipeline/chain/validate/security_orchestration_policy.rb b/lib/gitlab/ci/pipeline/chain/validate/security_orchestration_policy.rb
new file mode 100644
index 00000000000..de59a5d51e3
--- /dev/null
+++ b/lib/gitlab/ci/pipeline/chain/validate/security_orchestration_policy.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Ci
+ module Pipeline
+ module Chain
+ module Validate
+ class SecurityOrchestrationPolicy < Chain::Base
+ include Chain::Helpers
+
+ def perform!
+ # no-op
+ end
+
+ def break?
+ false
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+Gitlab::Ci::Pipeline::Chain::Validate::SecurityOrchestrationPolicy.prepend_if_ee('EE::Gitlab::Ci::Pipeline::Chain::Validate::SecurityOrchestrationPolicy')
diff --git a/lib/gitlab/import_export.rb b/lib/gitlab/import_export.rb
index c4867746b0f..231f2a977c0 100644
--- a/lib/gitlab/import_export.rb
+++ b/lib/gitlab/import_export.rb
@@ -99,11 +99,19 @@ module Gitlab
def group_config_file
Rails.root.join('lib/gitlab/import_export/group/import_export.yml')
end
+
+ def group_wiki_repo_bundle_filename(group_id)
+ "#{group_id}.wiki.bundle"
+ end
+
+ def group_wiki_repo_bundle_path(shared, filename)
+ File.join(shared.export_path, 'repositories', filename)
+ end
+
+ def group_wiki_repo_bundle_full_path(shared, group_id)
+ group_wiki_repo_bundle_path(shared, group_wiki_repo_bundle_filename(group_id))
+ end
end
end
-Gitlab::ImportExport.prepend_if_ee('EE::Gitlab::ImportExport')
-
-# The methods in `Gitlab::ImportExport::GroupHelper` should be available as both
-# instance and class methods.
-Gitlab::ImportExport.extend_if_ee('Gitlab::ImportExport::GroupHelper')
+Gitlab::ImportExport.prepend_mod
diff --git a/lib/gitlab/subscription_portal.rb b/lib/gitlab/subscription_portal.rb
index 3072210d7c8..1ba1d70a13c 100644
--- a/lib/gitlab/subscription_portal.rb
+++ b/lib/gitlab/subscription_portal.rb
@@ -12,5 +12,5 @@ module Gitlab
end
end
-Gitlab::SubscriptionPortal.prepend_if_jh('JH::Gitlab::SubscriptionPortal')
+Gitlab::SubscriptionPortal.prepend_mod
Gitlab::SubscriptionPortal::SUBSCRIPTIONS_URL = Gitlab::SubscriptionPortal.subscriptions_url.freeze
diff --git a/lib/sidebars/projects/menus/analytics_menu.rb b/lib/sidebars/projects/menus/analytics_menu.rb
new file mode 100644
index 00000000000..b8a4e0171a7
--- /dev/null
+++ b/lib/sidebars/projects/menus/analytics_menu.rb
@@ -0,0 +1,89 @@
+# frozen_string_literal: true
+
+module Sidebars
+ module Projects
+ module Menus
+ class AnalyticsMenu < ::Sidebars::Menu
+ include Gitlab::Utils::StrongMemoize
+
+ override :configure_menu_items
+ def configure_menu_items
+ return false unless can?(context.current_user, :read_analytics, context.project)
+
+ add_item(ci_cd_analytics_menu_item)
+ add_item(repository_analytics_menu_item)
+ add_item(cycle_analytics_menu_item)
+
+ true
+ end
+
+ override :link
+ def link
+ return cycle_analytics_menu_item.link if cycle_analytics_menu_item
+
+ items.first.link
+ end
+
+ override :extra_container_html_options
+ def extra_container_html_options
+ {
+ class: 'shortcuts-analytics'
+ }
+ end
+
+ override :title
+ def title
+ _('Analytics')
+ end
+
+ override :sprite_icon
+ def sprite_icon
+ 'chart'
+ end
+
+ private
+
+ def ci_cd_analytics_menu_item
+ return if context.project.empty_repo?
+ return unless context.project.feature_available?(:builds, context.current_user)
+ return unless can?(context.current_user, :read_build, context.project)
+
+ ::Sidebars::MenuItem.new(
+ title: _('CI/CD'),
+ link: charts_project_pipelines_path(context.project),
+ active_routes: { path: 'pipelines#charts' },
+ item_id: :ci_cd_analytics
+ )
+ end
+
+ def repository_analytics_menu_item
+ return if context.project.empty_repo?
+
+ ::Sidebars::MenuItem.new(
+ title: _('Repository'),
+ link: charts_project_graph_path(context.project, context.current_ref),
+ container_html_options: { class: 'shortcuts-repository-charts' },
+ active_routes: { path: 'graphs#charts' },
+ item_id: :repository_analytics
+ )
+ end
+
+ def cycle_analytics_menu_item
+ strong_memoize(:cycle_analytics_menu_item) do
+ next unless can?(context.current_user, :read_cycle_analytics, context.project)
+
+ ::Sidebars::MenuItem.new(
+ title: _('Value Stream'),
+ link: project_cycle_analytics_path(context.project),
+ container_html_options: { class: 'shortcuts-project-cycle-analytics' },
+ active_routes: { path: 'cycle_analytics#show' },
+ item_id: :cycle_analytics
+ )
+ end
+ end
+ end
+ end
+ end
+end
+
+Sidebars::Projects::Menus::AnalyticsMenu.prepend_if_ee('EE::Sidebars::Projects::Menus::AnalyticsMenu')
diff --git a/lib/sidebars/projects/panel.rb b/lib/sidebars/projects/panel.rb
index 58f2e9e7fb4..8d81c197f71 100644
--- a/lib/sidebars/projects/panel.rb
+++ b/lib/sidebars/projects/panel.rb
@@ -18,6 +18,7 @@ module Sidebars
add_menu(Sidebars::Projects::Menus::SecurityComplianceMenu.new(context))
add_menu(Sidebars::Projects::Menus::OperationsMenu.new(context))
add_menu(Sidebars::Projects::Menus::PackagesRegistriesMenu.new(context))
+ add_menu(Sidebars::Projects::Menus::AnalyticsMenu.new(context))
end
override :render_raw_menus_partial