summaryrefslogtreecommitdiff
path: root/app/helpers/projects_helper.rb
blob: 16e3d9d00560595de5dc0a269af7ec7460cd3ccc (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
module ProjectsHelper
  def view_mode_style(type)
    cookies["project_view"] ||= "tile"
    cookies["project_view"] == type ? nil : "display:none"
  end

  def load_note_parent(id, type, project)
    case type
    when "Issue" then @project.issues.find(id)
    when "Commit" then @project.repo.commits(id).first
    when "Snippet" then @project.snippets.find(id)
    else
      true
    end
  rescue
    nil
  end

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

    if controller.controller_name == "snippets" || 
     controller.controller_name == "hooks" ||
     controller.controller_name == "deploy_keys" ||
     controller.controller_name == "team_members"
     "current"
    end
  end

  def tree_tab_class
    controller.controller_name == "refs" ? 
     "current" : nil
  end

  def repository_tab_class
    #if controller.controller_name == "repositories" ||
      #controller.controller_name == "hooks" ||
      #controller.controller_name == "deploy_keys"
     #"current"
    #end
  end

  def commit_tab_class
    if controller.controller_name == "commits" || 
      controller.controller_name == "repositories" ||
      controller.controller_name == "protected_branches"
      "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))
      'active' 
    end
  end
end