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 @@ ...@@ -3,6 +3,10 @@
module Analytics module Analytics
module CycleAnalytics module CycleAnalytics
class StageEntity < Grape::Entity class StageEntity < Grape::Entity
include ActionView::Context
include LabelsHelper
include ActionView::Helpers::TagHelper
expose :title expose :title
expose :hidden expose :hidden
expose :legend expose :legend
...@@ -43,10 +47,20 @@ module Analytics ...@@ -43,10 +47,20 @@ module Analytics
html_description(object.end_event) html_description(object.end_event)
end end
# Avoid including ActionView::Helpers::UrlHelper
def link_to(*args)
ActionController::Base.helpers.link_to(*args)
end
private private
def html_description(event) 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 end
end end
......
...@@ -13,8 +13,8 @@ module Gitlab ...@@ -13,8 +13,8 @@ module Gitlab
:issue_label_added :issue_label_added
end end
def markdown_description def html_description(options)
s_("CycleAnalyticsEvent|%{label_reference} label was added to the issue") % { label_reference: label.to_reference } s_("CycleAnalyticsEvent|%{label_reference} label was added to the issue") % { label_reference: options.fetch(:label_html) }
end end
def object_type def object_type
......
...@@ -13,8 +13,8 @@ module Gitlab ...@@ -13,8 +13,8 @@ module Gitlab
:issue_label_removed :issue_label_removed
end end
def markdown_description def html_description(options = {})
s_("CycleAnalyticsEvent|%{label_reference} label was removed from the issue") % { label_reference: label.to_reference } s_("CycleAnalyticsEvent|%{label_reference} label was removed from the issue") % { label_reference: options.fetch(:label_html) }
end end
def object_type def object_type
......
...@@ -13,8 +13,8 @@ module Gitlab ...@@ -13,8 +13,8 @@ module Gitlab
:merge_request_label_added :merge_request_label_added
end end
def markdown_description def html_description(options)
s_("CycleAnalyticsEvent|%{label_reference} label was added to the merge request") % { label_reference: label.to_reference } s_("CycleAnalyticsEvent|%{label_reference} label was added to the merge request") % { label_reference: options.fetch(:label_html) }
end end
def object_type def object_type
......
...@@ -13,8 +13,8 @@ module Gitlab ...@@ -13,8 +13,8 @@ module Gitlab
:merge_request_label_removed :merge_request_label_removed
end end
def markdown_description def html_description(options)
s_("CycleAnalyticsEvent|%{label_reference} label was removed from the merge request") % { label_reference: label.to_reference } s_("CycleAnalyticsEvent|%{label_reference} label was removed from the merge request") % { label_reference: options.fetch(:label_html) }
end end
def object_type def object_type
......
...@@ -19,7 +19,7 @@ module Gitlab ...@@ -19,7 +19,7 @@ module Gitlab
raise NotImplementedError raise NotImplementedError
end end
def markdown_description def html_description(options = {})
self.class.name self.class.name
end end
......
...@@ -9,7 +9,7 @@ RSpec.shared_examples_for 'value stream analytics event' do ...@@ -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(described_class.identifier).to be_a_kind_of(Symbol) }
it { expect(instance.object_type.ancestors).to include(ApplicationRecord) } it { expect(instance.object_type.ancestors).to include(ApplicationRecord) }
it { expect(instance).to respond_to(:timestamp_projection) } 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) } it { expect(instance.column_list).to be_a_kind_of(Array) }
describe '#apply_query_customization' do 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