diff options
Diffstat (limited to 'lib/banzai/filter/inline_observability_filter.rb')
-rw-r--r-- | lib/banzai/filter/inline_observability_filter.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/banzai/filter/inline_observability_filter.rb b/lib/banzai/filter/inline_observability_filter.rb new file mode 100644 index 00000000000..27b89073a0e --- /dev/null +++ b/lib/banzai/filter/inline_observability_filter.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Banzai + module Filter + class InlineObservabilityFilter < ::Banzai::Filter::InlineEmbedsFilter + # Placeholder element for the frontend to use as an + # injection point for observability. + def create_element(url) + doc.document.create_element( + 'div', + class: 'js-render-observability', + 'data-frame-url': url + ) + end + + # Search params for selecting observability links. + def xpath_search + "descendant-or-self::a[starts-with(@href, '#{Gitlab::Observability.observability_url}')]" + end + + # Creates a new element based on the parameters + # obtained from the target link + def element_to_embed(node) + url = node['href'] + + create_element(url) + end + end + end +end |