summaryrefslogtreecommitdiff
path: root/app/helpers/nav_helper.rb
blob: 2b0ff6c0d00bc721d15e46c72fea0fae86033393 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
module NavHelper
  def nav_menu_collapsed?
    cookies[:collapsed_nav] == 'true'
  end

  def nav_sidebar_class
    if nav_menu_collapsed?
      "sidebar-collapsed"
    else
      "sidebar-expanded"
    end
  end

  def page_sidebar_class
    if pinned_nav?
      "page-sidebar-expanded page-sidebar-pinned"
    else
      "page-sidebar-collapsed"
    end
  end

  def page_gutter_class
    if current_path?('merge_requests#show') ||
      current_path?('merge_requests#diffs') ||
      current_path?('merge_requests#commits') ||
      current_path?('merge_requests#builds') ||
      current_path?('merge_requests#conflicts') ||
      current_path?('merge_requests#pipelines') ||
      
      current_path?('issues#show')
      if cookies[:collapsed_gutter] == 'true'
        "page-gutter right-sidebar-collapsed"
      else
        "page-gutter right-sidebar-expanded"
      end
    elsif current_path?('builds#show')
      "page-gutter build-sidebar right-sidebar-expanded"
    end
  end

  def nav_header_class
    class_name = ''
    class_name << " with-horizontal-nav" if defined?(nav) && nav

    if pinned_nav?
      class_name << " header-expanded header-pinned-nav"
    else
      class_name << " header-collapsed"
    end

    class_name
  end

  def layout_nav_class
    "page-with-layout-nav" if defined?(nav) && nav
  end

  def nav_control_class
    "nav-control" if current_user
  end

  def pinned_nav?
    cookies[:pin_nav] == 'true'
  end
end