User joined project event added
This commit is contained in:
parent
a56cec1132
commit
a86bd87afc
10 changed files with 78 additions and 3 deletions
|
@ -179,6 +179,14 @@ span.update-author {
|
|||
&.merged {
|
||||
background-color: #2A2;
|
||||
}
|
||||
|
||||
&.joined {
|
||||
background-color: #1cb9ff;
|
||||
}
|
||||
|
||||
&.left {
|
||||
background-color: #ff5057;
|
||||
}
|
||||
}
|
||||
|
||||
form {
|
||||
|
|
|
@ -8,7 +8,10 @@ class EventDecorator < ApplicationDecorator
|
|||
"#{self.author_name} #{self.action_name} MR ##{self.target_id}:" + self.merge_request_title
|
||||
elsif self.push?
|
||||
"#{self.author_name} #{self.push_action_name} #{self.ref_type} " + self.ref_name
|
||||
else
|
||||
elsif self.joined?
|
||||
"#{self.author_name} #{self.action_name} #{self.project.name}"
|
||||
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,7 @@ class Event < ActiveRecord::Base
|
|||
Pushed = 5
|
||||
Commented = 6
|
||||
Merged = 7
|
||||
Joined = 8 # User joined project
|
||||
|
||||
belongs_to :project
|
||||
belongs_to :target, polymorphic: true
|
||||
|
@ -37,7 +38,7 @@ class Event < ActiveRecord::Base
|
|||
# - new issue
|
||||
# - merge request
|
||||
def allowed?
|
||||
push? || issue? || merge_request?
|
||||
push? || issue? || merge_request? || joined?
|
||||
end
|
||||
|
||||
def push?
|
||||
|
@ -84,6 +85,10 @@ class Event < ActiveRecord::Base
|
|||
[Closed, Reopened].include?(action)
|
||||
end
|
||||
|
||||
def joined?
|
||||
action == self.class::Joined
|
||||
end
|
||||
|
||||
def issue
|
||||
target if target_type == "Issue"
|
||||
end
|
||||
|
@ -101,6 +106,8 @@ class Event < ActiveRecord::Base
|
|||
"closed"
|
||||
elsif merged?
|
||||
"merged"
|
||||
elsif joined?
|
||||
'joined'
|
||||
else
|
||||
"opened"
|
||||
end
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
class UsersProjectObserver < ActiveRecord::Observer
|
||||
def after_create(users_project)
|
||||
Notify.project_access_granted_email(users_project.id).deliver
|
||||
|
||||
Event.create(
|
||||
project_id: users_project.project.id,
|
||||
action: Event::Joined,
|
||||
author_id: users_project.user.id
|
||||
)
|
||||
end
|
||||
|
||||
def after_update(users_project)
|
||||
|
|
|
@ -11,3 +11,7 @@
|
|||
.event_feed
|
||||
= render "events/event_push", event: event
|
||||
|
||||
- elsif event.joined?
|
||||
.event_feed
|
||||
= render "events/event_joined", event: event
|
||||
|
||||
|
|
8
app/views/events/_event_joined.html.haml
Normal file
8
app/views/events/_event_joined.html.haml
Normal file
|
@ -0,0 +1,8 @@
|
|||
= image_tag gravatar_icon(event.author_email), class: "avatar"
|
||||
%strong #{event.author_name}
|
||||
%span.event_label{class: event.action_name}= event.action_name
|
||||
%strong= link_to event.project.name, event.project
|
||||
%span.cgray
|
||||
= time_ago_in_words(event.created_at)
|
||||
ago.
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue