Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
220708fa
Commit
220708fa
authored
8 years ago
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove schema from branch history
parent
0cf03523
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
170 additions
and
39 deletions
+170
-39
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+1
-0
app/assets/javascripts/notifications_form.js.coffee
app/assets/javascripts/notifications_form.js.coffee
+49
-0
app/assets/javascripts/project.js.coffee
app/assets/javascripts/project.js.coffee
+20
-15
app/assets/stylesheets/pages/projects.scss
app/assets/stylesheets/pages/projects.scss
+17
-5
app/controllers/projects/notification_settings_controller.rb
app/controllers/projects/notification_settings_controller.rb
+17
-3
app/models/notification_setting.rb
app/models/notification_setting.rb
+4
-5
app/services/notification_service.rb
app/services/notification_service.rb
+5
-0
app/views/projects/buttons/_notifications.html.haml
app/views/projects/buttons/_notifications.html.haml
+20
-10
app/views/shared/projects/_custom_notifications.html.haml
app/views/shared/projects/_custom_notifications.html.haml
+27
-0
app/views/shared/projects/_notification_dropdown.html.haml
app/views/shared/projects/_notification_dropdown.html.haml
+9
-0
features/steps/project/project.rb
features/steps/project/project.rb
+1
-1
No files found.
app/assets/javascripts/dispatcher.js.coffee
View file @
220708fa
...
...
@@ -75,6 +75,7 @@ class Dispatcher
when
'projects:show'
shortcut_handler
=
new
ShortcutsNavigation
()
new
NotificationsForm
()
new
TreeView
()
if
$
(
'#tree-slider'
).
length
when
'groups:activity'
new
Activities
()
...
...
This diff is collapsed.
Click to expand it.
app/assets/javascripts/notifications_form.js.coffee
0 → 100644
View file @
220708fa
class
@
NotificationsForm
constructor
:
->
@
form
=
$
(
'.custom-notifications-form'
)
@
removeEventListeners
()
@
initEventListeners
()
removeEventListeners
:
->
$
(
document
).
off
'change'
,
'.js-custom-notification-event'
initEventListeners
:
->
$
(
document
).
on
'change'
,
'.js-custom-notification-event'
,
@
toggleCheckbox
toggleCheckbox
:
(
e
)
=>
$checkbox
=
$
(
e
.
currentTarget
)
$parent
=
$checkbox
.
closest
(
'.checkbox'
)
@
saveEvent
(
$checkbox
,
$parent
)
showCheckboxLoadingSpinner
:
(
$parent
)
->
$parent
.
addClass
'is-loading'
.
find
'.custom-notification-event-loading'
.
removeClass
'fa-check'
.
addClass
'fa-spin fa-spinner'
.
removeClass
'is-done'
saveEvent
:
(
$checkbox
,
$parent
)
->
$
.
ajax
(
url
:
@
form
.
attr
(
'action'
)
method
:
'patch'
dataType
:
'json'
data
:
@
form
.
serialize
()
beforeSend
:
=>
@
showCheckboxLoadingSpinner
(
$parent
)
).
done
(
data
)
->
$checkbox
.
enable
()
if
data
.
saved
$parent
.
find
'.custom-notification-event-loading'
.
toggleClass
'fa-spin fa-spinner fa-check is-done'
setTimeout
(
->
$parent
.
removeClass
'is-loading'
.
find
'.custom-notification-event-loading'
.
toggleClass
'fa-spin fa-spinner fa-check is-done'
,
2000
)
This diff is collapsed.
Click to expand it.
app/assets/javascripts/project.js.coffee
View file @
220708fa
...
...
@@ -34,21 +34,26 @@ class @Project
$
(
@
).
parents
(
'.no-password-message'
).
remove
()
e
.
preventDefault
()
$
(
'.update-notification'
).
on
'click'
,
(
e
)
->
e
.
preventDefault
()
notification_level
=
$
(
@
).
data
'notification-level'
label
=
$
(
@
).
data
'notification-title'
$
(
'#notification_setting_level'
).
val
(
notification_level
)
$
(
'#notification-form'
).
submit
()
$
(
'#notifications-button'
).
empty
().
append
(
"<i class='fa fa-bell'></i>"
+
label
+
"<i class='fa fa-angle-down'></i>"
)
$
(
@
).
parents
(
'ul'
).
find
(
'li.active'
).
removeClass
'active'
$
(
@
).
parent
().
addClass
'active'
$
(
'#notification-form'
).
on
'ajax:success'
,
(
e
,
data
)
->
if
data
.
saved
new
Flash
(
"Notification settings saved"
,
"notice"
)
else
new
Flash
(
"Failed to save new settings"
,
"alert"
)
$
(
document
)
.
off
'click'
,
'.update-notification'
.
on
'click'
,
'.update-notification'
,
(
e
)
->
e
.
preventDefault
()
notificationLevel
=
$
(
@
).
data
'notification-level'
label
=
$
(
@
).
data
'notification-title'
$
(
'.js-notification-loading'
).
toggleClass
'fa-bell fa-spin fa-spinner'
$
(
'#notification_setting_level'
).
val
(
notificationLevel
)
$
(
'#notification-form'
).
submit
()
$
(
document
)
.
off
'ajax:success'
,
'#notification-form'
.
on
'ajax:success'
,
'#notification-form'
,
(
e
,
data
)
->
if
data
.
saved
new
Flash
(
'Notification settings saved'
,
'notice'
)
$
(
'.js-notification-toggle-btns'
)
.
closest
(
'.notification-dropdown'
)
.
replaceWith
(
data
.
html
)
else
new
Flash
(
'Failed to save new settings'
,
'alert'
)
@
projectSelectDropdown
()
...
...
This diff is collapsed.
Click to expand it.
app/assets/stylesheets/pages/projects.scss
View file @
220708fa
...
...
@@ -133,11 +133,6 @@
}
}
.btn-group
:not
(
:first-child
)
:not
(
:last-child
)
>
.btn
{
border-top-right-radius
:
3px
;
border-bottom-right-radius
:
3px
;
}
form
{
margin-left
:
10px
;
}
...
...
@@ -604,3 +599,20 @@ pre.light-well {
}
}
}
.custom-notifications-form
{
.is-loading
{
.custom-notification-event-loading
{
display
:
inline-block
;
}
}
}
.custom-notification-event-loading
{
display
:
none
;
margin-left
:
5px
;
&
.is-done
{
color
:
$gl-text-green
;
}
}
This diff is collapsed.
Click to expand it.
app/controllers/projects/notification_settings_controller.rb
View file @
220708fa
...
...
@@ -2,10 +2,24 @@ class Projects::NotificationSettingsController < Projects::ApplicationController
before_action
:authenticate_user!
def
update
notification_setting
=
current_user
.
notification_settings_for
(
project
)
saved
=
notification_setting
.
update_attributes
(
notification_setting_params
)
@notification_setting
=
current_user
.
notification_settings_for
(
project
)
render
json:
{
saved:
saved
}
if
params
[
:custom_events
].
nil?
saved
=
@notification_setting
.
update_attributes
(
notification_setting_params
)
else
events
=
params
[
:events
]
||
{}
NotificationSetting
::
EMAIL_EVENTS
.
each
do
|
event
|
@notification_setting
.
events
[
event
]
=
events
[
event
]
end
saved
=
@notification_setting
.
save
end
render
json:
{
html:
view_to_html_string
(
"projects/buttons/_notifications"
,
locals:
{
project:
@project
,
notification_setting:
@notification_setting
}),
saved:
saved
,
}
end
private
...
...
This diff is collapsed.
Click to expand it.
app/models/notification_setting.rb
View file @
220708fa
...
...
@@ -19,7 +19,7 @@ class NotificationSetting < ActiveRecord::Base
:new_note
,
:new_issue
,
:reopen_issue
,
:close
d
_issue
,
:close_issue
,
:reassign_issue
,
:new_merge_request
,
:reopen_merge_request
,
...
...
@@ -42,13 +42,12 @@ class NotificationSetting < ActiveRecord::Base
setting
end
# Set all event attributes
as true when level is not custom
# Set all event attributes
to false when level is not custom or being initialized
def
set_events
# Level is a ENUM cannot compare to symbol
return
if
level
==
"custom"
return
if
self
.
custom?
||
self
.
persisted?
EMAIL_EVENTS
.
each
do
|
event
|
self
.
send
(
"
#{
event
}
="
,
true
)
events
[
event
]
=
false
end
end
end
This diff is collapsed.
Click to expand it.
app/services/notification_service.rb
View file @
220708fa
...
...
@@ -29,6 +29,7 @@ class NotificationService
# * issue assignee if their notification level is not Disabled
# * project team members with notification level higher then Participating
# * watchers of the issue's labels
# * users with custom level checked with "new issue"
#
def
new_issue
(
issue
,
current_user
)
new_resource_email
(
issue
,
issue
.
project
,
:new_issue_email
)
...
...
@@ -39,6 +40,7 @@ class NotificationService
# * issue author if their notification level is not Disabled
# * issue assignee if their notification level is not Disabled
# * project team members with notification level higher then Participating
# * users with custom level checked with "close issue"
#
def
close_issue
(
issue
,
current_user
)
close_resource_email
(
issue
,
issue
.
project
,
current_user
,
:closed_issue_email
)
...
...
@@ -48,6 +50,7 @@ class NotificationService
#
# * issue old assignee if their notification level is not Disabled
# * issue new assignee if their notification level is not Disabled
# * users with custom level checked with "reassign issue"
#
def
reassigned_issue
(
issue
,
current_user
)
reassign_resource_email
(
issue
,
issue
.
project
,
current_user
,
:reassigned_issue_email
)
...
...
@@ -66,6 +69,7 @@ class NotificationService
# * mr assignee if their notification level is not Disabled
# * project team members with notification level higher then Participating
# * watchers of the mr's labels
# * users with custom level checked with "new merge request"
#
def
new_merge_request
(
merge_request
,
current_user
)
new_resource_email
(
merge_request
,
merge_request
.
target_project
,
:new_merge_request_email
)
...
...
@@ -75,6 +79,7 @@ class NotificationService
#
# * merge_request old assignee if their notification level is not Disabled
# * merge_request assignee if their notification level is not Disabled
# * users with custom level checked with "reassign merge request"
#
def
reassigned_merge_request
(
merge_request
,
current_user
)
reassign_resource_email
(
merge_request
,
merge_request
.
target_project
,
current_user
,
:reassigned_merge_request_email
)
...
...
This diff is collapsed.
Click to expand it.
app/views/projects/buttons/_notifications.html.haml
View file @
220708fa
-
if
@notification_setting
=
form_for
@notification_setting
,
url:
namespace_project_notification_setting_path
(
@project
.
namespace
.
becomes
(
Namespace
),
@project
),
method: :patch
,
remote:
true
,
html:
{
class:
'inline'
,
id:
'notification-form'
}
do
|
f
|
=
f
.
hidden_field
:level
.dropdown
%button
.btn.btn-default.notifications-btn
#notifications-button
{
data:
{
toggle:
"dropdown"
},
aria:
{
haspopup:
"true"
,
expanded:
"false"
}
}
=
icon
(
'bell'
)
=
notification_title
(
@notification_setting
.
level
)
=
icon
(
'caret-down'
)
%ul
.dropdown-menu.dropdown-menu-no-wrap.dropdown-menu-align-right.dropdown-menu-selectable.dropdown-menu-large
{
role:
"menu"
}
-
NotificationSetting
.
levels
.
each
do
|
level
|
=
notification_list_item
(
level
.
first
,
@notification_setting
)
.dropdown.notification-dropdown.pull-right
=
form_for
@notification_setting
,
url:
namespace_project_notification_setting_path
(
@project
.
namespace
.
becomes
(
Namespace
),
@project
),
method: :patch
,
remote:
true
,
html:
{
class:
"inline"
,
id:
"notification-form"
}
do
|
f
|
=
f
.
hidden_field
:level
.js-notification-toggle-btns
-
if
@notification_setting
.
level
!=
"custom"
%button
.dropdown-new.btn.btn-default.notifications-btn
#notifications-button
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
target:
".notification-dropdown"
}
}
=
icon
(
"bell"
,
class:
"js-notification-loading"
)
=
notification_title
(
@notification_setting
.
level
)
=
icon
(
"caret-down"
)
-
else
.btn-group
%button
.dropdown-new.btn.btn-default.notifications-btn
#notifications-button
{
type:
"button"
,
data:
{
toggle:
"modal"
,
target:
"#custom-notifications-modal"
}
}
=
icon
(
"bell"
,
class:
"js-notification-loading"
)
=
notification_title
(
@notification_setting
.
level
)
%button
.btn.btn-danger.dropdown-toggle
{
data:
{
toggle:
"dropdown"
,
target:
".notification-dropdown"
}
}
%span
.caret
.sr-only
Toggle dropdown
=
render
"shared/projects/notification_dropdown"
=
content_for
:scripts_body
do
=
render
"shared/projects/custom_notifications"
This diff is collapsed.
Click to expand it.
app/views/shared/projects/_custom_notifications.html.haml
0 → 100644
View file @
220708fa
#custom-notifications-modal
.modal.fade
{
tabindex:
"-1"
,
role:
"dialog"
,
aria:
{
labelledby:
"custom-notifications-title"
}
}
.modal-dialog
.modal-content
.modal-header
%button
.close
{
type:
"button"
,
data:
{
dismiss:
"modal"
},
aria:
{
label:
"close"
}
}
%span
{
aria:
{
hidden:
"true"
}
}
×
%h4
#custom-notifications-title
.modal-title
Custom notification events
.modal-body
.container-fluid
=
form_for
@notification_setting
,
url:
namespace_project_notification_setting_path
(
@project
.
namespace
.
becomes
(
Namespace
),
@project
),
method: :patch
,
html:
{
class:
"custom-notifications-form"
}
do
|
f
|
=
hidden_field_tag
"custom_events"
,
"true"
=
f
.
hidden_field
:level
.row
.col-lg-3
%h4
.prepend-top-0
Notification events
.col-lg-9
-
NotificationSetting
::
EMAIL_EVENTS
.
each
do
|
event
,
index
|
=
index
.form-group
.checkbox
{
class:
(
"prepend-top-0"
if
index
==
0
)
}
%label
{
for:
"events_#{event}"
}
=
check_box_tag
"events[
#{
event
}
]"
,
true
,
@notification_setting
.
events
[
event
],
id:
"events_
#{
event
}
"
,
class:
"js-custom-notification-event"
%strong
=
event
.
to_s
.
humanize
=
icon
(
"spinner spin"
,
class:
"custom-notification-event-loading"
)
This diff is collapsed.
Click to expand it.
app/views/shared/projects/_notification_dropdown.html.haml
0 → 100644
View file @
220708fa
%ul
.dropdown-menu.dropdown-menu-no-wrap.dropdown-menu-align-right.dropdown-menu-selectable.dropdown-menu-large
{
role:
"menu"
}
-
NotificationSetting
.
levels
.
each
do
|
level
|
-
if
level
.
first
!=
"custom"
=
notification_list_item
(
level
.
first
,
@notification_setting
)
-
if
@notification_setting
.
level
!=
"custom"
%li
.divider
%li
%a
.update-notification
{
href:
"#"
,
role:
"button"
,
data:
{
toggle:
"modal"
,
target:
"#custom-notifications-modal"
,
notification_level:
"custom"
,
notification_title:
"Custom"
}
}
Custom
This diff is collapsed.
Click to expand it.
features/steps/project/project.rb
View file @
220708fa
...
...
@@ -126,7 +126,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
end
step
'I click notifications drop down button'
do
fi
nd
(
'#notifications-butto
n'
).
click
fi
rst
(
'.notifications-bt
n'
).
click
end
step
'I choose Mention setting'
do
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment