Commit 795ae397 authored by Matthias Käppler's avatar Matthias Käppler

Merge branch...

Merge branch '357962-vsa-the-lead-time-tile-is-linked-incorrectly-to-the-lead-time-for-changes-chart' into 'master'

Fix Value Stream Analytics doc links

See merge request gitlab-org/gitlab!84492
parents 66723832 b8ac8d75
......@@ -22,14 +22,17 @@ module Gitlab
dashboard_link =
if @stage.parent.is_a?(::Group)
helpers.group_analytics_ci_cd_analytics_path(@stage.parent, tab: 'lead-time')
helpers.group_issues_analytics_path(@stage.parent)
else
helpers.charts_project_pipelines_path(@stage.parent, chart: 'lead-time')
helpers.project_analytics_issues_analytics_path(@stage.parent)
end
[
{ "name" => _('Lead Time'), "url" => dashboard_link, "label" => s_('ValueStreamAnalytics|Dashboard') },
{ "name" => _('Lead Time'), "url" => helpers.help_page_path('user/analytics/index', anchor: 'definitions'), "docs_link" => true, "label" => s_('ValueStreamAnalytics|Go to docs') }
{ "name" => _('Lead Time'),
"url" => helpers.help_page_path('user/analytics/index', anchor: 'definitions'),
"docs_link" => true,
"label" => s_('ValueStreamAnalytics|Go to docs') }
]
end
end
......
......@@ -25,6 +25,27 @@ module Gitlab
n_('day', 'days', value)
end
def links
helpers = Gitlab::Routing.url_helpers
dashboard_link =
if @stage.parent.is_a?(::Group)
helpers.group_analytics_ci_cd_analytics_path(@stage.parent, tab: 'lead-time')
else
helpers.charts_project_pipelines_path(@stage.parent, chart: 'lead-time')
end
[
{ "name" => _('Lead Time for Changes'),
"url" => dashboard_link,
"label" => s_('ValueStreamAnalytics|Dashboard') },
{ "name" => _('Lead Time for Changes'),
"url" => helpers.help_page_path('user/analytics/index', anchor: 'definitions'),
"docs_link" => true,
"label" => s_('ValueStreamAnalytics|Go to docs') }
]
end
private
attr_reader :stage, :current_user, :options, :from, :to
......
......@@ -44,4 +44,48 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::Summary::LeadTimeForChanges do
expect(result.to_s).to eq('5.0')
end
end
describe '#links' do
subject { described_class.new(stage: stage, current_user: user, options: options).links }
it 'displays documentation link and dashboard link' do
helpers = Gitlab::Routing.url_helpers
expect(subject).to match_array(
[
{
"name" => _('Lead Time for Changes'),
"url" => helpers.group_analytics_ci_cd_analytics_path(stage.parent, tab: 'lead-time'),
"label" => s_('ValueStreamAnalytics|Dashboard')
},
{ "name" => _('Lead Time for Changes'),
"url" => helpers.help_page_path('user/analytics/index', anchor: 'definitions'),
"docs_link" => true,
"label" => s_('ValueStreamAnalytics|Go to docs') }
]
)
end
context 'for project stage' do
let(:stage) { build(:cycle_analytics_project_stage) }
it 'returns project dashboard link' do
helpers = Gitlab::Routing.url_helpers
expect(subject).to match_array(
[
{
"name" => _('Lead Time for Changes'),
"url" => helpers.charts_project_pipelines_path(stage.parent, chart: 'lead-time'),
"label" => s_('ValueStreamAnalytics|Dashboard')
},
{ "name" => _('Lead Time for Changes'),
"url" => helpers.help_page_path('user/analytics/index', anchor: 'definitions'),
"docs_link" => true,
"label" => s_('ValueStreamAnalytics|Go to docs') }
]
)
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Analytics::CycleAnalytics::Summary::LeadTime do
let(:stage) { build(:cycle_analytics_group_stage) }
let(:user) { build(:user) }
let(:options) do
{
from: 5.days.ago,
to: 2.days.ago
}
end
subject(:result) { described_class.new(stage: stage, current_user: user, options: options).value }
describe '#links' do
subject { described_class.new(stage: stage, current_user: user, options: options).links }
it 'returns docs link and group dashboard link' do
helpers = Gitlab::Routing.url_helpers
expect(subject).to match_array(
[
{ "name" => _('Lead Time'),
"url" => helpers.group_issues_analytics_path(stage.parent),
"label" => s_('ValueStreamAnalytics|Dashboard') },
{ "name" => _('Lead Time'),
"url" => helpers.help_page_path('user/analytics/index', anchor: 'definitions'),
"docs_link" => true,
"label" => s_('ValueStreamAnalytics|Go to docs') }
]
)
end
context 'for project stage' do
let(:stage) { build(:cycle_analytics_project_stage) }
it 'returns project dashboard link' do
helpers = Gitlab::Routing.url_helpers
expect(subject).to match_array(
[
{ "name" => _('Lead Time'),
"url" => helpers.project_analytics_issues_analytics_path(stage.parent),
"label" => s_('ValueStreamAnalytics|Dashboard') },
{ "name" => _('Lead Time'),
"url" => helpers.help_page_path('user/analytics/index', anchor: 'definitions'),
"docs_link" => true,
"label" => s_('ValueStreamAnalytics|Go to docs') }
]
)
end
end
end
end
......@@ -22131,6 +22131,9 @@ msgstr ""
msgid "Lead Time"
msgstr ""
msgid "Lead Time for Changes"
msgstr ""
msgid "Lead time"
msgstr ""
......
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