Merge branch 'dev' into issue-184

This commit is contained in:
Aleksei Kvitinskii 2011-11-05 22:21:03 +02:00
commit 8926c922ac
18 changed files with 162 additions and 109 deletions

View file

@ -7,3 +7,51 @@ $(document).ready(function(){
} }
}); });
}); });
var CommitsList = {
ref:null,
limit:0,
offset:0,
init:
function(ref, limit) {
this.ref=ref;
this.limit=limit;
this.offset=limit;
this.initLoadMore();
$('.loading').show();
},
getOld:
function() {
$('.loading').show();
$.ajax({
type: "GET",
url: location.href,
data: "limit=" + this.limit + "&offset=" + this.offset + "&ref=" + this.ref,
complete: function(){ $('.loading').hide()},
dataType: "script"});
},
append:
function(count, html) {
$("#commits_list").append(html);
if(count > 0) {
this.offset += count;
this.initLoadMore();
}
},
initLoadMore:
function() {
$(window).bind('scroll', function(){
if($(window).scrollTop() == $(document).height() - $(window).height()){
$(window).unbind('scroll');
CommitsList.getOld();
}
});
}
}

View file

@ -31,6 +31,15 @@ append:
this.initLoadMore(); this.initLoadMore();
}, },
replace:
function(fid, lid, html) {
this.first_id = fid;
this.last_id = lid;
$("#notes-list").html(html);
this.initLoadMore();
},
prepend: prepend:
function(id, html) { function(id, html) {
this.last_id = id; this.last_id = id;
@ -47,10 +56,23 @@ getNew:
dataType: "script"}); dataType: "script"});
}, },
refresh:
function() {
// refersh notes list
$.ajax({
type: "GET",
url: location.href,
data: "first_id=" + this.first_id + "&last_id=" + this.last_id,
dataType: "script"});
},
initRefresh: initRefresh:
function() { function() {
// init timer // init timer
var int = setInterval("NoteList.getNew()", 20000); var intNew = setInterval("NoteList.getNew()", 15000);
var intRefresh = setInterval("NoteList.refresh()", 90000);
}, },
initLoadMore: initLoadMore:

View file

