Commit 6b844bc7 authored by Gilang Gumilar's avatar Gilang Gumilar

Sort by title and make Value Stream the first item

parent 0ce9f537
...@@ -14,9 +14,9 @@ module AnalyticsNavbarHelper ...@@ -14,9 +14,9 @@ module AnalyticsNavbarHelper
def project_analytics_navbar_links(project, current_user) def project_analytics_navbar_links(project, current_user)
[ [
cycle_analytics_navbar_link(project, current_user, 0), cycle_analytics_navbar_link(project, current_user, -1),
repository_analytics_navbar_link(project, current_user, 3), repository_analytics_navbar_link(project, current_user),
ci_cd_analytics_navbar_link(project, current_user, 5) ci_cd_analytics_navbar_link(project, current_user)
].compact ].compact
end end
...@@ -30,29 +30,29 @@ module AnalyticsNavbarHelper ...@@ -30,29 +30,29 @@ module AnalyticsNavbarHelper
NavbarSubItem.new(args) NavbarSubItem.new(args)
end end
def cycle_analytics_navbar_link(project, current_user, index = 0) def cycle_analytics_navbar_link(project, current_user, priority = 0)
return unless project_nav_tab?(:cycle_analytics) return unless project_nav_tab?(:cycle_analytics)
navbar_sub_item( navbar_sub_item(
title: _('Value Stream'), title: _('Value Stream'),
path: 'cycle_analytics#show', path: 'cycle_analytics#show',
link: project_cycle_analytics_path(project), link: project_cycle_analytics_path(project),
link_to_options: { class: 'shortcuts-project-cycle-analytics', data: { index: index } } link_to_options: { class: 'shortcuts-project-cycle-analytics', data: { priority: priority } }
) )
end end
def repository_analytics_navbar_link(project, current_user, index = 0) def repository_analytics_navbar_link(project, current_user, priority = 0)
return if project.empty_repo? return if project.empty_repo?
navbar_sub_item( navbar_sub_item(
title: _('Repository'), title: _('Repository'),
path: 'graphs#charts', path: 'graphs#charts',
link: charts_project_graph_path(project, current_ref), link: charts_project_graph_path(project, current_ref),
link_to_options: { class: 'shortcuts-repository-charts', data: { index: index } } link_to_options: { class: 'shortcuts-repository-charts', data: { priority: priority } }
) )
end end
def ci_cd_analytics_navbar_link(project, current_user, index = 0) def ci_cd_analytics_navbar_link(project, current_user, priority = 0)
return unless project_nav_tab?(:pipelines) return unless project_nav_tab?(:pipelines)
return unless project.feature_available?(:builds, current_user) || !project.empty_repo? return unless project.feature_available?(:builds, current_user) || !project.empty_repo?
...@@ -60,7 +60,7 @@ module AnalyticsNavbarHelper ...@@ -60,7 +60,7 @@ module AnalyticsNavbarHelper
title: _('CI / CD'), title: _('CI / CD'),
path: 'pipelines#charts', path: 'pipelines#charts',
link: charts_project_pipelines_path(project), link: charts_project_pipelines_path(project),
link_to_options: { data: { index: index } } link_to_options: { data: { priority: priority } }
) )
end end
end end
......
- navbar_links = links.sort_by { |link| [link.link_to_options.fetch(:data, {}).fetch(:index, 0), link.title] } - navbar_links = links.sort_by { |link| [link.link_to_options.fetch(:data, {}).fetch(:priority, 0), link.title] }
- all_paths = navbar_links.map(&:path) - all_paths = navbar_links.map(&:path)
- analytics_link = navbar_links.find { |link| link.title == _('Value Stream') } || navbar_links.first - analytics_link = navbar_links.find { |link| link.title == _('Value Stream') } || navbar_links.first
......
...@@ -7,9 +7,9 @@ module EE ...@@ -7,9 +7,9 @@ module EE
override :project_analytics_navbar_links override :project_analytics_navbar_links
def project_analytics_navbar_links(project, current_user) def project_analytics_navbar_links(project, current_user)
super + [ super + [
project_issues_analytics_navbar_link(project, current_user, 1), insights_navbar_link(project, current_user),
insights_navbar_link(project, current_user, 2), code_review_analytics_navbar_link(project, current_user),
code_review_analytics_navbar_link(project, current_user, 4) project_issues_analytics_navbar_link(project, current_user)
].compact ].compact
end end
...@@ -26,7 +26,7 @@ module EE ...@@ -26,7 +26,7 @@ module EE
private private
def project_issues_analytics_navbar_link(project, current_user, index = 0) def project_issues_analytics_navbar_link(project, current_user, priority = 0)
return unless ::Feature.enabled?(:project_level_issues_analytics, project, default_enabled: true) return unless ::Feature.enabled?(:project_level_issues_analytics, project, default_enabled: true)
return unless project_nav_tab?(:issues_analytics) return unless project_nav_tab?(:issues_analytics)
...@@ -34,7 +34,7 @@ module EE ...@@ -34,7 +34,7 @@ module EE
title: _('Issues'), title: _('Issues'),
path: 'issues_analytics#show', path: 'issues_analytics#show',
link: project_analytics_issues_analytics_path(project), link: project_analytics_issues_analytics_path(project),
link_to_options: { data: { index: index } } link_to_options: { data: { priority: priority } }
) )
end end
...@@ -90,25 +90,25 @@ module EE ...@@ -90,25 +90,25 @@ module EE
) )
end end
def insights_navbar_link(project, current_user, index = 0) def insights_navbar_link(project, current_user, priority = 0)
return unless project_nav_tab?(:project_insights) return unless project_nav_tab?(:project_insights)
navbar_sub_item( navbar_sub_item(
title: _('Insights'), title: _('Insights'),
path: 'insights#show', path: 'insights#show',
link: project_insights_path(project), link: project_insights_path(project),
link_to_options: { class: 'shortcuts-project-insights', data: { qa_selector: 'project_insights_link', index: index } } link_to_options: { class: 'shortcuts-project-insights', data: { qa_selector: 'project_insights_link', priority: priority } }
) )
end end
def code_review_analytics_navbar_link(project, current_user, index = 0) def code_review_analytics_navbar_link(project, current_user, priority = 0)
return unless project_nav_tab?(:code_review) return unless project_nav_tab?(:code_review)
navbar_sub_item( navbar_sub_item(
title: _('Code Review'), title: _('Code Review'),
path: 'projects/analytics/code_reviews#index', path: 'projects/analytics/code_reviews#priority',
link: project_analytics_code_reviews_path(project), link: project_analytics_code_reviews_path(project),
link_to_options: { data: { index: index } } link_to_options: { data: { priority: priority } }
) )
end end
end end
......
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