diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
commit | 41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch) | |
tree | 9c8d89a8624828992f06d892cd2f43818ff5dcc8 /app/presenters | |
parent | 0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff) |
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'app/presenters')
-rw-r--r-- | app/presenters/alert_management/alert_presenter.rb | 1 | ||||
-rw-r--r-- | app/presenters/blob_presenter.rb | 21 | ||||
-rw-r--r-- | app/presenters/blobs/notebook_presenter.rb | 9 | ||||
-rw-r--r-- | app/presenters/ci/build_runner_presenter.rb | 5 | ||||
-rw-r--r-- | app/presenters/ci/pipeline_presenter.rb | 1 | ||||
-rw-r--r-- | app/presenters/clusterable_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/environment_presenter.rb | 2 | ||||
-rw-r--r-- | app/presenters/gitlab/blame_presenter.rb | 9 | ||||
-rw-r--r-- | app/presenters/instance_clusterable_presenter.rb | 5 | ||||
-rw-r--r-- | app/presenters/label_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/merge_request_presenter.rb | 21 | ||||
-rw-r--r-- | app/presenters/project_clusterable_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/project_presenter.rb | 17 | ||||
-rw-r--r-- | app/presenters/release_presenter.rb | 6 | ||||
-rw-r--r-- | app/presenters/releases/evidence_presenter.rb | 2 | ||||
-rw-r--r-- | app/presenters/search_service_presenter.rb | 2 | ||||
-rw-r--r-- | app/presenters/user_presenter.rb | 20 |
17 files changed, 89 insertions, 44 deletions
diff --git a/app/presenters/alert_management/alert_presenter.rb b/app/presenters/alert_management/alert_presenter.rb index b692935d229..659e991e9d8 100644 --- a/app/presenters/alert_management/alert_presenter.rb +++ b/app/presenters/alert_management/alert_presenter.rb @@ -3,7 +3,6 @@ module AlertManagement class AlertPresenter < Gitlab::View::Presenter::Delegated include IncidentManagement::Settings - include ActionView::Helpers::UrlHelper presents ::AlertManagement::Alert delegator_override_with Gitlab::Utils::StrongMemoize # This module inclusion is expected. See https://gitlab.com/gitlab-org/gitlab/-/issues/352884. diff --git a/app/presenters/blob_presenter.rb b/app/presenters/blob_presenter.rb index 47b72df32a2..aeab914dc9e 100644 --- a/app/presenters/blob_presenter.rb +++ b/app/presenters/blob_presenter.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require 'ipynbdiff' class BlobPresenter < Gitlab::View::Presenter::Delegated include ApplicationHelper @@ -56,13 +55,19 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated end def replace_path - url_helpers.project_create_blob_path(project, ref_qualified_path) + url_helpers.project_update_blob_path(project, ref_qualified_path) end def pipeline_editor_path project_ci_pipeline_editor_path(project, branch_name: blob.commit_id) if can_collaborate_with_project?(project) && blob.path == project.ci_config_path_or_default end + def gitpod_blob_url + return unless Gitlab::CurrentSettings.gitpod_enabled && !current_user.nil? && current_user.gitpod_enabled + + "#{Gitlab::CurrentSettings.gitpod_url}##{url_helpers.project_tree_url(project, tree_join(blob.commit_id, blob.path || ''))}" + end + def find_file_path url_helpers.project_find_file_path(project, ref_qualified_path) end @@ -104,6 +109,10 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated fork_path_for_current_user(project, ide_edit_path) end + def fork_and_view_path + fork_path_for_current_user(project, web_path) + end + def can_modify_blob? super(blob, project, blob.commit_id) end @@ -128,6 +137,14 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated external_storage_url_or_path(url_helpers.project_raw_url(project, ref_qualified_path), project) end + def code_navigation_path + Gitlab::CodeNavigationPath.new(project, blob.commit_id).full_json_path_for(blob.path) + end + + def project_blob_path_root + project_blob_path(project, blob.commit_id) + end + private def url_helpers diff --git a/app/presenters/blobs/notebook_presenter.rb b/app/presenters/blobs/notebook_presenter.rb new file mode 100644 index 00000000000..16ae1e71191 --- /dev/null +++ b/app/presenters/blobs/notebook_presenter.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Blobs + class NotebookPresenter < ::BlobPresenter + def gitattr_language + 'md' + end + end +end diff --git a/app/presenters/ci/build_runner_presenter.rb b/app/presenters/ci/build_runner_presenter.rb index 8e1b675d051..082993130a1 100644 --- a/app/presenters/ci/build_runner_presenter.rb +++ b/app/presenters/ci/build_runner_presenter.rb @@ -105,10 +105,7 @@ module Ci end def refspec_for_persistent_ref - # Use persistent_ref.sha because it sometimes causes 'git fetch' to do - # less work. See - # https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/746. - "+#{pipeline.persistent_ref.sha}:#{pipeline.persistent_ref.path}" + "+#{pipeline.persistent_ref.path}:#{pipeline.persistent_ref.path}" end def persistent_ref_exist? diff --git a/app/presenters/ci/pipeline_presenter.rb b/app/presenters/ci/pipeline_presenter.rb index 2818e6da036..410b633df50 100644 --- a/app/presenters/ci/pipeline_presenter.rb +++ b/app/presenters/ci/pipeline_presenter.rb @@ -5,7 +5,6 @@ module Ci include Gitlab::Utils::StrongMemoize delegator_override_with Gitlab::Utils::StrongMemoize # This module inclusion is expected. See https://gitlab.com/gitlab-org/gitlab/-/issues/352884. - delegator_override_with ActionView::Helpers::TagHelper # TODO: Remove `ActionView::Helpers::UrlHelper` inclusion as it overrides `Ci::Pipeline#tag` # We use a class method here instead of a constant, allowing EE to redefine # the returned `Hash` more easily. diff --git a/app/presenters/clusterable_presenter.rb b/app/presenters/clusterable_presenter.rb index cc466e0ff81..82152ce42ae 100644 --- a/app/presenters/clusterable_presenter.rb +++ b/app/presenters/clusterable_presenter.rb @@ -32,6 +32,10 @@ class ClusterablePresenter < Gitlab::View::Presenter::Delegated new_polymorphic_path([clusterable, :cluster], options) end + def connect_path + polymorphic_path([clusterable, :clusters], action: :connect) + end + def authorize_aws_role_path polymorphic_path([clusterable, :clusters], action: :authorize_aws_role) end diff --git a/app/presenters/environment_presenter.rb b/app/presenters/environment_presenter.rb index 6c8da86187c..fe828fb9fd8 100644 --- a/app/presenters/environment_presenter.rb +++ b/app/presenters/environment_presenter.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true class EnvironmentPresenter < Gitlab::View::Presenter::Delegated - include ActionView::Helpers::UrlHelper - presents ::Environment, as: :environment def path diff --git a/app/presenters/gitlab/blame_presenter.rb b/app/presenters/gitlab/blame_presenter.rb index e9340a42e51..5dd2f3adda5 100644 --- a/app/presenters/gitlab/blame_presenter.rb +++ b/app/presenters/gitlab/blame_presenter.rb @@ -2,7 +2,6 @@ module Gitlab class BlamePresenter < Gitlab::View::Presenter::Simple - include ActionView::Helpers::UrlHelper include ActionView::Helpers::TranslationHelper include ActionView::Context include AvatarsHelper @@ -75,5 +74,13 @@ module Gitlab def project_duration @project_duration ||= age_map_duration(groups, project) end + + def link_to(*args, &block) + ActionController::Base.helpers.link_to(*args, &block) + end + + def mail_to(*args, &block) + ActionController::Base.helpers.mail_to(*args, &block) + end end end diff --git a/app/presenters/instance_clusterable_presenter.rb b/app/presenters/instance_clusterable_presenter.rb index f2550eb17e3..9e4a3b403ea 100644 --- a/app/presenters/instance_clusterable_presenter.rb +++ b/app/presenters/instance_clusterable_presenter.rb @@ -38,6 +38,11 @@ class InstanceClusterablePresenter < ClusterablePresenter admin_cluster_path(cluster, params) end + override :connect_path + def connect_path + connect_admin_clusters_path + end + override :create_user_clusters_path def create_user_clusters_path create_user_admin_clusters_path diff --git a/app/presenters/label_presenter.rb b/app/presenters/label_presenter.rb index 8d604f9a0f6..6929bf79fdf 100644 --- a/app/presenters/label_presenter.rb +++ b/app/presenters/label_presenter.rb @@ -14,6 +14,10 @@ class LabelPresenter < Gitlab::View::Presenter::Delegated end end + def text_color_class + "gl-label-text-#{label.color.contrast.luminosity}" + end + def destroy_path case label when GroupLabel then group_label_path(label.group, label) diff --git a/app/presenters/merge_request_presenter.rb b/app/presenters/merge_request_presenter.rb index 8450679dd79..6dd3908b21d 100644 --- a/app/presenters/merge_request_presenter.rb +++ b/app/presenters/merge_request_presenter.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true class MergeRequestPresenter < Gitlab::View::Presenter::Delegated - include ActionView::Helpers::UrlHelper include GitlabRoutingHelper include MarkupHelper include TreeHelper @@ -150,7 +149,11 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated ) end - def assign_to_closing_issues_link + def assign_to_closing_issues_path + assign_related_issues_project_merge_request_path(project, merge_request) + end + + def assign_to_closing_issues_count # rubocop: disable CodeReuse/ServiceClass issues = MergeRequests::AssignIssuesService.new(project: project, current_user: current_user, @@ -158,14 +161,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated merge_request: merge_request, closes_issues: closing_issues }).assignable_issues - path = assign_related_issues_project_merge_request_path(project, merge_request) - if issues.present? - if issues.count > 1 - link_to _('Assign yourself to these issues'), path, method: :post - else - link_to _('Assign yourself to this issue'), path, method: :post - end - end + issues.count # rubocop: enable CodeReuse/ServiceClass end @@ -290,6 +286,11 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated def user_can_fork_project? can?(current_user, :fork_project, project) end + + # Avoid including ActionView::Helpers::UrlHelper + def link_to(*args) + ApplicationController.helpers.link_to(*args) + end end MergeRequestPresenter.prepend_mod_with('MergeRequestPresenter') diff --git a/app/presenters/project_clusterable_presenter.rb b/app/presenters/project_clusterable_presenter.rb index 6c4d1143c0f..624fa1e0cb0 100644 --- a/app/presenters/project_clusterable_presenter.rb +++ b/app/presenters/project_clusterable_presenter.rb @@ -22,12 +22,12 @@ class ProjectClusterablePresenter < ClusterablePresenter override :sidebar_text def sidebar_text - s_('ClusterIntegration|With a Kubernetes cluster associated to this project, you can use review apps, deploy your applications, run your pipelines, and much more in an easy way.') + s_('ClusterIntegration|Use GitLab to deploy to your cluster, run jobs, use review apps, and more.') end override :learn_more_link def learn_more_link - ApplicationController.helpers.link_to(s_('ClusterIntegration|Learn more about Kubernetes'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer') + ApplicationController.helpers.link_to(s_('ClusterIntegration|Learn more about Kubernetes.'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer') end def metrics_dashboard_path(cluster) diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index 9e64d2d43a2..098519cdffe 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -2,7 +2,6 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated include ActionView::Helpers::NumberHelper - include ActionView::Helpers::UrlHelper include GitlabRoutingHelper include StorageHelper include TreeHelper @@ -138,17 +137,6 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated ide_edit_path(project, default_branch_or_main, 'README.md') end - def add_code_quality_ci_yml_path - add_special_file_path( - file_name: ci_config_path_or_default, - commit_message: s_("CommitMessage|Add %{file_name} and create a code quality job") % { file_name: ci_config_path_or_default }, - additional_params: { - template: 'Code-Quality', - code_quality_walkthrough: true - } - ) - end - def license_short_name license = repository.license license&.nickname || license&.name || 'LICENSE' @@ -473,6 +461,11 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated project.topics.map(&:name) end end + + # Avoid including ActionView::Helpers::UrlHelper + def content_tag(*args) + ActionController::Base.helpers.content_tag(*args) + end end ProjectPresenter.prepend_mod_with('ProjectPresenter') diff --git a/app/presenters/release_presenter.rb b/app/presenters/release_presenter.rb index dac42af38bf..fc47ece6199 100644 --- a/app/presenters/release_presenter.rb +++ b/app/presenters/release_presenter.rb @@ -1,14 +1,8 @@ # frozen_string_literal: true class ReleasePresenter < Gitlab::View::Presenter::Delegated - include ActionView::Helpers::UrlHelper - presents ::Release, as: :release - # TODO: Remove `delegate` as it's redundant due to SimpleDelegator. - delegator_override :tag, :project - delegate :project, :tag, to: :release - def commit_path return unless release.commit && can_download_code? diff --git a/app/presenters/releases/evidence_presenter.rb b/app/presenters/releases/evidence_presenter.rb index bdc053a303b..f7da6ceb8fe 100644 --- a/app/presenters/releases/evidence_presenter.rb +++ b/app/presenters/releases/evidence_presenter.rb @@ -2,8 +2,6 @@ module Releases class EvidencePresenter < Gitlab::View::Presenter::Delegated - include ActionView::Helpers::UrlHelper - presents ::Releases::Evidence, as: :evidence def filepath diff --git a/app/presenters/search_service_presenter.rb b/app/presenters/search_service_presenter.rb index 72f967b8beb..4755b88cbea 100644 --- a/app/presenters/search_service_presenter.rb +++ b/app/presenters/search_service_presenter.rb @@ -25,7 +25,7 @@ class SearchServicePresenter < Gitlab::View::Presenter::Delegated case scope when 'users' - objects.eager_load(:status) # rubocop:disable CodeReuse/ActiveRecord + objects.eager_load(:status) if objects.respond_to?(:eager_load) # rubocop:disable CodeReuse/ActiveRecord when 'commits' prepare_commits_for_rendering(objects) else diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index 5a99f10b6e7..dc775fb4160 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -11,6 +11,22 @@ class UserPresenter < Gitlab::View::Presenter::Delegated should_be_private? ? ProjectMember.none : user.project_members end + def preferences_gitpod_path + profile_preferences_path(anchor: 'user_gitpod_enabled') if application_gitpod_enabled? + end + + def profile_enable_gitpod_path + profile_path(user: { gitpod_enabled: true }) if application_gitpod_enabled? + end + + delegator_override :saved_replies + def saved_replies + return ::Users::SavedReply.none unless Feature.enabled?(:saved_replies, current_user, default_enabled: :yaml) + return ::Users::SavedReply.none unless current_user.can?(:read_saved_replies, user) + + user.saved_replies + end + private def can?(*args) @@ -20,4 +36,8 @@ class UserPresenter < Gitlab::View::Presenter::Delegated def should_be_private? !Ability.allowed?(current_user, :read_user_profile, user) end + + def application_gitpod_enabled? + Gitlab::CurrentSettings.gitpod_enabled + end end |