summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-17 13:16:28 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-17 13:16:28 +0000
commit3c2a6174f9052572d6aea1248e9e03752bb48f73 (patch)
tree9e25ff148e5fe584e7503e2d75cc0377b3083e07
parent591f2e1df245ed4f80b485f4c056e0730ed9ffb2 (diff)
parente960b3ad2c44c49560cceeee98fe0ec9542d74a7 (diff)
downloadgitlab-ce-3c2a6174f9052572d6aea1248e9e03752bb48f73.tar.gz
Merge branch 'ci-nav-changes' into 'master'
Integrate CI navigation more tightly with project ![Screen_Shot_2015-09-17_at_09.51.56](https://gitlab.com/gitlab-org/gitlab-ce/uploads/013807ad9f89a35a4af988199c2ee92f/Screen_Shot_2015-09-17_at_09.51.56.png) ![Screen_Shot_2015-09-17_at_09.52.14](https://gitlab.com/gitlab-org/gitlab-ce/uploads/8f9bdaafeef62fa451ee3699f003cbc4/Screen_Shot_2015-09-17_at_09.52.14.png) ![Screen_Shot_2015-09-17_at_09.52.07](https://gitlab.com/gitlab-org/gitlab-ce/uploads/cb726bf0651ddb74c10fd7bae9a333fb/Screen_Shot_2015-09-17_at_09.52.07.png) /cc @dzaporozhets See merge request !1324
-rw-r--r--app/helpers/application_helper.rb4
-rw-r--r--app/helpers/ci/application_helper.rb108
-rw-r--r--app/views/layouts/ci/_nav_admin.html.haml4
-rw-r--r--app/views/layouts/ci/_nav_dashboard.html.haml24
-rw-r--r--app/views/layouts/ci/application.html.haml2
-rw-r--r--app/views/layouts/nav/_admin.html.haml7
-rw-r--r--app/views/layouts/nav/_dashboard.html.haml12
-rw-r--r--app/views/layouts/nav/_project.html.haml7
8 files changed, 25 insertions, 143 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index b049bd9fcc2..39ab83ccf12 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -13,7 +13,9 @@ module ApplicationHelper
# current_controller?(:commits) # => false
# current_controller?(:commits, :tree) # => true
def current_controller?(*args)
- args.any? { |v| v.to_s.downcase == controller.controller_name }
+ args.any? do |v|
+ v.to_s.downcase == controller.controller_name || v.to_s.downcase == controller.controller_path
+ end
end
# Check if a particular action is the current one
diff --git a/app/helpers/ci/application_helper.rb b/app/helpers/ci/application_helper.rb
index 3198fe55f91..7e880b00b3a 100644
--- a/app/helpers/ci/application_helper.rb
+++ b/app/helpers/ci/application_helper.rb
@@ -4,118 +4,10 @@ module Ci
image_tag 'ci/loader.gif', alt: 'Loading'
end
- # Navigation link helper
- #
- # Returns an `li` element with an 'active' class if the supplied
- # controller(s) and/or action(s) are currently active. The content of the
- # element is the value passed to the block.
- #
- # options - The options hash used to determine if the element is "active" (default: {})
- # :controller - One or more controller names to check (optional).
- # :action - One or more action names to check (optional).
- # :path - A shorthand path, such as 'dashboard#index', to check (optional).
- # :html_options - Extra options to be passed to the list element (optional).
- # block - An optional block that will become the contents of the returned
- # `li` element.
- #
- # When both :controller and :action are specified, BOTH must match in order
- # to be marked as active. When only one is given, either can match.
- #
- # Examples
- #
- # # Assuming we're on TreeController#show
- #
- # # Controller matches, but action doesn't
- # nav_link(controller: [:tree, :refs], action: :edit) { "Hello" }
- # # => '<li>Hello</li>'
- #
- # # Controller matches
- # nav_link(controller: [:tree, :refs]) { "Hello" }
- # # => '<li class="active">Hello</li>'
- #
- # # Shorthand path
- # nav_link(path: 'tree#show') { "Hello" }
- # # => '<li class="active">Hello</li>'
- #
- # # Supplying custom options for the list element
- # nav_link(controller: :tree, html_options: {class: 'home'}) { "Hello" }
- # # => '<li class="home active">Hello</li>'
- #
- # Returns a list item element String
- def nav_link(options = {}, &block)
- if path = options.delete(:path)
- if path.respond_to?(:each)
- c = path.map { |p| p.split('#').first }
- a = path.map { |p| p.split('#').last }
- else
- c, a, _ = path.split('#')
- end
- else
- c = options.delete(:controller)
- a = options.delete(:action)
- end
-
- if c && a
- # When given both options, make sure BOTH are active
- klass = current_controller?(*c) && current_action?(*a) ? 'active' : ''
- else
- # Otherwise check EITHER option
- klass = current_controller?(*c) || current_action?(*a) ? 'active' : ''
- end
-
- # Add our custom class into the html_options, which may or may not exist
- # and which may or may not already have a :class key
- o = options.delete(:html_options) || {}
- o[:class] ||= ''
- o[:class] += ' ' + klass
- o[:class].strip!
-
- if block_given?
- content_tag(:li, capture(&block), o)
- else
- content_tag(:li, nil, o)
- end
- end
-
- # Check if a particular controller is the current one
- #
- # args - One or more controller names to check
- #
- # Examples
- #
- # # On TreeController
- # current_controller?(:tree) # => true
- # current_controller?(:commits) # => false
- # current_controller?(:commits, :tree) # => true
- def current_controller?(*args)
- args.any? { |v| v.to_s.downcase == controller.controller_name }
- end
-
- # Check if a particular action is the current one
- #
- # args - One or more action names to check
- #
- # Examples
- #
- # # On Projects#new
- # current_action?(:new) # => true
- # current_action?(:create) # => false
- # current_action?(:new, :create) # => true
- def current_action?(*args)
- args.any? { |v| v.to_s.downcase == action_name }
- end
-
def date_from_to(from, to)
"#{from.to_s(:short)} - #{to.to_s(:short)}"
end
- def body_data_page
- path = controller.controller_path.split('/')
- namespace = path.first if path.second
-
- [namespace, controller.controller_name, controller.action_name].compact.join(":")
- end
-
def duration_in_words(finished_at, started_at)
if finished_at && started_at
interval_in_seconds = finished_at.to_i - started_at.to_i
diff --git a/app/views/layouts/ci/_nav_admin.html.haml b/app/views/layouts/ci/_nav_admin.html.haml
index c987ab876a3..d0ca4c421ef 100644
--- a/app/views/layouts/ci/_nav_admin.html.haml
+++ b/app/views/layouts/ci/_nav_admin.html.haml
@@ -1,9 +1,9 @@
%ul.nav.nav-sidebar
= nav_link do
- = link_to ci_root_path, title: 'Back to dashboard', data: {placement: 'right'}, class: 'back-link' do
+ = link_to admin_root_path, title: 'Back to dashboard', data: {placement: 'right'}, class: 'back-link' do
= icon('caret-square-o-left fw')
%span
- Back to Dashboard
+ Back to Admin
%li.separate-item
= nav_link path: 'projects#index' do
diff --git a/app/views/layouts/ci/_nav_dashboard.html.haml b/app/views/layouts/ci/_nav_dashboard.html.haml
deleted file mode 100644
index fcff405d19d..00000000000
--- a/app/views/layouts/ci/_nav_dashboard.html.haml
+++ /dev/null
@@ -1,24 +0,0 @@
-%ul.nav.nav-sidebar
- = nav_link do
- = link_to root_path, title: 'Back to dashboard', data: {placement: 'right'}, class: 'back-link' do
- = icon('caret-square-o-left fw')
- %span
- Back to GitLab
- %li.separate-item
- = nav_link path: 'projects#index' do
- = link_to ci_root_path do
- %i.fa.fa-home
- %span
- Projects
- - if current_user && current_user.is_admin?
- %li
- = link_to ci_admin_projects_path do
- %i.fa.fa-cogs
- %span
- Admin
- %li
- = link_to ci_help_path do
- %i.fa.fa-info
- %span
- Help
-
diff --git a/app/views/layouts/ci/application.html.haml b/app/views/layouts/ci/application.html.haml
index b9f871d5447..9cc7fb85142 100644
--- a/app/views/layouts/ci/application.html.haml
+++ b/app/views/layouts/ci/application.html.haml
@@ -8,4 +8,4 @@
- else
= render "layouts/header/public", title: header_title
- = render 'layouts/ci/page', sidebar: 'nav_dashboard'
+ = render 'layouts/ci/page'
diff --git a/app/views/layouts/nav/_admin.html.haml b/app/views/layouts/nav/_admin.html.haml
index 3fe0127041e..2079feeeab6 100644
--- a/app/views/layouts/nav/_admin.html.haml
+++ b/app/views/layouts/nav/_admin.html.haml
@@ -4,7 +4,7 @@
= icon('dashboard fw')
%span
Overview
- = nav_link(controller: :projects) do
+ = nav_link(controller: [:admin, :projects]) do
= link_to admin_namespaces_projects_path, title: 'Projects', data: {placement: 'right'} do
= icon('cube fw')
%span
@@ -24,6 +24,11 @@
= icon('key fw')
%span
Deploy Keys
+ = nav_link do
+ = link_to ci_admin_projects_path, title: 'Continuous Integration', data: {placement: 'right'} do
+ = icon('building fw')
+ %span
+ Continuous Integration
= nav_link(controller: :logs) do
= link_to admin_logs_path, title: 'Logs', data: {placement: 'right'} do
= icon('file-text fw')
diff --git a/app/views/layouts/nav/_dashboard.html.haml b/app/views/layouts/nav/_dashboard.html.haml
index 56283cba6bd..f172e9b4ae8 100644
--- a/app/views/layouts/nav/_dashboard.html.haml
+++ b/app/views/layouts/nav/_dashboard.html.haml
@@ -1,5 +1,5 @@
%ul.nav.nav-sidebar
- = nav_link(path: ['root#index', 'projects#trending', 'projects#starred', 'projects#index'], html_options: {class: 'home'}) do
+ = nav_link(path: ['root#index', 'projects#trending', 'projects#starred', 'dashboard/projects#index'], html_options: {class: 'home'}) do
= link_to root_path, title: 'Projects', data: {placement: 'right'} do
= icon('home fw')
%span
@@ -31,6 +31,11 @@
%span
Merge Requests
%span.count= current_user.assigned_merge_requests.opened.count
+ = nav_link(path: 'ci/projects#index') do
+ = link_to ci_projects_path, title: 'Continuous Integration', data: {placement: 'right'} do
+ = icon('building fw')
+ %span
+ Continuous Integration
= nav_link(controller: :snippets) do
= link_to dashboard_snippets_path, title: 'Your snippets', data: {placement: 'right'} do
= icon('clipboard fw')
@@ -46,8 +51,3 @@
= icon('user fw')
%span
Profile Settings
- = nav_link(controller: :ci) do
- = link_to ci_root_path, title: 'Continuous Integration', data: {placement: 'right'} do
- = icon('building fw')
- %span
- CI
diff --git a/app/views/layouts/nav/_project.html.haml b/app/views/layouts/nav/_project.html.haml
index 8ce46d4865b..a218ec7486c 100644
--- a/app/views/layouts/nav/_project.html.haml
+++ b/app/views/layouts/nav/_project.html.haml
@@ -76,6 +76,13 @@
Merge Requests
%span.count.merge_counter= @project.merge_requests.opened.count
+ - if @project.gitlab_ci?
+ = nav_link(controller: [:ci, :project]) do
+ = link_to ci_project_path(@project.gitlab_ci_project), title: 'Continuous Integration', data: {placement: 'right'} do
+ = icon('building fw')
+ %span
+ Continuous Integration
+
- if project_nav_tab? :settings
= nav_link(controller: [:project_members, :teams]) do
= link_to namespace_project_project_members_path(@project.namespace, @project), title: 'Members', class: 'team-tab tab', data: {placement: 'right'} do