diff options
Diffstat (limited to 'app/services/metrics')
-rw-r--r-- | app/services/metrics/dashboard/transient_embed_service.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/app/services/metrics/dashboard/transient_embed_service.rb b/app/services/metrics/dashboard/transient_embed_service.rb new file mode 100644 index 00000000000..035707dceb9 --- /dev/null +++ b/app/services/metrics/dashboard/transient_embed_service.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +# Acts as a pass-through to allow embeddable dashboards to be +# generated based on external data, but still processed with the +# required attributes that allow the FE to render them appropriately. +# +# Use Gitlab::Metrics::Dashboard::Finder to retrive dashboards. +module Metrics + module Dashboard + class TransientEmbedService < ::Metrics::Dashboard::BaseEmbedService + extend ::Gitlab::Utils::Override + + class << self + def valid_params?(params) + [ + embedded?(params[:embedded]), + params[:embed_json] + ].all? + end + end + + private + + override :get_raw_dashboard + def get_raw_dashboard + JSON.parse(params[:embed_json]) + end + + override :sequence + def sequence + [STAGES::EndpointInserter] + end + end + end +end |