diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /app/presenters | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'app/presenters')
-rw-r--r-- | app/presenters/ci/build_runner_presenter.rb | 18 | ||||
-rw-r--r-- | app/presenters/ci/pipeline_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/clusters/cluster_presenter.rb | 20 | ||||
-rw-r--r-- | app/presenters/clusters/integration_presenter.rb | 11 | ||||
-rw-r--r-- | app/presenters/commit_status_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/dev_ops_report/metric_presenter.rb | 2 | ||||
-rw-r--r-- | app/presenters/packages/detail/package_presenter.rb | 1 | ||||
-rw-r--r-- | app/presenters/packages/npm/package_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/packages/nuget/packages_metadata_presenter.rb | 2 | ||||
-rw-r--r-- | app/presenters/project_presenter.rb | 16 | ||||
-rw-r--r-- | app/presenters/projects/settings/deploy_keys_presenter.rb | 29 | ||||
-rw-r--r-- | app/presenters/search_service_presenter.rb | 6 | ||||
-rw-r--r-- | app/presenters/user_presenter.rb | 6 |
13 files changed, 88 insertions, 35 deletions
diff --git a/app/presenters/ci/build_runner_presenter.rb b/app/presenters/ci/build_runner_presenter.rb index 769b793ee75..6978bc46475 100644 --- a/app/presenters/ci/build_runner_presenter.rb +++ b/app/presenters/ci/build_runner_presenter.rb @@ -33,7 +33,11 @@ module Ci end def runner_variables - variables.to_runner_variables + if Feature.enabled?(:variable_inside_variable, project) + variables.sort_and_expand_all(project, keep_undefined: true).to_runner_variables + else + variables.to_runner_variables + end end def refspecs @@ -51,6 +55,18 @@ module Ci specs end + # rubocop: disable CodeReuse/ActiveRecord + def all_dependencies + dependencies = super + + if Feature.enabled?(:preload_associations_jobs_request_api_endpoint, project, default_enabled: :yaml) + ActiveRecord::Associations::Preloader.new.preload(dependencies, :job_artifacts_archive) + end + + dependencies + end + # rubocop: enable CodeReuse/ActiveRecord + private def create_archive(artifacts) diff --git a/app/presenters/ci/pipeline_presenter.rb b/app/presenters/ci/pipeline_presenter.rb index 4e955469ddf..a2cdabb912f 100644 --- a/app/presenters/ci/pipeline_presenter.rb +++ b/app/presenters/ci/pipeline_presenter.rb @@ -14,7 +14,9 @@ module Ci activity_limit_exceeded: 'Pipeline activity limit exceeded!', size_limit_exceeded: 'Pipeline size limit exceeded!', job_activity_limit_exceeded: 'Pipeline job activity limit exceeded!', - deployments_limit_exceeded: 'Pipeline deployments limit exceeded!' } + deployments_limit_exceeded: 'Pipeline deployments limit exceeded!', + project_deleted: 'The associated project was deleted', + user_blocked: 'The user who created this pipeline is blocked' } end presents :pipeline diff --git a/app/presenters/clusters/cluster_presenter.rb b/app/presenters/clusters/cluster_presenter.rb index 541a6363edd..038fc752255 100644 --- a/app/presenters/clusters/cluster_presenter.rb +++ b/app/presenters/clusters/cluster_presenter.rb @@ -49,13 +49,25 @@ module Clusters end end - def show_path + def show_path(params: {}) if cluster.project_type? - project_cluster_path(project, cluster) + project_cluster_path(project, cluster, params) elsif cluster.group_type? - group_cluster_path(group, cluster) + group_cluster_path(group, cluster, params) elsif cluster.instance_type? - admin_cluster_path(cluster) + admin_cluster_path(cluster, params) + else + raise NotImplementedError + end + end + + def integrations_path + if cluster.project_type? + create_or_update_project_cluster_integration_path(project, cluster) + elsif cluster.group_type? + create_or_update_group_cluster_integration_path(group, cluster) + elsif cluster.instance_type? + create_or_update_admin_cluster_integration_path(cluster) else raise NotImplementedError end diff --git a/app/presenters/clusters/integration_presenter.rb b/app/presenters/clusters/integration_presenter.rb new file mode 100644 index 00000000000..57608be29b1 --- /dev/null +++ b/app/presenters/clusters/integration_presenter.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Clusters + class IntegrationPresenter < Gitlab::View::Presenter::Delegated + presents :integration + + def application_type + integration.class.name.demodulize.underscore + end + end +end diff --git a/app/presenters/commit_status_presenter.rb b/app/presenters/commit_status_presenter.rb index 714dd232efb..c8d3457b04a 100644 --- a/app/presenters/commit_status_presenter.rb +++ b/app/presenters/commit_status_presenter.rb @@ -21,7 +21,9 @@ class CommitStatusPresenter < Gitlab::View::Presenter::Delegated bridge_pipeline_is_child_pipeline: 'This job belongs to a child pipeline and cannot create further child pipelines', downstream_pipeline_creation_failed: 'The downstream pipeline could not be created', secrets_provider_not_found: 'The secrets provider can not be found', - reached_max_descendant_pipelines_depth: 'Maximum child pipeline depth has been reached' + reached_max_descendant_pipelines_depth: 'You reached the maximum depth of child pipelines', + project_deleted: 'The job belongs to a deleted project', + user_blocked: 'The user who created this job is blocked' }.freeze private_constant :CALLOUT_FAILURE_MESSAGES diff --git a/app/presenters/dev_ops_report/metric_presenter.rb b/app/presenters/dev_ops_report/metric_presenter.rb index b31dfd25a87..46b580d1f2a 100644 --- a/app/presenters/dev_ops_report/metric_presenter.rb +++ b/app/presenters/dev_ops_report/metric_presenter.rb @@ -38,7 +38,7 @@ module DevOpsReport ), Card.new( metric: subject, - title: 'Merge Requests', + title: 'Merge requests', description: 'per active user', feature: 'merge_requests', blog: 'https://8thlight.com/blog/uncle-bob/2013/02/01/The-Humble-Craftsman.html', diff --git a/app/presenters/packages/detail/package_presenter.rb b/app/presenters/packages/detail/package_presenter.rb index 9960fb4bf12..6640b0c5e94 100644 --- a/app/presenters/packages/detail/package_presenter.rb +++ b/app/presenters/packages/detail/package_presenter.rb @@ -64,7 +64,6 @@ module Packages id: pipeline_info.id, sha: pipeline_info.sha, ref: pipeline_info.ref, - git_commit_message: pipeline_info.git_commit_message, user: build_user_info(pipeline_info.user), project: { name: pipeline_info.project.name, diff --git a/app/presenters/packages/npm/package_presenter.rb b/app/presenters/packages/npm/package_presenter.rb index a3ab10d3913..4e147b4739e 100644 --- a/app/presenters/packages/npm/package_presenter.rb +++ b/app/presenters/packages/npm/package_presenter.rb @@ -35,9 +35,7 @@ module Packages private def build_package_tags - Hash[ - package_tags.map { |tag| [tag.name, tag.package.version] } - ] + package_tags.to_h { |tag| [tag.name, tag.package.version] } end def build_package_version(package, package_file) diff --git a/app/presenters/packages/nuget/packages_metadata_presenter.rb b/app/presenters/packages/nuget/packages_metadata_presenter.rb index 5f22d5dd8a1..5f5859d46c9 100644 --- a/app/presenters/packages/nuget/packages_metadata_presenter.rb +++ b/app/presenters/packages/nuget/packages_metadata_presenter.rb @@ -6,7 +6,7 @@ module Packages include Packages::Nuget::PresenterHelpers include Gitlab::Utils::StrongMemoize - COUNT = 1.freeze + COUNT = 1 def initialize(packages) @packages = packages diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index 71cbe28de25..aad1c816cf1 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -93,10 +93,6 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated filename_path(repository.license_blob&.name) end - def ci_configuration_path - filename_path(repository.gitlab_ci_yml&.name) - end - def contribution_guide_path if project && contribution_guide = repository.contribution_guide project_blob_path( @@ -131,10 +127,6 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated ide_edit_path(project, default_branch_or_master, 'CONTRIBUTING.md') end - def add_ci_yml_path - add_special_file_path(file_name: ci_config_path_or_default) - end - def add_readme_path add_special_file_path(file_name: 'README.md') end @@ -143,6 +135,10 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated ide_edit_path(project, default_branch_or_master, 'README.md') end + def add_ci_yml_path + add_special_file_path(file_name: ci_config_path_or_default) + end + def license_short_name license = repository.license license&.nickname || license&.name || 'LICENSE' @@ -384,11 +380,11 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated if cicd_missing? AnchorData.new(false, statistic_icon + _('Set up CI/CD'), - add_ci_yml_path) + project_ci_pipeline_editor_path(project)) elsif repository.gitlab_ci_yml.present? AnchorData.new(false, statistic_icon('doc-text') + _('CI/CD configuration'), - ci_configuration_path, + project_ci_pipeline_editor_path(project), 'btn-default') end end diff --git a/app/presenters/projects/settings/deploy_keys_presenter.rb b/app/presenters/projects/settings/deploy_keys_presenter.rb index 103c26289bf..13290a8e632 100644 --- a/app/presenters/projects/settings/deploy_keys_presenter.rb +++ b/app/presenters/projects/settings/deploy_keys_presenter.rb @@ -14,12 +14,20 @@ module Projects @key ||= DeployKey.new.tap { |dk| dk.deploy_keys_projects.build } end + # It includes: + # - The deploy keys enabled in the project. def enabled_keys strong_memoize(:enabled_keys) do project.deploy_keys.with_projects end end + # NOTE: This method is redundant. Use `available_project_keys` and `available_public_keys` instead. + # It includes: + # - Enabled deploy keys in projects that can be accessed by the user. + # - Instance-level public deploy keys. + # It excludes: + # - The deploy keys enabled in the project. def available_keys strong_memoize(:available_keys) do current_user @@ -29,22 +37,23 @@ module Projects end end + # It includes: + # - Enabled deploy keys in projects that can be accessed by the user. + # It excludes: + # - The deploy keys enabled in the project def available_project_keys strong_memoize(:available_project_keys) do - current_user - .project_deploy_keys - .id_not_in(enabled_keys.select(:id)) - .with_projects + current_user.project_deploy_keys.with_projects - enabled_keys end end + # It includes: + # - Instance-level public deploy keys. + # It excludes: + # - The deploy keys enabled in the project. def available_public_keys strong_memoize(:available_public_keys) do - DeployKey - .are_public - .id_not_in(enabled_keys.select(:id)) - .id_not_in(available_project_keys.select(:id)) - .with_projects + DeployKey.are_public.with_projects - enabled_keys end end @@ -78,7 +87,7 @@ module Projects # rubocop: disable CodeReuse/ActiveRecord def user_readable_project_ids - project_ids = (available_keys + available_project_keys + available_public_keys) + project_ids = (available_project_keys + available_public_keys) .flat_map { |deploy_key| deploy_key.deploy_keys_projects.map(&:project_id) } .compact .uniq diff --git a/app/presenters/search_service_presenter.rb b/app/presenters/search_service_presenter.rb index 19a90d002aa..e14446bb2f7 100644 --- a/app/presenters/search_service_presenter.rb +++ b/app/presenters/search_service_presenter.rb @@ -9,7 +9,11 @@ class SearchServicePresenter < Gitlab::View::Presenter::Delegated projects: :with_web_entity_associations, issues: :with_web_entity_associations, merge_requests: :with_web_entity_associations, - epics: :with_web_entity_associations + epics: :with_web_entity_associations, + notes: :with_web_entity_associations, + milestones: :with_web_entity_associations, + commits: :with_web_entity_associations, + blobs: :with_web_entity_associations }.freeze SORT_ENABLED_SCOPES = %w(issues merge_requests).freeze diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index 0028e6d9ef0..7cd94082bac 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -13,7 +13,11 @@ class UserPresenter < Gitlab::View::Presenter::Delegated private + def can?(*args) + user.can?(*args) + end + def should_be_private? - !can?(current_user, :read_user_profile, user) + !Ability.allowed?(current_user, :read_user_profile, user) end end |