debian-mirror-gitlab/app/helpers/groups/observability_helper.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.4 KiB
Ruby
Raw Normal View History

2023-01-13 00:05:48 +05:30
# frozen_string_literal: true
module Groups
module ObservabilityHelper
ACTION_TO_PATH = {
'dashboards' => {
path: '/',
2023-03-04 22:38:38 +05:30
title: -> { _('Dashboards') }
2023-01-13 00:05:48 +05:30
},
'manage' => {
path: '/dashboards',
2023-03-04 22:38:38 +05:30
title: -> { _('Manage Dashboards') }
2023-01-13 00:05:48 +05:30
},
'explore' => {
path: '/explore',
2023-03-04 22:38:38 +05:30
title: -> { _('Explore') }
2023-01-13 00:05:48 +05:30
}
}.freeze
def observability_iframe_src(group)
# Format: https://observe.gitlab.com/GROUP_ID
# When running Observability UI in standalone mode (i.e. not backed by Observability Backend)
# the group-id is not required. This is mostly used for local dev
2023-03-04 22:38:38 +05:30
base_url = ENV['STANDALONE_OBSERVABILITY_UI'] == 'true' ? observability_url : "#{observability_url}/-/#{group.id}"
2023-01-13 00:05:48 +05:30
sanitized_path = if params[:observability_path] && sanitize(params[:observability_path]) != ''
CGI.unescapeHTML(sanitize(params[:observability_path]))
else
observability_config_for(params).fetch(:path)
end
"#{base_url}#{sanitized_path}"
end
def observability_page_title
observability_config_for(params).fetch(:title).call
end
private
def observability_url
Gitlab::Observability.observability_url
end
def observability_config_for(params)
ACTION_TO_PATH.fetch(params[:action], ACTION_TO_PATH['dashboards'])
end
end
end