Commit d37eec72 authored by Markus Koller's avatar Markus Koller

Merge branch 'drop-banzai-rendering-in-vsa' into 'master'

Replace Banzai based label rendering in VSA

See merge request gitlab-org/gitlab!75415
parents 67d8f308 c89bb614
......@@ -3,6 +3,10 @@
module Analytics
module CycleAnalytics
class StageEntity < Grape::Entity
include ActionView::Context
include LabelsHelper
include ActionView::Helpers::TagHelper
expose :title
expose :hidden
expose :legend
......@@ -43,10 +47,20 @@ module Analytics
html_description(object.end_event)
end
# Avoid including ActionView::Helpers::UrlHelper
def link_to(*args)
ActionController::Base.helpers.link_to(*args)
end
private
def html_description(event)
Banzai::Renderer.render(event.markdown_description, { group: object.group, project: nil })
options = {}
if event.label_based?
options[:label_html] = render_label(event.label, link: '', small: true, tooltip: true)
end
content_tag(:p) { event.html_description(options).html_safe }
end
end
end
......
......@@ -13,8 +13,8 @@ module Gitlab
:issue_label_added
end
def markdown_description
s_("CycleAnalyticsEvent|%{label_reference} label was added to the issue") % { label_reference: label.to_reference }
def html_description(options)
s_("CycleAnalyticsEvent|%{label_reference} label was added to the issue") % { label_reference: options.fetch(:label_html) }
end
def object_type
......
......@@ -13,8 +13,8 @@ module Gitlab
:issue_label_removed
end
def markdown_description
s_("CycleAnalyticsEvent|%{label_reference} label was removed from the issue") % { label_reference: label.to_reference }
def html_description(options = {})
s_("CycleAnalyticsEvent|%{label_reference} label was removed from the issue") % { label_reference: options.fetch(:label_html) }
end
def object_type
......
......@@ -13,8 +13,8 @@ module Gitlab
:merge_request_label_added
end
def markdown_description
s_("CycleAnalyticsEvent|%{label_reference} label was added to the merge request") % { label_reference: label.to_reference }
def html_description(options)
s_("CycleAnalyticsEvent|%{label_reference} label was added to the merge request") % { label_reference: options.fetch(:label_html) }
end
def object_type
......
......@@ -13,8 +13,8 @@ module Gitlab
:merge_request_label_removed
end
def markdown_description
s_("CycleAnalyticsEvent|%{label_reference} label was removed from the merge request") % { label_reference: label.to_reference }
def html_description(options)
s_("CycleAnalyticsEvent|%{label_reference} label was removed from the merge request") % { label_reference: options.fetch(:label_html) }
end
def object_type
......
......@@ -19,7 +19,7 @@ module Gitlab
raise NotImplementedError
end
def markdown_description
def html_description(options = {})
self.class.name
end
......
......@@ -9,7 +9,7 @@ RSpec.shared_examples_for 'value stream analytics event' do
it { expect(described_class.identifier).to be_a_kind_of(Symbol) }
it { expect(instance.object_type.ancestors).to include(ApplicationRecord) }
it { expect(instance).to respond_to(:timestamp_projection) }
it { expect(instance).to respond_to(:markdown_description) }
it { expect(instance).to respond_to(:html_description) }
it { expect(instance.column_list).to be_a_kind_of(Array) }
describe '#apply_query_customization' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment