diff options
Diffstat (limited to 'app/presenters')
-rw-r--r-- | app/presenters/blob_presenter.rb | 20 | ||||
-rw-r--r-- | app/presenters/ci/runner_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/label_presenter.rb | 6 | ||||
-rw-r--r-- | app/presenters/packages/conan/package_presenter.rb | 8 | ||||
-rw-r--r-- | app/presenters/packages/detail/package_presenter.rb | 12 | ||||
-rw-r--r-- | app/presenters/packages/npm/package_presenter.rb | 6 | ||||
-rw-r--r-- | app/presenters/packages/nuget/presenter_helpers.rb | 9 | ||||
-rw-r--r-- | app/presenters/packages/pypi/package_presenter.rb | 8 | ||||
-rw-r--r-- | app/presenters/project_presenter.rb | 2 | ||||
-rw-r--r-- | app/presenters/service_hook_presenter.rb | 4 |
10 files changed, 69 insertions, 10 deletions
diff --git a/app/presenters/blob_presenter.rb b/app/presenters/blob_presenter.rb index 3bd92ebc942..2577fcaf303 100644 --- a/app/presenters/blob_presenter.rb +++ b/app/presenters/blob_presenter.rb @@ -63,6 +63,22 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated 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 find_file_path + url_helpers.project_find_file_path(project, ref_qualified_path) + end + + def blame_path + url_helpers.project_blame_path(project, ref_qualified_path) + end + + def history_path + url_helpers.project_commits_path(project, ref_qualified_path) + end + + def permalink_path + url_helpers.project_blob_path(project, File.join(project.repository.commit.sha, blob.path)) + end + # Will be overridden in EE def code_owners [] @@ -86,6 +102,10 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated user_access(project).can_push_to_branch?(blob.commit_id) end + def archived? + project.archived + end + def ide_edit_path super(project, blob.commit_id, blob.path) end diff --git a/app/presenters/ci/runner_presenter.rb b/app/presenters/ci/runner_presenter.rb index ad889d444f8..ffd826fab64 100644 --- a/app/presenters/ci/runner_presenter.rb +++ b/app/presenters/ci/runner_presenter.rb @@ -11,5 +11,9 @@ module Ci delegator_override :locked alias_method :locked, :locked? + + def executor_name + Ci::Runner::EXECUTOR_TYPE_TO_NAMES[executor_type&.to_sym] + end end end diff --git a/app/presenters/label_presenter.rb b/app/presenters/label_presenter.rb index fafade2828f..8d604f9a0f6 100644 --- a/app/presenters/label_presenter.rb +++ b/app/presenters/label_presenter.rb @@ -2,7 +2,7 @@ class LabelPresenter < Gitlab::View::Presenter::Delegated presents ::Label, as: :label - delegate :name, :full_name, to: :label_subject, prefix: :subject + delegate :name, :full_name, to: :label_subject, prefix: :subject, allow_nil: true delegator_override :subject # TODO: Fix `Gitlab::View::Presenter::Delegated#subject` not to override `Label#subject`. @@ -10,6 +10,7 @@ class LabelPresenter < Gitlab::View::Presenter::Delegated case label when GroupLabel then edit_group_label_path(label.group, label) when ProjectLabel then edit_project_label_path(label.project, label) + else edit_admin_label_path(label) end end @@ -17,6 +18,7 @@ class LabelPresenter < Gitlab::View::Presenter::Delegated case label when GroupLabel then group_label_path(label.group, label) when ProjectLabel then project_label_path(label.project, label) + else admin_label_path(label) end end @@ -43,7 +45,7 @@ class LabelPresenter < Gitlab::View::Presenter::Delegated end def label_subject - @label_subject ||= label.subject + @label_subject ||= label.subject if label.respond_to?(:subject) end private diff --git a/app/presenters/packages/conan/package_presenter.rb b/app/presenters/packages/conan/package_presenter.rb index df770777ad1..57636922676 100644 --- a/app/presenters/packages/conan/package_presenter.rb +++ b/app/presenters/packages/conan/package_presenter.rb @@ -80,7 +80,13 @@ module Packages def package_files return unless @package - @package_files ||= @package.package_files.preload_conan_file_metadata + strong_memoize(:package_files) do + if Feature.enabled?(:packages_installable_package_files, default_enabled: :yaml) + @package.installable_package_files.preload_conan_file_metadata + else + @package.package_files.preload_conan_file_metadata + end + end end def matching_reference?(package_file) diff --git a/app/presenters/packages/detail/package_presenter.rb b/app/presenters/packages/detail/package_presenter.rb index 59e50b96ab2..c257edcadfb 100644 --- a/app/presenters/packages/detail/package_presenter.rb +++ b/app/presenters/packages/detail/package_presenter.rb @@ -15,7 +15,7 @@ module Packages id: @package.id, created_at: @package.created_at, name: name, - package_files: @package.package_files.map { |pf| build_package_file_view(pf) }, + package_files: package_file_views, package_type: @package.package_type, status: @package.status, project_id: @package.project_id, @@ -38,6 +38,16 @@ module Packages private + def package_file_views + package_files = if Feature.enabled?(:packages_installable_package_files, default_enabled: :yaml) + @package.installable_package_files + else + @package.package_files + end + + package_files.map { |pf| build_package_file_view(pf) } + end + def build_package_file_view(package_file) file_view = { created_at: package_file.created_at, diff --git a/app/presenters/packages/npm/package_presenter.rb b/app/presenters/packages/npm/package_presenter.rb index c30dfa6196b..1f94187204f 100644 --- a/app/presenters/packages/npm/package_presenter.rb +++ b/app/presenters/packages/npm/package_presenter.rb @@ -26,7 +26,11 @@ module Packages .preload_npm_metadatum batched_packages.each do |package| - package_file = package.package_files.last + package_file = if Feature.enabled?(:packages_installable_package_files, default_enabled: :yaml) + package.installable_package_files.last + else + package.package_files.last + end next unless package_file diff --git a/app/presenters/packages/nuget/presenter_helpers.rb b/app/presenters/packages/nuget/presenter_helpers.rb index 09bf1e009a6..cd3e123033c 100644 --- a/app/presenters/packages/nuget/presenter_helpers.rb +++ b/app/presenters/packages/nuget/presenter_helpers.rb @@ -27,12 +27,19 @@ module Packages end def archive_url_for(package) + package_files = if Feature.enabled?(:packages_installable_package_files, default_enabled: :yaml) + package.installable_package_files + else + package.package_files + end + + package_filename = package_files.with_format(NUGET_PACKAGE_FORMAT).last&.file_name path = api_v4_projects_packages_nuget_download_package_name_package_version_package_filename_path( { id: package.project_id, package_name: package.name, package_version: package.version, - package_filename: package.package_files.with_format(NUGET_PACKAGE_FORMAT).last&.file_name + package_filename: package_filename }, true ) diff --git a/app/presenters/packages/pypi/package_presenter.rb b/app/presenters/packages/pypi/package_presenter.rb index 7997c1b9b79..33854e4d2fc 100644 --- a/app/presenters/packages/pypi/package_presenter.rb +++ b/app/presenters/packages/pypi/package_presenter.rb @@ -36,7 +36,13 @@ module Packages refs = [] @packages.map do |package| - package.package_files.each do |file| + package_files = if Feature.enabled?(:packages_installable_package_files, default_enabled: :yaml) + package.installable_package_files + else + package.package_files + end + + package_files.each do |file| url = build_pypi_package_path(file) refs << package_link(url, package.pypi_metadatum.required_python, file.file_name) diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index ec66f9bdd4f..64cd54953e2 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -364,7 +364,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated if clusters.empty? AnchorData.new(false, statistic_icon + _('Add Kubernetes cluster'), - new_project_cluster_path(project)) + project_clusters_path(project)) else cluster_link = clusters.count == 1 ? project_cluster_path(project, clusters.first) : project_clusters_path(project) diff --git a/app/presenters/service_hook_presenter.rb b/app/presenters/service_hook_presenter.rb index 91911eb3dff..f2a06358918 100644 --- a/app/presenters/service_hook_presenter.rb +++ b/app/presenters/service_hook_presenter.rb @@ -4,10 +4,10 @@ class ServiceHookPresenter < Gitlab::View::Presenter::Delegated presents ::ServiceHook, as: :service_hook def logs_details_path(log) - project_service_hook_log_path(integration.project, integration, log) + project_integration_hook_log_path(integration.project, integration, log) end def logs_retry_path(log) - retry_project_service_hook_log_path(integration.project, integration, log) + retry_project_integration_hook_log_path(integration.project, integration, log) end end |