diff --git a/ee/lib/gitlab/analytics/cycle_analytics/summary/time_to_restore_service.rb b/ee/lib/gitlab/analytics/cycle_analytics/summary/time_to_restore_service.rb index 2da797ca19edddb8bb614e0e6d49db0eca70c88a..a60db1c41c4087c81aed694c7e5df3adf643420a 100644 --- a/ee/lib/gitlab/analytics/cycle_analytics/summary/time_to_restore_service.rb +++ b/ee/lib/gitlab/analytics/cycle_analytics/summary/time_to_restore_service.rb @@ -11,11 +11,27 @@ def title def links helpers = Gitlab::Routing.url_helpers + parent = @stage.parent + + dashboard_link = + if parent.is_a?(::Group) + helpers.group_analytics_ci_cd_analytics_path(parent, tab: 'time-to-restore-service') + else + helpers.charts_project_pipelines_path(parent, chart: 'time-to-restore-service') + end + [ - { "name" => _('Time to Restore Service'), + { + "name" => _('Time to Restore Service'), + "url" => dashboard_link, + "label" => s_('ValueStreamAnalytics|Dashboard') + }, + { + "name" => _('Time to Restore Service'), "url" => helpers.help_page_path('user/analytics/index', anchor: 'time-to-restore-service'), "docs_link" => true, - "label" => s_('ValueStreamAnalytics|Go to docs') } + "label" => s_('ValueStreamAnalytics|Go to docs') + } ] end diff --git a/ee/spec/lib/gitlab/analytics/cycle_analytics/summary/time_to_restore_service_spec.rb b/ee/spec/lib/gitlab/analytics/cycle_analytics/summary/time_to_restore_service_spec.rb index efb1ccb185e6f027b36aa69207ccaa28f9e74e26..87ccb5fcc00d964fddaf031360485b81689090fb 100644 --- a/ee/spec/lib/gitlab/analytics/cycle_analytics/summary/time_to_restore_service_spec.rb +++ b/ee/spec/lib/gitlab/analytics/cycle_analytics/summary/time_to_restore_service_spec.rb @@ -48,17 +48,48 @@ describe '#links' do subject { described_class.new(stage: stage, current_user: user, options: options).links } - it 'displays documentation link' do + it 'displays documentation link and group dashboard link' do helpers = Gitlab::Routing.url_helpers expect(subject).to match_array( [ - { "name" => _('Time to Restore Service'), + { + "name" => _('Time to Restore Service'), + "url" => helpers.group_analytics_ci_cd_analytics_path(stage.parent, tab: 'time-to-restore-service'), + "label" => s_('ValueStreamAnalytics|Dashboard') + }, + { + "name" => _('Time to Restore Service'), "url" => helpers.help_page_path('user/analytics/index', anchor: 'time-to-restore-service'), "docs_link" => true, - "label" => s_('ValueStreamAnalytics|Go to docs') } + "label" => s_('ValueStreamAnalytics|Go to docs') + } ] ) end + + context 'for project stage' do + let(:stage) { build(:cycle_analytics_project_stage) } + + it 'displays documentation link and project dashboard link' do + helpers = Gitlab::Routing.url_helpers + + expect(subject).to match_array( + [ + { + "name" => _('Time to Restore Service'), + "url" => helpers.charts_project_pipelines_path(stage.parent, chart: 'time-to-restore-service'), + "label" => s_('ValueStreamAnalytics|Dashboard') + }, + { + "name" => _('Time to Restore Service'), + "url" => helpers.help_page_path('user/analytics/index', anchor: 'time-to-restore-service'), + "docs_link" => true, + "label" => s_('ValueStreamAnalytics|Go to docs') + } + ] + ) + end + end end end