summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-14 21:39:55 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-14 21:39:55 +0200
commitf2db188dbe26b93e76eb3536f1a972a4a9e01f66 (patch)
treede924b6769965cbd7fb096ac74ed6f0f6d97daed
parent678e5355a3e43aa2a13d109fe5d75de231eef413 (diff)
downloadgitlab-ce-f2db188dbe26b93e76eb3536f1a972a4a9e01f66.tar.gz
Processing with note events. reformated dashboard for more events to handle
-rw-r--r--app/assets/stylesheets/sections/events.scss9
-rw-r--r--app/controllers/milestones_controller.rb5
-rw-r--r--app/models/event.rb15
-rw-r--r--app/models/milestone.rb2
-rw-r--r--app/observers/activity_observer.rb25
-rw-r--r--app/roles/note_event.rb21
-rw-r--r--app/views/events/_event.html.haml14
-rw-r--r--app/views/events/event/_note.html.haml15
8 files changed, 73 insertions, 33 deletions
diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss
index 28551d9a6ee..710426441fe 100644
--- a/app/assets/stylesheets/sections/events.scss
+++ b/app/assets/stylesheets/sections/events.scss
@@ -31,7 +31,6 @@
*
*/
.event-item {
- min-height: 40px;
border-bottom: 1px solid #eee;
.event-title {
color: #333;
@@ -50,14 +49,18 @@
}
}
.avatar {
- width: 32px;
+ position: relative;
+ top: -3px;
}
.event_icon {
+ position: relative;
float: right;
border: 1px solid #EEE;
padding: 5px;
@include border-radius(5px);
background: #F9F9F9;
+ margin-left: 10px;
+ top: -6px;
img {
width: 20px;
}
@@ -71,7 +74,7 @@
}
}
- padding: 15px 5px;
+ padding: 16px 5px;
&:last-child { border:none }
.wll:hover { background:none }
diff --git a/app/controllers/milestones_controller.rb b/app/controllers/milestones_controller.rb
index fb3bdf4a3dd..a0c824e8abb 100644
--- a/app/controllers/milestones_controller.rb
+++ b/app/controllers/milestones_controller.rb
@@ -43,7 +43,7 @@ class MilestonesController < ProjectResourceController
def create
@milestone = @project.milestones.new(params[:milestone])
- @milestone.author_id = current_user.id
+ @milestone.author_id_of_changes = current_user.id
if @milestone.save
redirect_to project_milestone_path(@project, @milestone)
@@ -53,8 +53,7 @@ class MilestonesController < ProjectResourceController
end
def update
- @milestone.author_id = current_user.id
- @milestone.update_attributes(params[:milestone])
+ @milestone.update_attributes(params[:milestone].merge(author_id_of_changes: current_user.id))
respond_to do |format|
format.js
diff --git a/app/models/event.rb b/app/models/event.rb
index ee1998e5d4f..90376e73753 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -15,6 +15,7 @@
#
class Event < ActiveRecord::Base
+ include NoteEvent
include PushEvent
attr_accessible :project, :action, :data, :author_id, :project_id,
@@ -58,12 +59,14 @@ class Event < ActiveRecord::Base
end
end
- # Next events currently enabled for system
- # - push
- # - new issue
- # - merge request
- def allowed?
- push? || issue? || merge_request? || membership_changed? || note? || milestone?
+ def proper?
+ if push?
+ true
+ elsif membership_changed?
+ true
+ else
+ (issue? || merge_request? || note? || milestone?) && target
+ end
end
def project_name
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index 9e3c2bb5df6..6e3b0c15a5e 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -14,7 +14,7 @@
class Milestone < ActiveRecord::Base
attr_accessible :title, :description, :due_date, :closed
- attr_accessor :author_id
+ attr_accessor :author_id, :author_id_of_changes
belongs_to :project
has_many :issues
diff --git a/app/observers/activity_observer.rb b/app/observers/activity_observer.rb
index fa39bbfbd34..6fb10423eb7 100644
--- a/app/observers/activity_observer.rb
+++ b/app/observers/activity_observer.rb
@@ -2,17 +2,26 @@ class ActivityObserver < ActiveRecord::Observer
observe :issue, :merge_request, :note, :milestone
def after_create(record)
- Event.create(
- project: record.project,
- target_id: record.id,
- target_type: record.class.name,
- action: Event.determine_action(record),
- author_id: record.author_id
- )
+ event_author_id = record.author_id || record.author_id_of_changes
+
+ # Skip status notes
+ if record.kind_of?(Note) && record.note.include?("_Status changed to ")
+ return true
+ end
+
+ if event_author_id
+ Event.create(
+ project: record.project,
+ target_id: record.id,
+ target_type: record.class.name,
+ action: Event.determine_action(record),
+ author_id: event_author_id
+ )
+ end
end
def after_save(record)
- if record.changed.include?("closed")
+ if record.changed.include?("closed") && record.author_id_of_changes
Event.create(
project: record.project,
target_id: record.id,
diff --git a/app/roles/note_event.rb b/app/roles/note_event.rb
new file mode 100644
index 00000000000..cc6d7338a6d
--- /dev/null
+++ b/app/roles/note_event.rb
@@ -0,0 +1,21 @@
+module NoteEvent
+ def note_commit_id
+ target.noteable_id
+ end
+
+ def note_short_commit_id
+ note_commit_id[0..8]
+ end
+
+ def note_commit?
+ target.noteable_type == "Commit"
+ end
+
+ def note_target
+ target.noteable
+ end
+
+ def note_target_id
+ target.noteable_id
+ end
+end
diff --git a/app/views/events/_event.html.haml b/app/views/events/_event.html.haml
index 9625e1e20de..191aed0747e 100644
--- a/app/views/events/_event.html.haml
+++ b/app/views/events/_event.html.haml
@@ -1,17 +1,15 @@
-- if event.allowed?
+- if event.proper?
%div.event-item
- = event_image(event)
+ %span.cgray.right
+ #{time_ago_in_words(event.created_at)} ago.
+
= image_tag gravatar_icon(event.author_email), class: "avatar s24"
- if event.push?
= render "events/event/push", event: event
- - if event.note?
+ .clearfix
+ - elsif event.note?
= render "events/event/note", event: event
- else
= render "events/event/common", event: event
- .clearfix
- %span.cgray.right
- = time_ago_in_words(event.created_at)
- ago.
- .clearfix
diff --git a/app/views/events/event/_note.html.haml b/app/views/events/event/_note.html.haml
index 5dddef1f1ac..88b8532f8d8 100644
--- a/app/views/events/event/_note.html.haml
+++ b/app/views/events/event/_note.html.haml
@@ -1,9 +1,13 @@
.event-title
%span.author_name= link_to_author event
%span.event_label commented on #{event.target.noteable_type_name}
- - if event.target and event.target.noteable_id
- = link_to [event.project, event.target.noteable] do
- %strong= truncate event.target.noteable_id
+ - if event.target and event.note_target
+ - if event.note_commit?
+ = link_to event.note_short_commit_id, project_commit_path(event.project, event.note_commit_id), class: "commit_short_id"
+ - else
+ = link_to [event.project, event.note_target] do
+ %strong= truncate event.note_target_id
+
- else
%strong (deleted)
at
@@ -13,4 +17,7 @@
= event.project_name
.event-body
- %p.hint= truncate event.target.note, length: 70
+ %span.hint
+ &nbsp;
+ %i.icon-comment
+ = truncate event.target.note, length: 70