summaryrefslogtreecommitdiff
path: root/app/presenters
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-02 21:08:01 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-02 21:08:01 +0000
commit561e1b470f0a99fe6304c8f197348c47a637d594 (patch)
tree6b361b6b0b412b70450aca167079c50a13bd88d8 /app/presenters
parent7b52c7cb634ef7047d30b0337fe477bcdcedf41d (diff)
downloadgitlab-ce-561e1b470f0a99fe6304c8f197348c47a637d594.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/presenters')
-rw-r--r--app/presenters/projects/prometheus/alert_presenter.rb6
-rw-r--r--app/presenters/snippet_blob_presenter.rb27
2 files changed, 22 insertions, 11 deletions
diff --git a/app/presenters/projects/prometheus/alert_presenter.rb b/app/presenters/projects/prometheus/alert_presenter.rb
index 7416b76b65d..02e22f8f46a 100644
--- a/app/presenters/projects/prometheus/alert_presenter.rb
+++ b/app/presenters/projects/prometheus/alert_presenter.rb
@@ -53,7 +53,7 @@ module Projects
#### Summary
#{metadata_list}
- #{alert_details}
+ #{alert_details}#{metric_embed_for_alert}
MARKDOWN
end
@@ -118,6 +118,10 @@ module Projects
def host_links
Array(hosts.value).join(' ')
end
+
+ def metric_embed_for_alert; end
end
end
end
+
+Projects::Prometheus::AlertPresenter.prepend_if_ee('EE::Projects::Prometheus::AlertPresenter')
diff --git a/app/presenters/snippet_blob_presenter.rb b/app/presenters/snippet_blob_presenter.rb
index 8e593d3a5fe..ed9c28bbc2c 100644
--- a/app/presenters/snippet_blob_presenter.rb
+++ b/app/presenters/snippet_blob_presenter.rb
@@ -3,18 +3,15 @@
class SnippetBlobPresenter < BlobPresenter
def rich_data
return if blob.binary?
+ return unless blob.rich_viewer
- if markup?
- blob.rendered_markup
- else
- highlight(plain: false)
- end
+ render_rich_partial
end
def plain_data
return if blob.binary?
- highlight(plain: !markup?)
+ highlight(plain: false)
end
def raw_path
@@ -27,10 +24,6 @@ class SnippetBlobPresenter < BlobPresenter
private
- def markup?
- blob.rich_viewer&.partial_name == 'markup'
- end
-
def snippet
blob.container
end
@@ -38,4 +31,18 @@ class SnippetBlobPresenter < BlobPresenter
def language
nil
end
+
+ 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 },
+ layout: false)
+ end
+
+ def renderer
+ proxy = Warden::Proxy.new({}, Warden::Manager.new({})).tap do |proxy_instance|
+ proxy_instance.set_user(current_user, scope: :user)
+ end
+
+ ApplicationController.renderer.new('warden' => proxy)
+ end
end