tab_helper.rb 1007 Bytes
Newer Older
1 2 3 4 5 6
module TabHelper
  def issues_tab?
    controller.controller_name == "issues" || controller.controller_name == "milestones"
  end

  def wall_tab?
7
    current_page?(controller: "projects", action: "wall", id: @project)
8 9 10
  end

  def project_tab_class
11
    [:show, :files, :edit, :update].each do |action|
12
      return "current" if current_page?(controller: "projects", action: action, id: @project)
13 14
    end

Andrey Vakarev's avatar
Andrey Vakarev committed
15
    if ['snippets', 'hooks', 'deploy_keys', 'team_members'].include? controller.controller_name
16 17 18 19 20
     "current"
    end
  end

  def tree_tab_class
Andrey Vakarev's avatar
Andrey Vakarev committed
21
    controller.controller_name == "refs" ? "current" : nil
22 23 24
  end

  def commit_tab_class
Andrey Vakarev's avatar
Andrey Vakarev committed
25
    if ['commits', 'repositories', 'protected_branches'].include? controller.controller_name
26 27 28 29 30 31 32 33
      "current"
    end
  end

  def branches_tab_class
    if current_page?(branches_project_repository_path(@project)) ||
      controller.controller_name == "protected_branches" ||
      current_page?(project_repository_path(@project))
Andrey Vakarev's avatar
Andrey Vakarev committed
34
      'active'
35 36 37
    end
  end
end