Commit e33aab0b21e38f4cf7aed8bb6451d737fcefe110

Authored by Dmitriy Zaporozhets
2 parents 7279e8c1 61a2ce41

Merge branch 'feature/project_tab'

app/assets/stylesheets/projects.css.scss
@@ -561,6 +561,7 @@ h4.middle-panel { @@ -561,6 +561,7 @@ h4.middle-panel {
561 display:none; 561 display:none;
562 } 562 }
563 563
  564 +
564 .merge-tabs { 565 .merge-tabs {
565 margin: 0; 566 margin: 0;
566 border: 1px solid #ccc; 567 border: 1px solid #ccc;
@@ -572,11 +573,10 @@ h4.middle-panel { @@ -572,11 +573,10 @@ h4.middle-panel {
572 573
573 .tab { 574 .tab {
574 font-weight: bold; 575 font-weight: bold;
575 - text-transform: uppercase;  
576 border-right: 1px solid #ddd; 576 border-right: 1px solid #ddd;
577 background:none; 577 background:none;
578 padding: 10px; 578 padding: 10px;
579 - width:60px; 579 + min-width:60px;
580 float:left; 580 float:left;
581 position:relative; 581 position:relative;
582 top:-5px; 582 top:-5px;
@@ -598,6 +598,11 @@ h4.middle-panel { @@ -598,6 +598,11 @@ h4.middle-panel {
598 } 598 }
599 } 599 }
600 } 600 }
  601 +.activities-tab span { background: url("images.png") no-repeat -161px -1px; }
  602 +.stat-tab span,
  603 +.team-tab span,
  604 +.snippets-tab span { background: url("images.png") no-repeat -38px -77px; }
  605 +.files-tab span { background: url("images.png") no-repeat -112px -23px; }
601 606
602 .merge-notes-tab span { background: url("images.png") no-repeat -161px -1px; } 607 .merge-notes-tab span { background: url("images.png") no-repeat -161px -1px; }
603 .merge-commits-tab span { background: url("images.png") no-repeat -86px 1px; } 608 .merge-commits-tab span { background: url("images.png") no-repeat -86px 1px; }
app/controllers/projects_controller.rb
@@ -57,7 +57,7 @@ class ProjectsController < ApplicationController @@ -57,7 +57,7 @@ class ProjectsController < ApplicationController
57 def update 57 def update
58 respond_to do |format| 58 respond_to do |format|
59 if project.update_attributes(params[:project]) 59 if project.update_attributes(params[:project])
60 - format.html { redirect_to project, :notice => 'Project was successfully updated.' } 60 + format.html { redirect_to info_project_path(project), :notice => 'Project was successfully updated.' }
61 format.js 61 format.js
62 else 62 else
63 format.html { render action: "edit" } 63 format.html { render action: "edit" }
@@ -72,6 +72,13 @@ class ProjectsController < ApplicationController @@ -72,6 +72,13 @@ class ProjectsController < ApplicationController
72 @activities = @project.cached_updates(limit) 72 @activities = @project.cached_updates(limit)
73 end 73 end
74 74
  75 + def files
  76 + @notes = @project.notes.where("attachment != 'NULL'").order("created_at DESC").limit(100)
  77 + end
  78 +
  79 + def info
  80 + end
  81 +
75 # 82 #
76 # Wall 83 # Wall
77 # 84 #
app/helpers/projects_helper.rb
@@ -16,12 +16,21 @@ module ProjectsHelper @@ -16,12 +16,21 @@ module ProjectsHelper
16 nil 16 nil
17 end 17 end
18 18
19 - # expires in 360 days  
20 - def switch_colorscheme_link(opts)  
21 - if cookies[:colorschema].blank?  
22 - link_to_function "paint it black!", "$.cookie('colorschema','black', {expires:360}); window.location.reload()", opts  
23 - else  
24 - link_to_function "paint it white!", "$.cookie('colorschema','', {expires:360}); window.location.reload()", opts 19 + def project_tab_class
  20 + [:show, :files, :team, :edit, :update, :info].each do |action|
  21 + return "current" if current_page?(:controller => "projects", :action => action, :id => @project)
  22 + end
  23 +
  24 + if controller.controller_name == "snippets" ||
  25 + controller.controller_name == "team_members"
  26 + "current"
25 end 27 end
26 end 28 end
  29 +
  30 + def tree_tab_class
  31 + current_page?(:controller => "refs",
  32 + :action => "tree",
  33 + :project_id => @project,
  34 + :id => @ref || @project.root_ref ) ? "current" : nil
  35 + end
27 end 36 end
app/views/layouts/project.html.haml
@@ -23,14 +23,10 @@ @@ -23,14 +23,10 @@
23 .project-sidebar 23 .project-sidebar
24 .fixed 24 .fixed
25 %aside 25 %aside
26 - = link_to "Activities", project_path(@project), :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil  
27 - = link_to "Tree", tree_project_ref_path(@project, @project.root_ref), :class => current_page?(:controller => "refs", :action => "tree", :project_id => @project, :id => @ref || @project.root_ref ) ? "current" : nil 26 + = link_to "Project", project_path(@project), :class => project_tab_class
  27 + = link_to "Tree", tree_project_ref_path(@project, @project.root_ref), :class => tree_tab_class
28 = link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil 28 = link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil
29 = link_to "Network graph", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil 29 = link_to "Network graph", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil
30 - = link_to team_project_path(@project), :class => (current_page?(:controller => "projects", :action => "team", :id => @project) || controller.controller_name == "team_members") ? "current" : nil do  
31 - Team  
32 - - if @project.users_projects.count > 0  
33 - %span{ :class => "number" }= @project.users_projects.count  
34 = link_to project_issues_filter_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do 30 = link_to project_issues_filter_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do
35 Issues 31 Issues
36 - if @project.issues.open_for(current_user).count > 0 32 - if @project.issues.open_for(current_user).count > 0
@@ -43,13 +39,7 @@ @@ -43,13 +39,7 @@
43 Merge Requests 39 Merge Requests
44 - if @project.merge_requests.opened.count > 0 40 - if @project.merge_requests.opened.count > 0
45 %span{ :class => "number" }= @project.merge_requests.opened.count 41 %span{ :class => "number" }= @project.merge_requests.opened.count
46 - = link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do  
47 - Snippets  
48 - - if @project.snippets.non_expired.count > 0  
49 - %span{ :class => "number" }= @project.snippets.non_expired.count  
50 42
51 - - if can? current_user, :admin_project, @project  
52 - = link_to "Admin", edit_project_path(@project), :class => (current_page?(edit_project_path(@project))) ? "current" : nil  
53 43
54 .medium-tags{:style => 'padding: 10px 0 0 10px; width: 210px;'}= tag_list @project 44 .medium-tags{:style => 'padding: 10px 0 0 10px; width: 210px;'}= tag_list @project
55 45
app/views/projects/_project_head.html.haml 0 → 100644
@@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
  1 +.merge-tabs
  2 + = link_to project_path(@project), :class => "activities-tab tab #{'active' if current_page?(project_path(@project)) }" do
  3 + %span
  4 + Activities
  5 + = link_to info_project_path(@project), :class => "stat-tab tab #{'active' if current_page?(info_project_path(@project)) || current_page?(edit_project_path(@project)) }" do
  6 + %span
  7 + Info
  8 + = link_to team_project_path(@project), :class => "team-tab tab #{'active' if current_page?(team_project_path(@project)) }" do
  9 + %span
  10 + Team
  11 + = link_to files_project_path(@project), :class => "files-tab tab #{'active' if current_page?(files_project_path(@project)) }" do
  12 + %span
  13 + Files
  14 + = link_to project_snippets_path(@project), :class => "snippets-tab tab #{'active' if current_page?(project_snippets_path(@project)) }" do
  15 + %span
  16 + Snippets
  17 +
  18 +
app/views/projects/_team.html.haml
1 -%h2.icon  
2 - %span>  
3 - Team  
4 - if can? current_user, :admin_team_member, @project 1 - if can? current_user, :admin_team_member, @project
5 %div#new-member-holder 2 %div#new-member-holder
6 .right= link_to "Add new", new_project_team_member_path(@project), :remote => true, :class => "grey-button" 3 .right= link_to "Add new", new_project_team_member_path(@project), :remote => true, :class => "grey-button"
  4 + .clear
7 %br 5 %br
8 %table.round-borders#team-table 6 %table.round-borders#team-table
9 %thead 7 %thead
app/views/projects/edit.html.erb
@@ -1 +0,0 @@ @@ -1 +0,0 @@
1 -<%= render 'form' %>  
app/views/projects/edit.html.haml 0 → 100644
@@ -0,0 +1,69 @@ @@ -0,0 +1,69 @@
  1 += render "project_head"
  2 +
  3 += form_for(@project, :remote => true) do |f|
  4 + %div
  5 + %span.entity-info
  6 + = link_to info_project_path(@project) do
  7 + .entity-button
  8 + Info
  9 + %i
  10 + %h2= @project.name
  11 + %hr
  12 + %table.no-borders
  13 + -if @project.errors.any?
  14 + %tr
  15 + %td{:colspan => 2}
  16 + #error_explanation
  17 + - @project.errors.full_messages.each do |msg|
  18 + %span= msg
  19 + %br
  20 +
  21 + %tr
  22 + %td= f.label :name
  23 + %td= f.text_field :name, :placeholder => "Example Project"
  24 + %tr
  25 + %td
  26 + .left= f.label :path
  27 + %cite.right= "git@#{GIT_HOST["host"]}:"
  28 + %td
  29 + = f.text_field :path, :placeholder => "example_project", :disabled => !@project.new_record?
  30 + %tr
  31 + %td
  32 + .left= f.label :code
  33 + %cite.right= "http://#{GIT_HOST["host"]}/"
  34 + %td= f.text_field :code, :placeholder => "example"
  35 +
  36 + - unless @project.new_record? || @project.heads.empty?
  37 + %tr
  38 + %td= f.label :default_branch, "Default Branch"
  39 + %td= f.select(:default_branch, @project.heads.map(&:name), {}, :style => "width:300px;")
  40 +
  41 + %tr
  42 + %td= f.label :description
  43 + %td= f.text_area :description, :placeholder => "project description", :style => "height:50px"
  44 +
  45 + %br
  46 +
  47 + .merge-tabs
  48 + = f.submit 'Save', :class => "grey-button"
  49 + &nbsp;
  50 + - unless @project.new_record?
  51 + .right
  52 + = link_to 'Remove', @project, :confirm => 'Are you sure?', :method => :delete, :class => "red-button"
  53 +
  54 +%div{ :class => "ajax_loader", :style => "display:none;height:200px;"}
  55 + %center
  56 + = image_tag "ajax-loader.gif", :class => "append-bottom"
  57 + %h3.prepend-top Updating project &amp; repository. Please wait for few minutes
  58 +
  59 +:javascript
  60 + $('.edit_project').bind('ajax:before', function() {
  61 + $(".edit_project").hide();
  62 + $('.ajax_loader').show();
  63 + });
  64 +
  65 +:javascript
  66 + $(function(){
  67 + $('#project_default_branch').chosen();
  68 + })
  69 +
app/views/projects/files.html.haml 0 → 100644
@@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
  1 += render "project_head"
  2 +- unless @notes.empty?
  3 + %div.update-data.ui-box.ui-box-small
  4 + .data
  5 + - @notes.each do |note|
  6 + %a.update-item{:href => note.attachment.url}
  7 + = image_tag gravatar_icon(note.author_email), :class => "left", :width => 16
  8 + %span.update-title{:style => "margin-bottom:0px;"}
  9 + = note.attachment_identifier
  10 + %span.update-author.right
  11 + Added
  12 + = time_ago_in_words(note.created_at)
  13 + ago
  14 +- else
  15 + %h3 All files attached to project wall, issues etc will be displayed here
  16 +
  17 +
app/views/projects/info.html.haml 0 → 100644
@@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
  1 += render "project_head"
  2 +
  3 +%div
  4 + %span.entity-info
  5 + = link_to edit_project_path(@project) do
  6 + .entity-button
  7 + Edit
  8 + %i
  9 + %h2= @project.name
  10 + %hr
  11 +
  12 +%table.no-borders
  13 + %tr
  14 + %td Name
  15 + %td= @project.name
  16 +
  17 + %tr
  18 + %td Slug
  19 + %td= @project.code
  20 +
  21 + %tr
  22 + %td Created
  23 + %td= @project.created_at.stamp("Aug 21, 2011")
  24 +
  25 + %tr
  26 + %td{:colspan => 2}= simple_format @project.description
  27 +
  28 +
app/views/projects/show.html.haml
1 - content_for(:body_class, "project-page dashboard") 1 - content_for(:body_class, "project-page dashboard")
2 2
  3 += render "project_head"
3 #news-feed.news-feed 4 #news-feed.news-feed
4 - %h2.icon  
5 - %span>  
6 - Activities  
7 .project-box.project-updates.ui-box.ui-box-small.ui-box-big 5 .project-box.project-updates.ui-box.ui-box-small.ui-box-big
8 - @activities.each do |update| 6 - @activities.each do |update|
9 = render "projects/feed", :update => update, :project => @project 7 = render "projects/feed", :update => update, :project => @project
app/views/projects/team.html.haml
  1 += render "project_head"
1 %div 2 %div
2 = render :partial => "team", :locals => {:project => @project} 3 = render :partial => "team", :locals => {:project => @project}
3 4
app/views/projects/update.js.haml
1 - if @project.valid? 1 - if @project.valid?
2 :plain 2 :plain
3 - location.href = "#{project_path(@project, :notice => 'Project was successfully updated.')}"; 3 + location.href = "#{info_project_path(@project, :notice => 'Project was successfully updated.')}";
4 - else 4 - else
5 :plain 5 :plain
6 $(".edit_project").replaceWith("#{escape_javascript(render('form'))}"); 6 $(".edit_project").replaceWith("#{escape_javascript(render('form'))}");
app/views/snippets/index.html.haml
1 -%h2.icon  
2 - %span>  
3 - Snippets 1 += render "projects/project_head"
4 - if can? current_user, :write_snippet, @project 2 - if can? current_user, :write_snippet, @project
5 .right= link_to 'New Snippet', new_project_snippet_path(@project), :class => "grey-button append-bottom-10" 3 .right= link_to 'New Snippet', new_project_snippet_path(@project), :class => "grey-button append-bottom-10"
6 4
config/routes.rb
@@ -42,6 +42,8 @@ Gitlab::Application.routes.draw do @@ -42,6 +42,8 @@ Gitlab::Application.routes.draw do
42 get "team" 42 get "team"
43 get "wall" 43 get "wall"
44 get "graph" 44 get "graph"
  45 + get "info"
  46 + get "files"
45 end 47 end
46 48
47 resources :refs, :only => [], :path => "/" do 49 resources :refs, :only => [], :path => "/" do
spec/requests/projects_spec.rb
@@ -140,7 +140,7 @@ describe &quot;Projects&quot; do @@ -140,7 +140,7 @@ describe &quot;Projects&quot; do
140 end 140 end
141 141
142 it "should be correct path" do 142 it "should be correct path" do
143 - current_path.should == project_path(@project) 143 + current_path.should == info_project_path(@project)
144 end 144 end
145 145
146 it "should show project" do 146 it "should show project" do