diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-07-04 20:10:37 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-07-04 20:10:37 +0300 |
commit | 116955c4533497e68abbddbace2eae0a07c98569 (patch) | |
tree | 8a3d10e7f6ac265d31da47ffe0c69f09c65c2f6b /app | |
parent | c0e50fdfc296777871f3cc2d417252f599f5fcfb (diff) | |
parent | 01248876d2a74e3a5eee5a55908c687da3b9600e (diff) |
Merge branch '45739-add-metrics-to-operations-tab' into 'master'
Resolve "Add Metrics to Operations Tab"
Closes #45739
See merge request gitlab-org/gitlab-ce!20025
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/shortcuts_navigation.js | 1 | ||||
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 10 | ||||
-rw-r--r-- | app/models/project.rb | 9 | ||||
-rw-r--r-- | app/views/help/_shortcuts.html.haml | 6 | ||||
-rw-r--r-- | app/views/layouts/nav/sidebar/_project.html.haml | 13 | ||||
-rw-r--r-- | app/views/projects/environments/empty.html.haml | 14 |
6 files changed, 49 insertions, 4 deletions
diff --git a/app/assets/javascripts/shortcuts_navigation.js b/app/assets/javascripts/shortcuts_navigation.js index 78f7353eb0d..6b595764bc5 100644 --- a/app/assets/javascripts/shortcuts_navigation.js +++ b/app/assets/javascripts/shortcuts_navigation.js @@ -20,6 +20,7 @@ export default class ShortcutsNavigation extends Shortcuts { Mousetrap.bind('g s', () => findAndFollowLink('.shortcuts-snippets')); Mousetrap.bind('g k', () => findAndFollowLink('.shortcuts-kubernetes')); Mousetrap.bind('g e', () => findAndFollowLink('.shortcuts-environments')); + Mousetrap.bind('g l', () => findAndFollowLink('.shortcuts-metrics')); Mousetrap.bind('i', () => findAndFollowLink('.shortcuts-new-issue')); this.enabledHelp.push('.hidden-shortcut.project'); diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 0821362f5df..27b7425b965 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -120,6 +120,16 @@ class Projects::EnvironmentsController < Projects::ApplicationController end end + def metrics_redirect + environment = project.default_environment + + if environment + redirect_to environment_metrics_path(environment) + else + render :empty + end + end + def metrics # Currently, this acts as a hint to load the metrics details into the cache # if they aren't there already diff --git a/app/models/project.rb b/app/models/project.rb index 7304ab7b909..8f40470de82 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1774,6 +1774,15 @@ class Project < ActiveRecord::Base end end + def default_environment + production_first = "(CASE WHEN name = 'production' THEN 0 ELSE 1 END), id ASC" + + environments + .with_state(:available) + .reorder(production_first) + .first + end + def secret_variables_for(ref:, environment: nil) # EE would use the environment if protected_for?(ref) diff --git a/app/views/help/_shortcuts.html.haml b/app/views/help/_shortcuts.html.haml index c23fe0b5c49..37b56f92030 100644 --- a/app/views/help/_shortcuts.html.haml +++ b/app/views/help/_shortcuts.html.haml @@ -182,6 +182,12 @@ %tr %td.shortcut %kbd g + %kbd l + %td + Go to metrics + %tr + %td.shortcut + %kbd g %kbd k %td Go to kubernetes diff --git a/app/views/layouts/nav/sidebar/_project.html.haml b/app/views/layouts/nav/sidebar/_project.html.haml index 33416bf76d7..00d75b3399b 100644 --- a/app/views/layouts/nav/sidebar/_project.html.haml +++ b/app/views/layouts/nav/sidebar/_project.html.haml @@ -196,7 +196,7 @@ - if project_nav_tab? :operations = nav_link(controller: [:environments, :clusters, :user, :gcp]) do - = link_to project_environments_path(@project), class: 'shortcuts-operations' do + = link_to metrics_project_environments_path(@project), class: 'shortcuts-operations' do .nav-icon-container = sprite_icon('cloud-gear') %span.nav-item-name @@ -204,14 +204,19 @@ %ul.sidebar-sub-level-items = nav_link(controller: [:environments, :clusters, :user, :gcp], html_options: { class: "fly-out-top-item" } ) do - = link_to project_environments_path(@project) do + = link_to metrics_project_environments_path(@project) do %strong.fly-out-top-item-name = _('Operations') %li.divider.fly-out-top-item - if project_nav_tab? :environments - = nav_link(controller: :environments) do - = link_to project_environments_path(@project), title: 'Environments', class: 'shortcuts-environments' do + = nav_link(controller: :environments, action: [:metrics, :metrics_redirect]) do + = link_to metrics_project_environments_path(@project), title: _('Metrics'), class: 'shortcuts-metrics' do + %span + = _('Metrics') + + = nav_link(controller: :environments, action: [:index, :folder, :show, :new, :edit, :create, :update, :stop, :terminal]) do + = link_to project_environments_path(@project), title: _('Environments'), class: 'shortcuts-environments' do %span = _('Environments') diff --git a/app/views/projects/environments/empty.html.haml b/app/views/projects/environments/empty.html.haml new file mode 100644 index 00000000000..1413930ebdb --- /dev/null +++ b/app/views/projects/environments/empty.html.haml @@ -0,0 +1,14 @@ +- page_title _("Metrics") + +.row + .col-sm-12 + .svg-content + = image_tag 'illustrations/operations_metrics_empty.svg' +.row.empty-environments + .col-sm-12.text-center + %h4 + = s_('Metrics|No deployed environments') + .state-description + = s_('Metrics|Check out the CI/CD documentation on deploying to an environment') + .prepend-top-10 + = link_to s_("Metrics|Learn about environments"), help_page_path('ci/environments'), class: 'btn btn-success' |