diff options
Diffstat (limited to 'app/presenters')
19 files changed, 81 insertions, 33 deletions
diff --git a/app/presenters/alert_management/alert_presenter.rb b/app/presenters/alert_management/alert_presenter.rb index a515c70152d..5bfa6dee18b 100644 --- a/app/presenters/alert_management/alert_presenter.rb +++ b/app/presenters/alert_management/alert_presenter.rb @@ -4,6 +4,7 @@ module AlertManagement class AlertPresenter < Gitlab::View::Presenter::Delegated include Gitlab::Utils::StrongMemoize include IncidentManagement::Settings + include ActionView::Helpers::UrlHelper MARKDOWN_LINE_BREAK = " \n".freeze @@ -37,8 +38,18 @@ module AlertManagement MARKDOWN end + def runbook + strong_memoize(:runbook) do + payload&.dig('runbook') + end + end + def metrics_dashboard_url; end + def details_url + details_project_alert_management_url(project, alert.iid) + end + private attr_reader :alert, :project @@ -61,6 +72,7 @@ module AlertManagement metadata << list_item('Monitoring tool', monitoring_tool) if monitoring_tool metadata << list_item('Hosts', host_links) if hosts.any? metadata << list_item('Description', description) if description.present? + metadata << list_item('GitLab alert', details_url) if details_url.present? metadata.join(MARKDOWN_LINE_BREAK) end diff --git a/app/presenters/alert_management/prometheus_alert_presenter.rb b/app/presenters/alert_management/prometheus_alert_presenter.rb index 3bcc98e6784..6b8c8183f08 100644 --- a/app/presenters/alert_management/prometheus_alert_presenter.rb +++ b/app/presenters/alert_management/prometheus_alert_presenter.rb @@ -2,6 +2,12 @@ module AlertManagement class PrometheusAlertPresenter < AlertManagement::AlertPresenter + def runbook + strong_memoize(:runbook) do + payload&.dig('annotations', 'runbook') + end + end + def metrics_dashboard_url alerting_alert.metrics_dashboard_url end diff --git a/app/presenters/blob_presenter.rb b/app/presenters/blob_presenter.rb index e0077db8d5c..cff935d51b5 100644 --- a/app/presenters/blob_presenter.rb +++ b/app/presenters/blob_presenter.rb @@ -18,6 +18,10 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated Gitlab::Routing.url_helpers.project_blob_url(blob.repository.project, File.join(blob.commit_id, blob.path)) end + def web_path + Gitlab::Routing.url_helpers.project_blob_path(blob.repository.project, File.join(blob.commit_id, blob.path)) + end + private def load_all_blob_data diff --git a/app/presenters/ci/build_runner_presenter.rb b/app/presenters/ci/build_runner_presenter.rb index 5e35bfc79ef..64461fa9193 100644 --- a/app/presenters/ci/build_runner_presenter.rb +++ b/app/presenters/ci/build_runner_presenter.rb @@ -118,3 +118,5 @@ module Ci end end end + +Ci::BuildRunnerPresenter.prepend_if_ee('EE::Ci::BuildRunnerPresenter') diff --git a/app/presenters/clusters/cluster_presenter.rb b/app/presenters/clusters/cluster_presenter.rb index c0da5310ca4..25693af4881 100644 --- a/app/presenters/clusters/cluster_presenter.rb +++ b/app/presenters/clusters/cluster_presenter.rb @@ -80,7 +80,7 @@ module Clusters 'clusters-path': clusterable.index_path, 'dashboard-endpoint': clusterable.metrics_dashboard_path(cluster), 'documentation-path': help_page_path('user/project/clusters/index', anchor: 'monitoring-your-kubernetes-cluster-ultimate'), - 'add-dashboard-documentation-path': help_page_path('user/project/integrations/prometheus.md', anchor: 'adding-a-new-dashboard-to-your-project'), + 'add-dashboard-documentation-path': help_page_path('operations/metrics/dashboards/index.md', anchor: 'add-a-new-dashboard-to-your-project'), 'empty-getting-started-svg-path': image_path('illustrations/monitoring/getting_started.svg'), 'empty-loading-svg-path': image_path('illustrations/monitoring/loading.svg'), 'empty-no-data-svg-path': image_path('illustrations/monitoring/no_data.svg'), diff --git a/app/presenters/commit_presenter.rb b/app/presenters/commit_presenter.rb index 9ded00fcb7a..c14dcab6000 100644 --- a/app/presenters/commit_presenter.rb +++ b/app/presenters/commit_presenter.rb @@ -17,10 +17,6 @@ class CommitPresenter < Gitlab::View::Presenter::Delegated commit.pipelines.any? end - def web_url - url_builder.build(commit) - end - def signature_html return unless commit.has_signature? diff --git a/app/presenters/commit_status_presenter.rb b/app/presenters/commit_status_presenter.rb index 52811e152a6..eaa7cf848cd 100644 --- a/app/presenters/commit_status_presenter.rb +++ b/app/presenters/commit_status_presenter.rb @@ -19,7 +19,8 @@ class CommitStatusPresenter < Gitlab::View::Presenter::Delegated downstream_bridge_project_not_found: 'This job could not be executed because downstream bridge project could not be found', insufficient_bridge_permissions: 'This job could not be executed because of insufficient permissions to create a downstream pipeline', 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' + downstream_pipeline_creation_failed: 'The downstream pipeline could not be created', + secrets_provider_not_found: 'The secrets provider can not be found' }.freeze private_constant :CALLOUT_FAILURE_MESSAGES diff --git a/app/presenters/event_presenter.rb b/app/presenters/event_presenter.rb index 5657e0b96bc..8f2388c2c31 100644 --- a/app/presenters/event_presenter.rb +++ b/app/presenters/event_presenter.rb @@ -24,7 +24,7 @@ class EventPresenter < Gitlab::View::Presenter::Delegated when Group [event.group, event.target] when Project - [event.project.namespace.becomes(Namespace), event.project, event.target] + [event.project, event.target] else '' end diff --git a/app/presenters/gitlab/blame_presenter.rb b/app/presenters/gitlab/blame_presenter.rb index db2fc52a88b..3c581d4b115 100644 --- a/app/presenters/gitlab/blame_presenter.rb +++ b/app/presenters/gitlab/blame_presenter.rb @@ -76,7 +76,7 @@ module Gitlab end def versions_sprite_icon - @versions_sprite_icon ||= sprite_icon('doc-versions', size: 16, css_class: 'doc-versions align-text-bottom') + @versions_sprite_icon ||= sprite_icon('doc-versions', css_class: 'doc-versions align-text-bottom') end end end diff --git a/app/presenters/issue_presenter.rb b/app/presenters/issue_presenter.rb index 004813d0374..185fcd3e934 100644 --- a/app/presenters/issue_presenter.rb +++ b/app/presenters/issue_presenter.rb @@ -3,10 +3,6 @@ class IssuePresenter < Gitlab::View::Presenter::Delegated presents :issue - def web_url - url_builder.build(issue) - end - def issue_path url_builder.build(issue, only_path: true) end diff --git a/app/presenters/merge_request_presenter.rb b/app/presenters/merge_request_presenter.rb index bccf0340749..1ff02412994 100644 --- a/app/presenters/merge_request_presenter.rb +++ b/app/presenters/merge_request_presenter.rb @@ -179,7 +179,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated return false unless source_branch_exists? !!::Gitlab::UserAccess - .new(current_user, project: source_project) + .new(current_user, container: source_project) .can_push_to_branch?(source_branch) end @@ -202,10 +202,6 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated end end - def web_url - Gitlab::UrlBuilder.build(merge_request) - end - def subscribed? merge_request.subscribed?(current_user, merge_request.target_project) end diff --git a/app/presenters/packages/detail/package_presenter.rb b/app/presenters/packages/detail/package_presenter.rb index f6e068302c1..bdb2e34854e 100644 --- a/app/presenters/packages/detail/package_presenter.rb +++ b/app/presenters/packages/detail/package_presenter.rb @@ -22,6 +22,8 @@ module Packages package_detail[:maven_metadatum] = @package.maven_metadatum if @package.maven_metadatum 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[:pipeline] = build_pipeline_info(@package.build_info.pipeline) if @package.build_info @@ -49,7 +51,9 @@ module Packages user: build_user_info(pipeline_info.user), project: { name: pipeline_info.project.name, - web_url: pipeline_info.project.web_url + web_url: pipeline_info.project.web_url, + pipeline_url: Gitlab::Routing.url_helpers.project_pipeline_url(pipeline_info.project, pipeline_info), + commit_url: Gitlab::Routing.url_helpers.project_commit_url(pipeline_info.project, pipeline_info.sha) } } end diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index 4e8dae1d508..86fd405812e 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -16,7 +16,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated MAX_TOPICS_TO_SHOW = 3 def statistic_icon(icon_name = 'plus-square-o') - sprite_icon(icon_name, size: 16, css_class: 'icon gl-mr-2') + sprite_icon(icon_name, css_class: 'icon gl-mr-2') end def statistics_anchors(show_auto_devops_callout:) diff --git a/app/presenters/projects/prometheus/alert_presenter.rb b/app/presenters/projects/prometheus/alert_presenter.rb index 1cf8b202810..49859f27edd 100644 --- a/app/presenters/projects/prometheus/alert_presenter.rb +++ b/app/presenters/projects/prometheus/alert_presenter.rb @@ -77,6 +77,15 @@ module Projects end end + def details_url + return unless am_alert + + ::Gitlab::Routing.url_helpers.details_project_alert_management_url( + project, + am_alert.iid + ) + end + private def alert_title @@ -97,6 +106,7 @@ module Projects metadata << list_item(service.label.humanize, service.value) if service metadata << list_item(monitoring_tool.label.humanize, monitoring_tool.value) if monitoring_tool metadata << list_item(hosts.label.humanize, host_links) if hosts + metadata << list_item('GitLab alert', details_url) if details_url metadata.join(MARKDOWN_LINE_BREAK) end @@ -173,7 +183,7 @@ module Projects { panel_groups: [{ panels: [{ - type: 'line-graph', + type: 'area-chart', title: title, y_label: y_label, metrics: [{ diff --git a/app/presenters/prometheus_alert_presenter.rb b/app/presenters/prometheus_alert_presenter.rb new file mode 100644 index 00000000000..99e24bdcdb9 --- /dev/null +++ b/app/presenters/prometheus_alert_presenter.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class PrometheusAlertPresenter < Gitlab::View::Presenter::Delegated + include ActionView::Helpers::UrlHelper + + presents :prometheus_alert + + def humanized_text + operator_text = + case prometheus_alert.operator + when 'lt' then s_('PrometheusAlerts|is less than') + when 'eq' then s_('PrometheusAlerts|is equal to') + when 'gt' then s_('PrometheusAlerts|exceeded') + end + + "#{operator_text} #{prometheus_alert.threshold}#{prometheus_alert.prometheus_metric.unit}" + end +end diff --git a/app/presenters/snippet_blob_presenter.rb b/app/presenters/snippet_blob_presenter.rb index d27fe751ab7..abe95f5c44d 100644 --- a/app/presenters/snippet_blob_presenter.rb +++ b/app/presenters/snippet_blob_presenter.rb @@ -4,7 +4,6 @@ class SnippetBlobPresenter < BlobPresenter include GitlabRoutingHelper def rich_data - return if blob.binary? return unless blob.rich_viewer render_rich_partial @@ -17,9 +16,11 @@ class SnippetBlobPresenter < BlobPresenter end def raw_path - return gitlab_raw_snippet_blob_path(blob) if snippet_multiple_files? + snippet_blob_raw_route(only_path: true) + end - gitlab_raw_snippet_path(snippet) + def raw_url + snippet_blob_raw_route end private @@ -38,7 +39,7 @@ class SnippetBlobPresenter < BlobPresenter def render_rich_partial renderer.render("projects/blob/viewers/_#{blob.rich_viewer.partial_name}", - locals: { viewer: blob.rich_viewer, blob: blob, blob_raw_path: raw_path }, + locals: { viewer: blob.rich_viewer, blob: blob, blob_raw_path: raw_path, blob_raw_url: raw_url }, layout: false) end @@ -49,4 +50,10 @@ class SnippetBlobPresenter < BlobPresenter ApplicationController.renderer.new('warden' => proxy) end + + def snippet_blob_raw_route(only_path: false) + return gitlab_raw_snippet_blob_url(snippet, blob.path, only_path: only_path) if snippet_multiple_files? + + gitlab_raw_snippet_url(snippet, only_path: only_path) + end end diff --git a/app/presenters/snippet_presenter.rb b/app/presenters/snippet_presenter.rb index 62a90025ce1..d814c4404b6 100644 --- a/app/presenters/snippet_presenter.rb +++ b/app/presenters/snippet_presenter.rb @@ -3,12 +3,8 @@ class SnippetPresenter < Gitlab::View::Presenter::Delegated presents :snippet - def web_url - Gitlab::UrlBuilder.build(snippet) - end - def raw_url - Gitlab::UrlBuilder.build(snippet, raw: true) + url_builder.build(snippet, raw: true) end def ssh_url_to_repo diff --git a/app/presenters/tree_entry_presenter.rb b/app/presenters/tree_entry_presenter.rb index 7bb10cd1455..216b3b0d4c9 100644 --- a/app/presenters/tree_entry_presenter.rb +++ b/app/presenters/tree_entry_presenter.rb @@ -6,4 +6,8 @@ class TreeEntryPresenter < Gitlab::View::Presenter::Delegated def web_url Gitlab::Routing.url_helpers.project_tree_url(tree.repository.project, File.join(tree.commit_id, tree.path)) end + + def web_path + Gitlab::Routing.url_helpers.project_tree_path(tree.repository.project, File.join(tree.commit_id, tree.path)) + end end diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index 14ef53e9ec8..f201b36346f 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -2,8 +2,4 @@ class UserPresenter < Gitlab::View::Presenter::Delegated presents :user - - def web_url - Gitlab::Routing.url_helpers.user_url(user) - end end |