From ee2d3de1a634611a1c660516c955be0d3000904b Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Thu, 24 Nov 2011 08:08:20 -0500 Subject: [PATCH 1/5] ability to attach branch to issue --- app/assets/stylesheets/projects.css.scss | 1 + app/controllers/issues_controller.rb | 9 +- app/models/issue.rb | 5 + app/views/issues/edit.html.haml | 37 +++++ app/views/issues/show.html.haml | 127 +++++++++++------- ...20111124115339_add_extra_field_to_issue.rb | 5 + db/schema.rb | 13 +- 7 files changed, 149 insertions(+), 48 deletions(-) create mode 100644 app/views/issues/edit.html.haml create mode 100644 db/migrate/20111124115339_add_extra_field_to_issue.rb diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 029b8d3fbd7..5466d21afcf 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -160,6 +160,7 @@ input.ssh_project_url { .new_issue, .new_note, .edit_user, +.edit_issue, .new_project, .new_snippet, .edit_snippet, diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 5a18879edc3..daaf8fa2f19 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -9,7 +9,7 @@ class IssuesController < ApplicationController before_filter :authorize_read_issue! before_filter :authorize_write_issue!, :only => [:new, :create, :close, :edit, :update, :sort] - respond_to :js + respond_to :js, :html def index @issues = case params[:f].to_i @@ -41,6 +41,13 @@ class IssuesController < ApplicationController @notes = @issue.notes.inc_author.order("created_at DESC").limit(20) @note = @project.notes.new(:noteable => @issue) + @commits = if @issue.branch_name && @project.repo.heads.map(&:name).include?(@issue.branch_name) + @project.repo.commits_between("master", @issue.branch_name) + else + [] + end + + respond_to do |format| format.html format.js { respond_with_notes } diff --git a/app/models/issue.rb b/app/models/issue.rb index 2a880037091..c06f173888b 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -15,6 +15,11 @@ class Issue < ActiveRecord::Base :to => :author, :prefix => true + delegate :name, + :email, + :to => :assignee, + :prefix => true + validates :title, :presence => true, :length => { :within => 0..255 } diff --git a/app/views/issues/edit.html.haml b/app/views/issues/edit.html.haml new file mode 100644 index 00000000000..872a64b467f --- /dev/null +++ b/app/views/issues/edit.html.haml @@ -0,0 +1,37 @@ +%div.issue-form-holder + = form_for [@project, @issue] do |f| + -if @issue.errors.any? + %ul + - @issue.errors.full_messages.each do |msg| + %li= msg + + %table + %thead + %th Name + %th Value + %tr + %td= f.label :title + %td= f.text_area :title, :style => "width:450px; height:100px", :maxlength => 255 + %tr + %td= f.label :assignee_id + %td= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }) + %tr + %td= f.label :branch_name + %td= f.select(:branch_name, @project.heads.map(&:name), { :include_blank => "Select git branch" }) + %tr + %td + = f.label :critical, "Critical" + %br + %td= f.check_box :critical + - unless @issue.new_record? + %tr + %td= f.label :closed + %td= f.check_box :closed + = f.submit 'Save', :class => "grey-button" + +:javascript + $(function(){ + $('select#issue_branch_name').selectmenu({width:300}); + $('select#issue_assignee_id').selectmenu({width:300}); + }); + diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 9d4e0bc627d..7357449ccba 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -1,50 +1,85 @@ -%h2 - %strong - Issue - = "##{@issue.id}" - – - = html_escape(@issue.title) -.left.width-65p - .issue_notes= render "notes/notes" +%h2.icon + %span + %d + = "Issue ##{@issue.id}" + – + = truncate(@issue.title, :length => 50) + +- unless @commits.blank? + .right + = link_to 'Browse Code', tree_project_ref_path(@project, @issue.branch_name), :class => "browse-code button yellow", :style => "margin-right:10px;" + = link_to 'Commits', project_commits_path(@project, :ref => @issue.branch_name), :class => "browse-code button" - .loading{ :style => "display:none;"} - %center= image_tag "ajax-loader.gif" -.right.width-30p - .span-8 - %table.round-borders - %tr - %td Author: - %td - = image_tag gravatar_icon(@issue.author.email), :class => "left", :width => 40, :style => "padding:0 5px;" - = @issue.author.name - %tr - %td Assignee: - %td - = image_tag gravatar_icon(@issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;" - = @issue.assignee.name - %tr - %td Tags - %td - - if @issue.critical - %span.tag.high critical - - else - %span.tag.normal normal - - if @issue.today? - %span.tag.today today - %tr - %td Closed? - %td - - if can? current_user, :write_issue, @issue - = form_for([@project, @issue]) do |f| - = f.check_box :closed, :onclick => "$(this).parent().submit();" - = hidden_field_tag :status_only, true - - else - = check_box_tag "closed", 1, @issue.closed, :disabled => true - - if can?(current_user, :write_issue, @issue) - .clear - %br - = link_to 'Edit', edit_project_issue_path(@project, @issue), :class => "grey-button positive", :remote => true - .right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "grey-button delete-issue negative", :id => "destroy_issue_#{@issue.id}" +.clear + +%table.round-borders + %thead + %th + %center Author + %th + %th + %center + Assignee + %tr + %td + %center + = image_tag gravatar_icon(@issue.author_email), :width => 40, :style => "padding:0 5px;" + %br + %br + = @issue.author_name + %td + %center + - if @issue.closed + Resolved + %br + %span{:style => "font-size:36px;"} ← + - else + Open + %br + %span{:style => "font-size:36px;"} → + %br + = @issue.created_at.stamp("21 Aug 2011, 11:15pm") + + %td + %center + = image_tag gravatar_icon(@issue.assignee_email), :width => 40, :style => "padding:0 5px;" + %br + %br + = @issue.assignee_name + + + +- if can? current_user, :write_issue, @issue + - if @issue.closed + = link_to 'Reopen', project_issue_path(@project, @issue, :issue => {:closed => false }, :status_only => true), :method => :put, :class => "grey-button" + - else + = link_to 'Resolve', project_issue_path(@project, @issue, :issue => {:closed => true }, :status_only => true), :method => :put, :class => "grey-button" + .right + = link_to 'Edit', edit_project_issue_path(@project, @issue), :class => "grey-button positive" +   + = link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "grey-button delete-issue negative", :id => "destroy_issue_#{@issue.id}" + +%br +%br +- unless @commits.blank? + %table.round-borders + %thead + %th Unmerged Commits + - @commits.each do |commit| + %tr + %td + = image_tag gravatar_icon(commit.author_email), :class => "left", :width => 20, :style => "padding-right:5px;" + = link_to commit.id.to_s, project_commit_path(@project, :id => commit.id) + .right + = time_ago_in_words(commit.created_at) + ago + + +.issue_notes= render "notes/notes" + +.loading{ :style => "display:none;"} + %center= image_tag "ajax-loader.gif" + .clear diff --git a/db/migrate/20111124115339_add_extra_field_to_issue.rb b/db/migrate/20111124115339_add_extra_field_to_issue.rb new file mode 100644 index 00000000000..4946c6fb0bc --- /dev/null +++ b/db/migrate/20111124115339_add_extra_field_to_issue.rb @@ -0,0 +1,5 @@ +class AddExtraFieldToIssue < ActiveRecord::Migration + def change + add_column :issues, :branch_name, :string, :null => true + end +end diff --git a/db/schema.rb b/db/schema.rb index 83f916d4acf..502f52ad9cb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,17 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111115063954) do +ActiveRecord::Schema.define(:version => 20111124115339) do + + create_table "features", :force => true do |t| + t.string "name" + t.string "branch_name" + t.integer "assignee_id" + t.integer "author_id" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + end create_table "issues", :force => true do |t| t.string "title" @@ -23,6 +33,7 @@ ActiveRecord::Schema.define(:version => 20111115063954) do t.boolean "closed", :default => false, :null => false t.integer "position", :default => 0 t.boolean "critical", :default => false, :null => false + t.string "branch_name" end create_table "keys", :force => true do |t| From 2fbf45b2e04b09e944de9404bd87508e81dbf6da Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Thu, 24 Nov 2011 10:15:30 -0500 Subject: [PATCH 2/5] issue message output --- app/views/issues/show.html.haml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 7357449ccba..48ecf36cbbb 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -2,8 +2,6 @@ %span %d = "Issue ##{@issue.id}" - – - = truncate(@issue.title, :length => 50) - unless @commits.blank? .right @@ -16,12 +14,10 @@ %table.round-borders %thead - %th - %center Author - %th - %th - %center - Assignee + %th{:colspan => 3} Details + %tr + %td{:colspan => 3} + %h3= @issue.title %tr %td %center @@ -49,6 +45,16 @@ %br = @issue.assignee_name + %tr + %td{:colspan => 3} + - if @issue.critical + %span.tag.high critical + - else + %span.tag.normal normal + - if @issue.today? + %span.tag.today today + +.clear - if can? current_user, :write_issue, @issue From b7f4f67b9b6a318f8fdbe2ff48074c3aff1ce73b Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Thu, 24 Nov 2011 11:47:27 -0500 Subject: [PATCH 3/5] issue show finished --- app/views/issues/show.html.haml | 45 ++++++++++++--------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 48ecf36cbbb..3156da7fe41 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -12,41 +12,26 @@ .clear +%h3= @issue.title + %table.round-borders %thead - %th{:colspan => 3} Details - %tr - %td{:colspan => 3} - %h3= @issue.title + %th Assignee + %th Status + %th Opened + %th Tags %tr %td - %center - = image_tag gravatar_icon(@issue.author_email), :width => 40, :style => "padding:0 5px;" - %br - %br - = @issue.author_name + = image_tag gravatar_icon(@issue.assignee_email), :width => 20, :style => "padding:0 5px;" + = @issue.assignee_name %td - %center - - if @issue.closed - Resolved - %br - %span{:style => "font-size:36px;"} ← - - else - Open - %br - %span{:style => "font-size:36px;"} → - %br - = @issue.created_at.stamp("21 Aug 2011, 11:15pm") - + - if @issue.closed + %span.tag.high Resolved + - else + %span.tag.today Open + %td + = @issue.created_at.stamp("21 Aug 2011, 11:15pm") %td - %center - = image_tag gravatar_icon(@issue.assignee_email), :width => 40, :style => "padding:0 5px;" - %br - %br - = @issue.assignee_name - - %tr - %td{:colspan => 3} - if @issue.critical %span.tag.high critical - else @@ -54,6 +39,8 @@ - if @issue.today? %span.tag.today today + + .clear From 4e55cc67f52d420691246dc3a20c75f6f3add912 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 25 Nov 2011 05:41:30 -0500 Subject: [PATCH 4/5] Issue show page restyled --- app/views/issues/edit.html.haml | 2 +- app/views/issues/show.html.haml | 92 ++++++++++----------------------- 2 files changed, 29 insertions(+), 65 deletions(-) diff --git a/app/views/issues/edit.html.haml b/app/views/issues/edit.html.haml index 872a64b467f..394e0e2082f 100644 --- a/app/views/issues/edit.html.haml +++ b/app/views/issues/edit.html.haml @@ -15,7 +15,7 @@ %tr %td= f.label :assignee_id %td= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }) - %tr + -#%tr %td= f.label :branch_name %td= f.select(:branch_name, @project.heads.map(&:name), { :include_blank => "Select git branch" }) %tr diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 3156da7fe41..cd9c77b3b80 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -1,78 +1,42 @@ -%h2.icon - %span - %d - = "Issue ##{@issue.id}" - -- unless @commits.blank? - .right - = link_to 'Browse Code', tree_project_ref_path(@project, @issue.branch_name), :class => "browse-code button yellow", :style => "margin-right:10px;" - = link_to 'Commits', project_commits_path(@project, :ref => @issue.branch_name), :class => "browse-code button" - - - -.clear - -%h3= @issue.title - -%table.round-borders - %thead - %th Assignee - %th Status - %th Opened - %th Tags - %tr - %td - = image_tag gravatar_icon(@issue.assignee_email), :width => 20, :style => "padding:0 5px;" - = @issue.assignee_name - %td +.issue-show-holder.ui-box + %h3 + = "Issue ##{@issue.id}" + .right - if @issue.closed %span.tag.high Resolved - else %span.tag.today Open - %td - = @issue.created_at.stamp("21 Aug 2011, 11:15pm") - %td - - if @issue.critical - %span.tag.high critical + + .data + %h4= @issue.title + + - if @issue.author == @issue.assignee + = image_tag gravatar_icon(@issue.assignee_email), :width => 20, :style => "padding:0 5px;" + = @issue.assignee_name + - else + = image_tag gravatar_icon(@issue.author_email), :width => 20, :style => "padding:0 5px;" + = @issue.author_name + → + = image_tag gravatar_icon(@issue.assignee_email), :width => 20, :style => "padding:0 5px;" + = @issue.assignee_name + .right + %cite.cgray= @issue.created_at.stamp("21 Aug 2011, 11:15pm") + .clear + + .buttons + - if can? current_user, :write_issue, @issue + - if @issue.closed + = link_to 'Reopen', project_issue_path(@project, @issue, :issue => {:closed => false }, :status_only => true), :method => :put, :class => "grey-button" - else - %span.tag.normal normal - - if @issue.today? - %span.tag.today today - - + = link_to 'Resolve', project_issue_path(@project, @issue, :issue => {:closed => true }, :status_only => true), :method => :put, :class => "grey-button" + .right + = link_to 'Edit', edit_project_issue_path(@project, @issue), :class => "grey-button positive" .clear - - -- if can? current_user, :write_issue, @issue - - if @issue.closed - = link_to 'Reopen', project_issue_path(@project, @issue, :issue => {:closed => false }, :status_only => true), :method => :put, :class => "grey-button" - - else - = link_to 'Resolve', project_issue_path(@project, @issue, :issue => {:closed => true }, :status_only => true), :method => :put, :class => "grey-button" - .right - = link_to 'Edit', edit_project_issue_path(@project, @issue), :class => "grey-button positive" -   - = link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "grey-button delete-issue negative", :id => "destroy_issue_#{@issue.id}" - %br %br -- unless @commits.blank? - %table.round-borders - %thead - %th Unmerged Commits - - @commits.each do |commit| - %tr - %td - = image_tag gravatar_icon(commit.author_email), :class => "left", :width => 20, :style => "padding-right:5px;" - = link_to commit.id.to_s, project_commit_path(@project, :id => commit.id) - .right - = time_ago_in_words(commit.created_at) - ago - .issue_notes= render "notes/notes" - .loading{ :style => "display:none;"} %center= image_tag "ajax-loader.gif" - .clear From 4aad057f23a7d517d090ea3f54a48c693bf1b804 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 25 Nov 2011 05:49:28 -0500 Subject: [PATCH 5/5] issues style fixed --- app/assets/stylesheets/issues.css.scss | 5 ++++- app/views/issues/show.html.haml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/issues.css.scss b/app/assets/stylesheets/issues.css.scss index 4e030767ef6..9098b632b79 100644 --- a/app/assets/stylesheets/issues.css.scss +++ b/app/assets/stylesheets/issues.css.scss @@ -44,4 +44,7 @@ } } .issue:hover .action-links { display:block; } - +.issue-show-holder { + width:100%; + .data p { font-size:16px } +} diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index cd9c77b3b80..7eba0adff14 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -8,7 +8,7 @@ %span.tag.today Open .data - %h4= @issue.title + %p= @issue.title - if @issue.author == @issue.assignee = image_tag gravatar_icon(@issue.assignee_email), :width => 20, :style => "padding:0 5px;"