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
ab236c76
Commit
ab236c76
authored
Jun 17, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow users to set custom notifications in projects they don't own and several fixes to code
parent
a4b078bf
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
24 additions
and
59 deletions
+24
-59
CHANGELOG
CHANGELOG
+1
-1
app/assets/javascripts/notifications_dropdown.js.coffee
app/assets/javascripts/notifications_dropdown.js.coffee
+4
-4
app/controllers/notification_settings_controller.rb
app/controllers/notification_settings_controller.rb
+9
-5
app/views/profiles/notifications/_group_settings.html.haml
app/views/profiles/notifications/_group_settings.html.haml
+1
-1
app/views/profiles/notifications/_project_settings.html.haml
app/views/profiles/notifications/_project_settings.html.haml
+1
-1
app/views/profiles/notifications/show.html.haml
app/views/profiles/notifications/show.html.haml
+5
-5
app/views/projects/_home_panel.html.haml
app/views/projects/_home_panel.html.haml
+1
-1
app/views/shared/notifications/buttons/_button.html.haml
app/views/shared/notifications/buttons/_button.html.haml
+1
-1
app/views/shared/projects/_custom_notifications.html.haml
app/views/shared/projects/_custom_notifications.html.haml
+0
-26
app/views/shared/projects/_notification_dropdown.html.haml
app/views/shared/projects/_notification_dropdown.html.haml
+0
-9
lib/api/entities.rb
lib/api/entities.rb
+1
-2
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+0
-3
No files found.
CHANGELOG
View file @
ab236c76
...
@@ -54,7 +54,7 @@ v 8.9.0 (unreleased)
...
@@ -54,7 +54,7 @@ v 8.9.0 (unreleased)
- Remove 'main language' feature
- Remove 'main language' feature
- Pipelines can be canceled only when there are running builds
- Pipelines can be canceled only when there are running builds
- Use downcased path to container repository as this is expected path by Docker
- Use downcased path to container repository as this is expected path by Docker
- Custom
ized notification settings for project
s
- Custom
notification setting
s
- Projects pending deletion will render a 404 page
- Projects pending deletion will render a 404 page
- Measure queue duration between gitlab-workhorse and Rails
- Measure queue duration between gitlab-workhorse and Rails
- Make Omniauth providers specs to not modify global configuration
- Make Omniauth providers specs to not modify global configuration
...
...
app/assets/javascripts/notifications_dropdown.js.coffee
View file @
ab236c76
...
@@ -9,14 +9,14 @@ class @NotificationsDropdown
...
@@ -9,14 +9,14 @@ class @NotificationsDropdown
notificationLevel
=
$
(
@
).
data
'notification-level'
notificationLevel
=
$
(
@
).
data
'notification-level'
label
=
$
(
@
).
data
'notification-title'
label
=
$
(
@
).
data
'notification-title'
form
=
$
(
this
).
parents
(
'form:first'
)
form
=
$
(
this
).
parents
(
'
.notification-
form:first'
)
form
.
find
(
'.js-notification-loading'
).
toggleClass
'fa-bell fa-spin fa-spinner'
form
.
find
(
'.js-notification-loading'
).
toggleClass
'fa-bell fa-spin fa-spinner'
form
.
find
(
'#notification_setting_level'
).
val
(
notificationLevel
)
form
.
find
(
'#notification_setting_level'
).
val
(
notificationLevel
)
form
.
submit
()
;
form
.
submit
()
$
(
document
)
$
(
document
)
.
off
'ajax:success'
,
'
#
notification-form'
.
off
'ajax:success'
,
'
.
notification-form'
.
on
'ajax:success'
,
'
#
notification-form'
,
(
e
,
data
)
->
.
on
'ajax:success'
,
'
.
notification-form'
,
(
e
,
data
)
->
if
data
.
saved
if
data
.
saved
new
Flash
(
'Notification settings saved'
,
'notice'
)
new
Flash
(
'Notification settings saved'
,
'notice'
)
$
(
e
.
currentTarget
).
closest
(
'.notification-dropdown'
).
replaceWith
(
data
.
html
)
$
(
e
.
currentTarget
).
closest
(
'.notification-dropdown'
).
replaceWith
(
data
.
html
)
...
...
app/controllers/notification_settings_controller.rb
View file @
ab236c76
...
@@ -2,12 +2,16 @@ class NotificationSettingsController < ApplicationController
...
@@ -2,12 +2,16 @@ class NotificationSettingsController < ApplicationController
before_action
:authenticate_user!
before_action
:authenticate_user!
def
create
def
create
project
=
current_user
.
projects
.
find
(
params
[
:project
][
:id
])
project
=
Project
.
find
(
params
[
:project
][
:id
])
@notification_setting
=
current_user
.
notification_settings_for
(
project
)
if
can?
(
current_user
,
:read_project
,
project
)
@saved
=
@notification_setting
.
update_attributes
(
notification_setting_params
)
@notification_setting
=
current_user
.
notification_settings_for
(
project
)
@saved
=
@notification_setting
.
update_attributes
(
notification_setting_params
)
render_response
render_response
else
render_404
end
end
end
def
update
def
update
...
@@ -21,7 +25,7 @@ class NotificationSettingsController < ApplicationController
...
@@ -21,7 +25,7 @@ class NotificationSettingsController < ApplicationController
def
render_response
def
render_response
render
json:
{
render
json:
{
html:
view_to_html_string
(
"
notifications/buttons/_notifications
"
,
notification_setting:
@notification_setting
),
html:
view_to_html_string
(
"
shared/notifications/buttons/_button
"
,
notification_setting:
@notification_setting
),
saved:
@saved
saved:
@saved
}
}
end
end
...
...
app/views/profiles/notifications/_group_settings.html.haml
View file @
ab236c76
...
@@ -9,4 +9,4 @@
...
@@ -9,4 +9,4 @@
=
link_to
group
.
name
,
group_path
(
group
)
=
link_to
group
.
name
,
group_path
(
group
)
.pull-right
.pull-right
=
render
'
notifications/buttons/notifications
'
,
notification_setting:
setting
=
render
'
/shared/notifications/buttons/button
'
,
notification_setting:
setting
app/views/profiles/notifications/_project_settings.html.haml
View file @
ab236c76
...
@@ -9,4 +9,4 @@
...
@@ -9,4 +9,4 @@
=
link_to_project
(
project
)
=
link_to_project
(
project
)
.pull-right
.pull-right
=
render
'
notifications/buttons/notifications
'
,
notification_setting:
setting
=
render
'
/shared/notifications/buttons/button
'
,
notification_setting:
setting
app/views/profiles/notifications/show.html.haml
View file @
ab236c76
...
@@ -25,11 +25,11 @@
...
@@ -25,11 +25,11 @@
=
f
.
label
:notification_email
,
class:
"label-light"
=
f
.
label
:notification_email
,
class:
"label-light"
=
f
.
select
:notification_email
,
@user
.
all_emails
,
{
include_blank:
false
},
class:
"select2"
=
f
.
select
:notification_email
,
@user
.
all_emails
,
{
include_blank:
false
},
class:
"select2"
=
label_tag
:global_notification_level
,
"Global notification level"
,
class:
"label-light"
=
label_tag
:global_notification_level
,
"Global notification level"
,
class:
"label-light"
%br
%br
.clearfix
.clearfix
.form-group.pull-left
.form-group.pull-left
=
render
'notifications/buttons/notifications
'
,
notification_setting:
@global_notification_setting
,
left_align:
true
=
render
'/shared/notifications/buttons/button
'
,
notification_setting:
@global_notification_setting
,
left_align:
true
.clearfix
.clearfix
...
...
app/views/projects/_home_panel.html.haml
View file @
ab236c76
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
.project-repo-buttons.btn-group.project-right-buttons
.project-repo-buttons.btn-group.project-right-buttons
=
render
"projects/buttons/download"
=
render
"projects/buttons/download"
=
render
'projects/buttons/dropdown'
=
render
'projects/buttons/dropdown'
=
render
'
notifications/buttons/notifications
'
,
notification_setting:
@notification_setting
=
render
'
/shared/notifications/buttons/button
'
,
notification_setting:
@notification_setting
:javascript
:javascript
new
Star
();
new
Star
();
app/views/
notifications/buttons/_notifications
.html.haml
→
app/views/
shared/notifications/buttons/_button
.html.haml
View file @
ab236c76
-
left_align
=
local_assigns
[
:left_align
]
-
left_align
=
local_assigns
[
:left_align
]
-
if
notification_setting
-
if
notification_setting
.dropdown.notification-dropdown.pull-right
.dropdown.notification-dropdown.pull-right
=
form_for
notification_setting
,
remote:
true
,
html:
{
class:
"inline
"
,
id:
"
notification-form"
}
do
|
f
|
=
form_for
notification_setting
,
remote:
true
,
html:
{
class:
"inline
notification-form"
}
do
|
f
|
=
hidden_setting_source_input
(
notification_setting
)
=
hidden_setting_source_input
(
notification_setting
)
=
f
.
hidden_field
:level
,
class:
"notification_setting_level"
=
f
.
hidden_field
:level
,
class:
"notification_setting_level"
.js-notification-toggle-btns
.js-notification-toggle-btns
...
...
app/views/shared/projects/_custom_notifications.html.haml
deleted
100644 → 0
View file @
a4b078bf
#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
|
.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
(
"notification_setting"
,
event
,
{
id:
"events_
#{
event
}
"
,
class:
"js-custom-notification-event"
})
%strong
=
event
.
to_s
.
humanize
=
icon
(
"spinner spin"
,
class:
"custom-notification-event-loading"
)
app/views/shared/projects/_notification_dropdown.html.haml
deleted
100644 → 0
View file @
a4b078bf
%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
)
%li
.divider
%li
%a
.update-notification
{
href:
"#"
,
role:
"button"
,
data:
{
toggle:
"modal"
,
target:
"#custom-notifications-modal"
,
notification_level:
"custom"
,
notification_title:
"Custom"
}
}
%strong
.dropdown-menu-inner-title
Custom
%span
.dropdown-menu-inner-content
=
notification_description
(
"custom"
)
lib/api/entities.rb
View file @
ab236c76
...
@@ -272,8 +272,7 @@ module API
...
@@ -272,8 +272,7 @@ module API
expose
:access_level
expose
:access_level
expose
:notification_level
do
|
member
,
options
|
expose
:notification_level
do
|
member
,
options
|
if
member
.
notification_setting
if
member
.
notification_setting
setting
=
member
.
notification_setting
NotificationSetting
.
levels
[
member
.
notification_setting
.
level
]
{
level:
NotificationSetting
.
levels
[
setting
.
level
],
events:
setting
.
events
}
end
end
end
end
end
end
...
...
spec/services/notification_service_spec.rb
View file @
ab236c76
...
@@ -146,9 +146,6 @@ describe NotificationService, services: true do
...
@@ -146,9 +146,6 @@ describe NotificationService, services: true do
let
(
:note
)
{
create
(
:note_on_issue
,
noteable:
confidential_issue
,
project:
project
,
note:
"
#{
author
.
to_reference
}
#{
assignee
.
to_reference
}
#{
non_member
.
to_reference
}
#{
member
.
to_reference
}
#{
admin
.
to_reference
}
"
)
}
let
(
:note
)
{
create
(
:note_on_issue
,
noteable:
confidential_issue
,
project:
project
,
note:
"
#{
author
.
to_reference
}
#{
assignee
.
to_reference
}
#{
non_member
.
to_reference
}
#{
member
.
to_reference
}
#{
admin
.
to_reference
}
"
)
}
let
(
:guest_watcher
)
{
create_user_with_notification
(
:watch
,
"guest-watcher-confidential"
)
}
let
(
:guest_watcher
)
{
create_user_with_notification
(
:watch
,
"guest-watcher-confidential"
)
}
before
do
end
it
'filters out users that can not read the issue'
do
it
'filters out users that can not read the issue'
do
project
.
team
<<
[
member
,
:developer
]
project
.
team
<<
[
member
,
:developer
]
project
.
team
<<
[
guest
,
:guest
]
project
.
team
<<
[
guest
,
:guest
]
...
...
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