diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /app/presenters | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'app/presenters')
-rw-r--r-- | app/presenters/ci/build_runner_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/ci/pipeline_presenter.rb | 2 | ||||
-rw-r--r-- | app/presenters/dev_ops_report/metric_presenter.rb | 2 | ||||
-rw-r--r-- | app/presenters/packages/composer/packages_presenter.rb | 15 | ||||
-rw-r--r-- | app/presenters/packages/detail/package_presenter.rb | 6 | ||||
-rw-r--r-- | app/presenters/project_presenter.rb | 89 |
6 files changed, 98 insertions, 20 deletions
diff --git a/app/presenters/ci/build_runner_presenter.rb b/app/presenters/ci/build_runner_presenter.rb index dbb77143e2e..769b793ee75 100644 --- a/app/presenters/ci/build_runner_presenter.rb +++ b/app/presenters/ci/build_runner_presenter.rb @@ -32,6 +32,10 @@ module Ci end.to_i end + def runner_variables + variables.to_runner_variables + end + def refspecs specs = [] specs << refspec_for_persistent_ref if persistent_ref_exist? diff --git a/app/presenters/ci/pipeline_presenter.rb b/app/presenters/ci/pipeline_presenter.rb index 0c68c33cbbe..4e955469ddf 100644 --- a/app/presenters/ci/pipeline_presenter.rb +++ b/app/presenters/ci/pipeline_presenter.rb @@ -61,7 +61,7 @@ module Ci link_to_merge_request: link_to_merge_request, link_to_merge_request_source_branch: link_to_merge_request_source_branch } - elsif pipeline.merge_request_pipeline? + elsif pipeline.merged_result_pipeline? _("for %{link_to_merge_request} with %{link_to_merge_request_source_branch} into %{link_to_merge_request_target_branch}") .html_safe % { link_to_merge_request: link_to_merge_request, diff --git a/app/presenters/dev_ops_report/metric_presenter.rb b/app/presenters/dev_ops_report/metric_presenter.rb index e7363293435..b31dfd25a87 100644 --- a/app/presenters/dev_ops_report/metric_presenter.rb +++ b/app/presenters/dev_ops_report/metric_presenter.rb @@ -2,6 +2,8 @@ module DevOpsReport class MetricPresenter < Gitlab::View::Presenter::Simple + delegate :created_at, to: :subject + def cards [ Card.new( diff --git a/app/presenters/packages/composer/packages_presenter.rb b/app/presenters/packages/composer/packages_presenter.rb index ed0e9d3b731..8e3f482126d 100644 --- a/app/presenters/packages/composer/packages_presenter.rb +++ b/app/presenters/packages/composer/packages_presenter.rb @@ -11,8 +11,19 @@ module Packages end def root - path = api_v4_group___packages_composer_package_name_path({ id: @group.id, package_name: '%package%$%hash%', format: '.json' }, true) - { 'packages' => [], 'provider-includes' => { 'p/%hash%.json' => { 'sha256' => provider_sha } }, 'providers-url' => path } + v1_path = expose_path(api_v4_group___packages_composer_package_name_path({ id: @group.id, package_name: '%package%$%hash%', format: '.json' }, true)) + v2_path = expose_path(api_v4_group___packages_composer_p2_package_name_path({ id: @group.id, package_name: '%package%', format: '.json' }, true)) + + { + 'packages' => [], + 'provider-includes' => { + 'p/%hash%.json' => { + 'sha256' => provider_sha + } + }, + 'providers-url' => v1_path, + 'metadata-url' => v2_path + } end def provider diff --git a/app/presenters/packages/detail/package_presenter.rb b/app/presenters/packages/detail/package_presenter.rb index dbfcfcb67f3..9960fb4bf12 100644 --- a/app/presenters/packages/detail/package_presenter.rb +++ b/app/presenters/packages/detail/package_presenter.rb @@ -42,7 +42,11 @@ module Packages created_at: package_file.created_at, download_path: package_file.download_path, file_name: package_file.file_name, - size: package_file.size + size: package_file.size, + file_md5: package_file.file_md5, + file_sha1: package_file.file_sha1, + file_sha256: package_file.file_sha256 + } file_view[:pipelines] = build_pipeline_infos(package_file.pipelines) if package_file.pipelines.present? diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index e13ef7a3811..71cbe28de25 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -10,10 +10,11 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated include BlobHelper include ChecksCollaboration include Gitlab::Utils::StrongMemoize + include Gitlab::Experiment::Dsl presents :project - AnchorData = Struct.new(:is_link, :label, :link, :class_modifier, :icon, :itemprop) + AnchorData = Struct.new(:is_link, :label, :link, :class_modifier, :icon, :itemprop, :data) MAX_TOPICS_TO_SHOW = 3 def statistic_icon(icon_name = 'plus-square-o') @@ -33,13 +34,15 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated def statistics_buttons(show_auto_devops_callout:) [ + upload_anchor_data, readme_anchor_data, license_anchor_data, changelog_anchor_data, contribution_guide_anchor_data, autodevops_anchor_data(show_auto_devops_callout: show_auto_devops_callout), kubernetes_cluster_anchor_data, - gitlab_ci_anchor_data + gitlab_ci_anchor_data, + integrations_anchor_data ].compact.reject(&:is_link).sort_by.with_index { |item, idx| [item.class_modifier ? 0 : 1, idx] } end @@ -49,12 +52,14 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated def empty_repo_statistics_buttons [ + upload_anchor_data, new_file_anchor_data, readme_anchor_data, license_anchor_data, changelog_anchor_data, contribution_guide_anchor_data, - gitlab_ci_anchor_data + gitlab_ci_anchor_data, + integrations_anchor_data ].compact.reject { |item| item.is_link } end @@ -154,6 +159,8 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated end def can_current_user_push_to_branch?(branch) + return false unless current_user + user_access(project).can_push_to_branch?(branch) end @@ -232,19 +239,50 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated empty_repo? ? nil : project_tags_path(project)) end + def upload_anchor_data + strong_memoize(:upload_anchor_data) do + next unless can_current_user_push_to_default_branch? + + experiment(:empty_repo_upload, project: project) do |e| + e.use {} + e.try do + AnchorData.new(false, + statistic_icon('upload') + _('Upload file'), + '#modal-upload-blob', + 'js-upload-file-experiment-trigger', + nil, + nil, + { + 'target_branch' => default_branch_or_master, + 'original_branch' => default_branch_or_master, + 'can_push_code' => 'true', + 'path' => project_create_blob_path(project, default_branch_or_master), + 'project_path' => project.path + } + ) + end + e.run + end + end + end + + def empty_repo_upload_experiment? + upload_anchor_data.present? + end + def new_file_anchor_data - if current_user && can_current_user_push_to_default_branch? + if can_current_user_push_to_default_branch? new_file_path = empty_repo? ? ide_edit_path(project, default_branch_or_master) : project_new_blob_path(project, default_branch_or_master) AnchorData.new(false, statistic_icon + _('New file'), new_file_path, - 'dashed') + 'btn-dashed') end end def readme_anchor_data - if current_user && can_current_user_push_to_default_branch? && readme_path.nil? + if can_current_user_push_to_default_branch? && readme_path.nil? AnchorData.new(false, statistic_icon + _('Add README'), empty_repo? ? add_readme_ide_path : add_readme_path) @@ -252,13 +290,13 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated AnchorData.new(false, statistic_icon('doc-text') + _('README'), default_view != 'readme' ? readme_path : '#readme', - 'default', + 'btn-default', 'doc-text') end end def changelog_anchor_data - if current_user && can_current_user_push_to_default_branch? && repository.changelog.blank? + if can_current_user_push_to_default_branch? && repository.changelog.blank? AnchorData.new(false, statistic_icon + _('Add CHANGELOG'), empty_repo? ? add_changelog_ide_path : add_changelog_path) @@ -266,7 +304,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated AnchorData.new(false, statistic_icon('doc-text') + _('CHANGELOG'), changelog_path, - 'default') + 'btn-default') end end @@ -277,11 +315,11 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated AnchorData.new(false, icon + content_tag(:span, license_short_name, class: 'project-stat-value'), license_path, - 'default', + 'btn-default', nil, 'license') else - if current_user && can_current_user_push_to_default_branch? + if can_current_user_push_to_default_branch? AnchorData.new(false, content_tag(:span, statistic_icon + _('Add LICENSE'), class: 'add-license-link d-flex'), empty_repo? ? add_license_ide_path : add_license_path) @@ -294,7 +332,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated end def contribution_guide_anchor_data - if current_user && can_current_user_push_to_default_branch? && repository.contribution_guide.blank? + if can_current_user_push_to_default_branch? && repository.contribution_guide.blank? AnchorData.new(false, statistic_icon + _('Add CONTRIBUTING'), empty_repo? ? add_contribution_guide_ide_path : add_contribution_guide_path) @@ -302,7 +340,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated AnchorData.new(false, statistic_icon('doc-text') + _('CONTRIBUTING'), contribution_guide_path, - 'default') + 'btn-default') end end @@ -312,7 +350,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated AnchorData.new(false, statistic_icon('settings') + _('Auto DevOps enabled'), project_settings_ci_cd_path(project, anchor: 'autodevops-settings'), - 'default') + 'btn-default') else AnchorData.new(false, statistic_icon + _('Enable Auto DevOps'), @@ -337,7 +375,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated AnchorData.new(false, _('Kubernetes'), cluster_link, - 'default') + 'btn-default') end end end @@ -351,7 +389,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated AnchorData.new(false, statistic_icon('doc-text') + _('CI/CD configuration'), ci_configuration_path, - 'default') + 'btn-default') end end @@ -389,6 +427,25 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated private + def integrations_anchor_data + experiment(:repo_integrations_link, project: project) do |e| + e.exclude! unless can?(current_user, :admin_project, project) + + e.use {} # nil control + e.try do + label = statistic_icon('settings') + _('Configure Integrations') + AnchorData.new(false, label, project_settings_integrations_path(project), nil, nil, nil, { + 'track-event': 'click', + 'track-experiment': e.name + }) + end + + e.run # call run so the return value will be the AnchorData (or nil) + + e.track(:view, value: project.id) # track an event for the view, with project id + end + end + def cicd_missing? current_user && can_current_user_push_code? && repository.gitlab_ci_yml.blank? && !auto_devops_enabled? end |