diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 16:49:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 16:49:51 +0300 |
commit | 71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch) | |
tree | 6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /app/presenters | |
parent | a7253423e3403b8c08f8a161e5937e1488f5f407 (diff) |
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'app/presenters')
-rw-r--r-- | app/presenters/issue_email_participant_presenter.rb | 12 | ||||
-rw-r--r-- | app/presenters/issue_presenter.rb | 13 | ||||
-rw-r--r-- | app/presenters/merge_request_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/packages/detail/package_presenter.rb | 2 | ||||
-rw-r--r-- | app/presenters/packages/npm/package_presenter.rb | 2 | ||||
-rw-r--r-- | app/presenters/project_presenter.rb | 51 | ||||
-rw-r--r-- | app/presenters/projects/import_export/project_export_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/projects/settings/deploy_keys_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/user_presenter.rb | 4 |
9 files changed, 81 insertions, 15 deletions
diff --git a/app/presenters/issue_email_participant_presenter.rb b/app/presenters/issue_email_participant_presenter.rb new file mode 100644 index 00000000000..8688b9a2af1 --- /dev/null +++ b/app/presenters/issue_email_participant_presenter.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class IssueEmailParticipantPresenter < Gitlab::View::Presenter::Delegated + presents ::IssueEmailParticipant, as: :participant + + delegator_override :email + def email + return super if Ability.allowed?(current_user, :read_external_emails, participant.issue.project) + + Gitlab::Utils::Email.obfuscated_email(super, deform: true) + end +end diff --git a/app/presenters/issue_presenter.rb b/app/presenters/issue_presenter.rb index 9b4e7e22165..69d775d8125 100644 --- a/app/presenters/issue_presenter.rb +++ b/app/presenters/issue_presenter.rb @@ -15,6 +15,19 @@ class IssuePresenter < Gitlab::View::Presenter::Delegated def project_emails_disabled? issue.project.emails_disabled? end + + delegator_override :service_desk_reply_to + def service_desk_reply_to + return unless super.present? + return super if Ability.allowed?(current_user, :read_external_emails, issue.project) + + Gitlab::Utils::Email.obfuscated_email(super, deform: true) + end + + delegator_override :issue_email_participants + def issue_email_participants + issue.issue_email_participants.present(current_user: current_user) + end end IssuePresenter.prepend_mod_with('IssuePresenter') diff --git a/app/presenters/merge_request_presenter.rb b/app/presenters/merge_request_presenter.rb index 417a2f9c51f..353e0fad6fb 100644 --- a/app/presenters/merge_request_presenter.rb +++ b/app/presenters/merge_request_presenter.rb @@ -281,8 +281,8 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated end # Avoid including ActionView::Helpers::UrlHelper - def link_to(*args) - ApplicationController.helpers.link_to(*args) + def link_to(...) + ApplicationController.helpers.link_to(...) end end diff --git a/app/presenters/packages/detail/package_presenter.rb b/app/presenters/packages/detail/package_presenter.rb index b82b558f0cd..37d144d9e98 100644 --- a/app/presenters/packages/detail/package_presenter.rb +++ b/app/presenters/packages/detail/package_presenter.rb @@ -29,7 +29,7 @@ module Packages package_detail[:nuget_metadatum] = @package.nuget_metadatum if @package.nuget_metadatum package_detail[:composer_metadatum] = @package.composer_metadatum if @package.composer_metadatum package_detail[:conan_metadatum] = @package.conan_metadatum if @package.conan_metadatum - package_detail[:dependency_links] = @package.dependency_links.map(&method(:build_dependency_links)) + package_detail[:dependency_links] = @package.dependency_links.map { |link| build_dependency_links(link) } package_detail[:pipeline] = build_pipeline_info(@package.pipeline) if @package.pipeline package_detail[:pipelines] = build_pipeline_infos(@package.pipelines) if @package.pipelines.present? diff --git a/app/presenters/packages/npm/package_presenter.rb b/app/presenters/packages/npm/package_presenter.rb index fabb0a36746..57bdd373309 100644 --- a/app/presenters/packages/npm/package_presenter.rb +++ b/app/presenters/packages/npm/package_presenter.rb @@ -83,7 +83,7 @@ module Packages end def package_tags - Packages::Tag.for_packages(packages) + Packages::Tag.for_package_ids(packages.last_of_each_version_ids) .preload_package end diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index 780740fd805..392a2fcd390 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -30,7 +30,8 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated branches_anchor_data, tags_anchor_data, storage_anchor_data, - releases_anchor_data + releases_anchor_data, + environments_anchor_data ].compact.select(&:is_link) end @@ -43,6 +44,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated autodevops_anchor_data(show_auto_devops_callout: show_auto_devops_callout), kubernetes_cluster_anchor_data, gitlab_ci_anchor_data, + wiki_anchor_data, integrations_anchor_data ].compact.reject(&:is_link).sort_by.with_index { |item, idx| [item.class_modifier ? 0 : 1, idx] } end @@ -60,6 +62,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated changelog_anchor_data, contribution_guide_anchor_data, gitlab_ci_anchor_data, + wiki_anchor_data, integrations_anchor_data ].compact.reject { |item| item.is_link } end @@ -189,6 +192,22 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated project_releases_path(project)) end + def environments_anchor_data + return unless can?(current_user, :read_environment, project) + + environments_count = project.environments.available.count + return if environments_count == 0 + + AnchorData.new(true, + statistic_icon('environment') + + n_('%{strong_start}%{count}%{strong_end} Environment', '%{strong_start}%{count}%{strong_end} Environments', environments_count).html_safe % { + count: number_with_delimiter(environments_count), + strong_start: '<strong class="project-stat-value">'.html_safe, + strong_end: '</strong>'.html_safe + }, + project_environments_path(project)) + end + def commits_anchor_data AnchorData.new(true, statistic_icon('commit') + @@ -364,6 +383,16 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated end end + def wiki_anchor_data + return unless project.wiki_enabled? && can_read_wiki? + + if project.wiki.has_home_page? + AnchorData.new(false, statistic_icon('book') + _('Wiki'), project_wiki_path, 'btn-default', nil, nil) + elsif can_create_wiki? + AnchorData.new(false, statistic_icon + _('Add Wiki'), project_create_wiki_path, nil, nil, nil) + end + end + def topics_to_show project_topic_list.take(MAX_TOPICS_TO_SHOW) # rubocop: disable CodeReuse/ActiveRecord end @@ -450,8 +479,24 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated end # Avoid including ActionView::Helpers::UrlHelper - def content_tag(*args) - ActionController::Base.helpers.content_tag(*args) + def content_tag(...) + ActionController::Base.helpers.content_tag(...) + end + + def can_create_wiki? + current_user && can?(current_user, :create_wiki, project) + end + + def can_read_wiki? + current_user && can?(current_user, :read_wiki, project) + end + + def project_wiki_path + wiki_path(project.wiki) + end + + def project_create_wiki_path + "#{wiki_path(project.wiki)}?view=create" end end diff --git a/app/presenters/projects/import_export/project_export_presenter.rb b/app/presenters/projects/import_export/project_export_presenter.rb index 53c547cde9e..76cc8242da8 100644 --- a/app/presenters/projects/import_export/project_export_presenter.rb +++ b/app/presenters/projects/import_export/project_export_presenter.rb @@ -17,7 +17,7 @@ module Projects delegator_override :project_members def project_members - super + converted_group_members + super.preload(:user) + converted_group_members # rubocop:disable CodeReuse/ActiveRecord end delegator_override :description @@ -46,7 +46,7 @@ module Projects # invitee, it would make the following query return 0 rows since a NULL # user_id would be present in the subquery non_null_user_ids = project.project_members.connected_to_user.select(:user_id) - GroupMembersFinder.new(project.group).execute.where.not(user_id: non_null_user_ids) + GroupMembersFinder.new(project.group).execute.where.not(user_id: non_null_user_ids).preload(:user) end # rubocop: enable CodeReuse/ActiveRecord end diff --git a/app/presenters/projects/settings/deploy_keys_presenter.rb b/app/presenters/projects/settings/deploy_keys_presenter.rb index b760786aa4c..14aa9f26677 100644 --- a/app/presenters/projects/settings/deploy_keys_presenter.rb +++ b/app/presenters/projects/settings/deploy_keys_presenter.rb @@ -68,10 +68,6 @@ module Projects } end - def to_partial_path - '../../shared/deploy_keys/index' - end - def form_partial_path 'shared/deploy_keys/project_group_form' end diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index 26b8169d2b0..43164cca9c9 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -29,8 +29,8 @@ class UserPresenter < Gitlab::View::Presenter::Delegated private - def can?(*args) - user.can?(*args) + def can?(...) + user.can?(...) end def should_be_private? |