@ -52,7 +52,8 @@
background: #eee; background: #eee;
} }
.diff_file_content { .diff_file_content {
overflow-x: scroll; overflow:auto;
overflow-y:hidden;
background:#fff; background:#fff;
color:#333; color:#333;
font-size: 12px; font-size: 12px;
@ -162,10 +163,6 @@ table.round-borders {
padding:20px; padding:20px;
} }
//body {
//background: #eaeaea;
//}
a { a {
color: #111; color: #111;
} }
@ -174,9 +171,9 @@ a {
.old_line, .new_line { .old_line, .new_line {
background:#ECECEC; background:#ECECEC;
color:#777; color:#777;
width:15px; width:30px;
float:left; float:left;
padding: 0px 10px; padding: 0px 5px;
border-right: 1px solid #ccc; border-right: 1px solid #ccc;
} }
} }
@ -231,43 +228,15 @@ input.ssh_project_url {
text-align:center; text-align:center;
} }
.day-commits-table li.commit {
cursor:pointer;
&:hover {
@include hover-color;
}
}
/*
#FFF6BF
#FFD324
*/
#tree-slider tr.tree-item {
cursor:pointer;
&:hover {
@include hover-color;
td {
@include hover-color;
}
}
}
#projects-list .project { #projects-list .project {
height:50px; height:50px;
} }
#tree-slider .tree-item,
#projects-list .project, #projects-list .project,
#snippets-table .snippet, #snippets-table .snippet,
#issues-table .issue{ #issues-table .issue{
cursor:pointer; cursor:pointer;
&:hover {
@include hover-color;
td {
@include hover-color;
}
}
} }
.clear { .clear {
@ -562,6 +531,7 @@ input.ssh_project_url {
@include round-borders-all(4px); @include round-borders-all(4px);
padding:2px 4px; padding:2px 4px;
border:none; border:none;
text-shadow:none;
&.high { &.high {
background: #D12F19; background: #D12F19;
@ -686,6 +656,13 @@ table.highlighttable pre{
width:200px; width:200px;
} }
.issues_filter {
margin-top:10px;
.left {
margin-right:15px;
}
}
body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;}
body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;}
body.project-page #notes-list .note img{float: left; margin-right: 10px;} body.project-page #notes-list .note img{float: left; margin-right: 10px;}

View file

@ -82,5 +82,23 @@ class ApplicationController < ActionController::Base
elsif params[:view_style] == "fluid" elsif params[:view_style] == "fluid"
cookies[:view_style] = "" cookies[:view_style] = ""
end end
@view_mode = if cookies[:view_style] == "collapsed"
:fixed
else
:fluid
end
end
def respond_with_notes
if params[:last_id] && params[:first_id]
@notes = @notes.where("id >= ?", params[:first_id])
elsif params[:last_id]
@notes = @notes.where("id > ?", params[:last_id])
elsif params[:first_id]
@notes = @notes.where("id < ?", params[:first_id])
else
nil
end
end end
end end

View file

@ -13,11 +13,12 @@ class CommitsController < ApplicationController
load_refs # load @branch, @tag & @ref load_refs # load @branch, @tag & @ref
@repo = project.repo @repo = project.repo
limit, offset = (params[:limit] || 20), (params[:offset] || 0)
if params[:path] if params[:path]
@commits = @repo.log(@ref, params[:path], :max_count => params[:limit] || 100, :skip => params[:offset] || 0) @commits = @repo.log(@ref, params[:path], :max_count => limit, :skip => offset)
else else
@commits = @repo.commits(@ref, params[:limit] || 100, params[:offset] || 0) @commits = @repo.commits(@ref, limit, offset)
end end
respond_to do |format| respond_to do |format|
@ -33,10 +34,7 @@ class CommitsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html format.html
format.js do format.js { respond_with_notes }
@notes = @notes.where("id > ?", params[:last_id]) if params[:last_id]
@notes = @notes.where("id < ?", params[:first_id]) if params[:first_id]
end
end end
end end
end end

View file

@ -40,10 +40,7 @@ class IssuesController < ApplicationController
respond_to do |format| respond_to do |format|
format.html format.html
format.js do format.js { respond_with_notes }
@notes = @notes.where("id > ?", params[:last_id]) if params[:last_id]
@notes = @notes.where("id < ?", params[:first_id]) if params[:first_id]
end
end end
end end

View file

@ -92,10 +92,7 @@ class ProjectsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html format.html
format.js do format.js { respond_with_notes }
@notes = @notes.where("id > ?", params[:last_id]) if params[:last_id]
@notes = @notes.where("id < ?", params[:first_id]) if params[:first_id]
end
end end
end end

View file

@ -22,4 +22,3 @@
%strong= commit.author_name %strong= commit.author_name
= time_ago_in_words(commit.committed_date) = time_ago_in_words(commit.committed_date)
ago ago
= more_commits_link if @commits.size > 99

View file

@ -15,4 +15,14 @@
.right= render :partial => "projects/refs", :locals => { :destination => project_commits_path(@project) } .right= render :partial => "projects/refs", :locals => { :destination => project_commits_path(@project) }
%div{:id => dom_id(@project)} %div{:id => dom_id(@project)}
= render "commits" #commits_list= render "commits"
.clear
.loading{ :style => "display:none;"}
%center= image_tag "ajax-loader.gif"
:javascript
$(function(){
CommitsList.init("#{@ref}", 20);
});

View file

@ -1,2 +0,0 @@
$("#more-commits-link").remove();
$('#<%= dom_id(@project)%>').append('<%= escape_javascript(render("commits")) %>');

View file

@ -0,0 +1,3 @@
:plain
CommitsList.append(#{@commits.count}, "#{escape_javascript(render(:partial => 'commits/commits'))}");

View file

@ -1,5 +1,5 @@
%h3 %h3
= "[ #{@commit.committer} ] #{truncate(@commit.safe_message)}" = "[ #{@commit.author_name} ] #{truncate(@commit.safe_message, :length => 70)}"
-#= link_to 'Back', project_commits_path(@project), :class => "button" -#= link_to 'Back', project_commits_path(@project), :class => "button"
%table.round-borders %table.round-borders
%tr %tr
@ -8,12 +8,9 @@
%tr %tr
%td Author %td Author
%td= @commit.author_name %td= @commit.author_name
%tr
%td Commiter
%td= @commit.committer
%tr %tr
%td Commited Date %td Commited Date
%td= @commit.committed_date %td= @commit.committed_date.stamp("21 Aug 2011, 11:15pm")
%tr %tr
%td Message %td Message
%td %td
@ -24,18 +21,7 @@
%td= link_to 'Browse Code', tree_project_path(@project, :commit_id => @commit.id) %td= link_to 'Browse Code', tree_project_path(@project, :commit_id => @commit.id)
.clear .clear
#tabs %br
%ul
%li
%a{ :href => "#tabs-1" } Diff
%li
%a{ :href => "#tabs-2" } Comments
%span{ :class => "notes_count" }= @notes.count
%hr
#tabs-1
= render "commits/diff"
#tabs-2
= render "notes/notes"
:javascript = render "commits/diff"
$(function() { $( "#tabs" ).tabs(); }); = render "notes/notes"

View file

@ -4,10 +4,11 @@
= image_tag "move.png" , :class => [:handle, :left] = image_tag "move.png" , :class => [:handle, :left]
%td %td
= image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;" = image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;"
= truncate issue.assignee.name, :lenght => 20 = issue.assignee.name
%td ##{issue.id} %td ##{issue.id}
%td %td
= truncate(html_escape(issue.title), :length => 60) = truncate(html_escape(issue.title), :length => 200)
%br
%br %br
- if issue.critical - if issue.critical
%span.tag.high critical %span.tag.high critical
@ -27,7 +28,8 @@
- else - else
= check_box_tag "closed", 1, issue.closed, :disabled => true = check_box_tag "closed", 1, issue.closed, :disabled => true
%td %td
- if can?(current_user, :admin_issue, @project) || issue.author == current_user - if @view_mode == :fluid
= link_to 'Edit', edit_project_issue_path(@project, issue), :class => "lbutton positive", :remote => true - if can?(current_user, :admin_issue, @project) || issue.author == current_user
- if can?(current_user, :admin_issue, @project) || issue.author == current_user = link_to 'Edit', edit_project_issue_path(@project, issue), :class => "lbutton positive", :remote => true
= link_to 'Destroy', [@project, issue], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{issue.id}" - if can?(current_user, :admin_issue, @project) || issue.author == current_user
= link_to 'Destroy', [@project, issue], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{issue.id}"

View file

@ -7,18 +7,18 @@
= hidden_field_tag :project_id, @project.id, { :id => 'project_id' } = hidden_field_tag :project_id, @project.id, { :id => 'project_id' }
= search_field_tag :issue_search, nil, { :placeholder => 'Search', :class => 'issue_search' } = search_field_tag :issue_search, nil, { :placeholder => 'Search', :class => 'issue_search' }
.right .right.issues_filter
= form_tag project_issues_path(@project), :method => :get do = form_tag project_issues_path(@project), :method => :get do
.span-2 .left
= radio_button_tag :f, 0, (params[:f] || "0") == "0", :onclick => "this.form.submit()", :id => "open_issues", :class => "status" = radio_button_tag :f, 0, (params[:f] || "0") == "0", :onclick => "this.form.submit()", :id => "open_issues", :class => "status"
= label_tag "open_issues","Open" = label_tag "open_issues","Open"
.span-2 .left
= radio_button_tag :f, 2, params[:f] == "2", :onclick => "this.form.submit()", :id => "closed_issues", :class => "status" = radio_button_tag :f, 2, params[:f] == "2", :onclick => "this.form.submit()", :id => "closed_issues", :class => "status"
= label_tag "closed_issues","Closed" = label_tag "closed_issues","Closed"
.span-2 .left
= radio_button_tag :f, 3, params[:f] == "3", :onclick => "this.form.submit()", :id => "my_issues", :class => "status" = radio_button_tag :f, 3, params[:f] == "3", :onclick => "this.form.submit()", :id => "my_issues", :class => "status"
= label_tag "my_issues","To Me" = label_tag "my_issues","To Me"
.span-2 .left
= radio_button_tag :f, 1, params[:f] == "1", :onclick => "this.form.submit()", :id => "all_issues", :class => "status" = radio_button_tag :f, 1, params[:f] == "1", :onclick => "this.form.submit()", :id => "all_issues", :class => "status"
= label_tag "all_issues","All" = label_tag "all_issues","All"

View file

@ -1,5 +1,9 @@
%h2 %h2
= "Issue ##{@issue.id} - #{html_escape(@issue.title)}" %strong
Issue
= "##{@issue.id}"
&ndash;
= html_escape(@issue.title)
.left.width-65p .left.width-65p
.issue_notes= render "notes/notes" .issue_notes= render "notes/notes"
@ -8,14 +12,6 @@
.right.width-30p .right.width-30p
.span-8 .span-8
%table.round-borders %table.round-borders
%tr
%td Title:
%td
= truncate html_escape(@issue.title)
%tr
%td Project
%td
%strong= @issue.project.name
%tr %tr
%td Author: %td Author:
%td %td
@ -39,7 +35,7 @@
%tr %tr
%td Closed? %td Closed?
%td %td
- if can? current_user, :write_issue, @project - if can? current_user, :write_issue, @issue
= form_for([@project, @issue]) do |f| = form_for([@project, @issue]) do |f|
= f.check_box :closed, :onclick => "$(this).parent().submit();" = f.check_box :closed, :onclick => "$(this).parent().submit();"
= hidden_field_tag :status_only, true = hidden_field_tag :status_only, true
@ -47,8 +43,9 @@
= check_box_tag "closed", 1, @issue.closed, :disabled => true = check_box_tag "closed", 1, @issue.closed, :disabled => true
- if can?(current_user, :admin_issue, @issue) - if can?(current_user, :write_issue, @issue)
.clear .clear
= link_to 'Edit', edit_project_issue_path(@project, @issue), :class => "lbutton positive", :remote => true %br
.right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{@issue.id}" = link_to 'Edit', edit_project_issue_path(@project, @issue), :class => "lbutton positive", :remote => true
.right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{@issue.id}"
.clear .clear

View file

@ -2,11 +2,7 @@
%html %html
%head %head
%title %title
GitLab #{" - #{@project.name}" if @project && !@project.new_record?} GitLab
-#= stylesheet_link_tag 'blueprint/screen', :media => "screen, projection"
-#= stylesheet_link_tag 'blueprint/print', :media => "print"
-#= stylesheet_link_tag 'blueprint/plugins/buttons/screen', :media => "screen, projection"
-#= stylesheet_link_tag 'blueprint/plugins/link-icons/screen', :media => "screen, projection"
= stylesheet_link_tag "application" = stylesheet_link_tag "application"
= javascript_include_tag "application" = javascript_include_tag "application"
= csrf_meta_tags = csrf_meta_tags
@ -17,6 +13,5 @@
#container #container
= render :partial => "layouts/flash" = render :partial => "layouts/flash"
= render :partial => "layouts/head_panel" = render :partial => "layouts/head_panel"
%div{ :id => "main", :role => "main", :class => "container_4" } = render :partial => "layouts/page_title"
= render :partial => "layouts/page_title" = yield
= yield

View file

@ -1,10 +1,17 @@
- unless @notes.blank? - unless @notes.blank?
- if params[:last_id] - if params[:last_id] && params[:first_id]
:plain
NoteList.replace(#{@notes.last.id}, #{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}");
- elsif params[:last_id]
:plain :plain
NoteList.prepend(#{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); NoteList.prepend(#{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}");
- if params[:first_id] - elsif params[:first_id]
:plain :plain
NoteList.append(#{@notes.last.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); NoteList.append(#{@notes.last.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}");
- else
:plain

View file

@ -12,7 +12,6 @@ describe "Issues" do
describe "add new note", :js => true do describe "add new note", :js => true do
before do before do
visit project_commit_path(project, commit) visit project_commit_path(project, commit)
click_link "Comments" # notes tab
fill_in "note_note", :with => "I commented this commit" fill_in "note_note", :with => "I commented this commit"
click_button "Add note" click_button "Add note"
end end