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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
8447c6b1
Commit
8447c6b1
authored
Jun 21, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Insert notification settings dropdown into groups
parent
f82ab42d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
101 additions
and
29 deletions
+101
-29
CHANGELOG
CHANGELOG
+3
-0
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+1
-0
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+19
-12
app/controllers/notification_settings_controller.rb
app/controllers/notification_settings_controller.rb
+20
-2
app/views/groups/show.html.haml
app/views/groups/show.html.haml
+2
-0
app/views/notifications/buttons/_notifications.html.haml
app/views/notifications/buttons/_notifications.html.haml
+1
-1
spec/controllers/notification_settings_controller_spec.rb
spec/controllers/notification_settings_controller_spec.rb
+55
-14
No files found.
CHANGELOG
View file @
8447c6b1
Please view this file on the master branch, on stable branches it's out of date.
Please view this file on the master branch, on stable branches it's out of date.
v 8.10(unreleased)
- Add notifications dropdown for groups
v 8.9.0 (unreleased)
v 8.9.0 (unreleased)
- Fix Error 500 when using closes_issues API with an external issue tracker
- Fix Error 500 when using closes_issues API with an external issue tracker
...
@@ -29,6 +31,7 @@ v 8.9.0 (unreleased)
...
@@ -29,6 +31,7 @@ v 8.9.0 (unreleased)
- Use gitlab-shell v3.0.0
- Use gitlab-shell v3.0.0
- Upgrade to jQuery 2
- Upgrade to jQuery 2
- Use Knapsack to evenly distribute tests across multiple nodes
- Use Knapsack to evenly distribute tests across multiple nodes
- Add notifications dropdown for groups
- Add `sha` parameter to MR merge API, to ensure only reviewed changes are merged
- Add `sha` parameter to MR merge API, to ensure only reviewed changes are merged
- Don't allow MRs to be merged when commits were added since the last review / page load
- Don't allow MRs to be merged when commits were added since the last review / page load
- Add DB index on users.state
- Add DB index on users.state
...
...
app/assets/javascripts/dispatcher.js.coffee
View file @
8447c6b1
...
@@ -81,6 +81,7 @@ class Dispatcher
...
@@ -81,6 +81,7 @@ class Dispatcher
new
Activities
()
new
Activities
()
when
'groups:show'
when
'groups:show'
shortcut_handler
=
new
ShortcutsNavigation
()
shortcut_handler
=
new
ShortcutsNavigation
()
new
NotificationsForm
()
when
'groups:group_members:index'
when
'groups:group_members:index'
new
GroupMembers
()
new
GroupMembers
()
new
UsersSelect
()
new
UsersSelect
()
...
...
app/controllers/groups_controller.rb
View file @
8447c6b1
...
@@ -37,15 +37,12 @@ class GroupsController < Groups::ApplicationController
...
@@ -37,15 +37,12 @@ class GroupsController < Groups::ApplicationController
end
end
def
show
def
show
@last_push
=
current_user
.
recent_push
if
current_user
if
current_user
@last_push
=
current_user
.
recent_push
@notification_setting
=
current_user
.
notification_settings_for
(
group
)
end
@projects
=
@projects
.
includes
(
:namespace
)
setup_projects
@projects
=
@projects
.
sorted_by_activity
@projects
=
filter_projects
(
@projects
)
@projects
=
@projects
.
sort
(
@sort
=
params
[
:sort
])
@projects
=
@projects
.
page
(
params
[
:page
])
if
params
[
:filter_projects
].
blank?
@shared_projects
=
GroupProjectsFinder
.
new
(
group
,
only_shared:
true
).
execute
(
current_user
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
...
@@ -77,10 +74,6 @@ class GroupsController < Groups::ApplicationController
...
@@ -77,10 +74,6 @@ class GroupsController < Groups::ApplicationController
def
edit
def
edit
end
end
def
projects
@projects
=
@group
.
projects
.
page
(
params
[
:page
])
end
def
update
def
update
if
Groups
::
UpdateService
.
new
(
@group
,
current_user
,
group_params
).
execute
if
Groups
::
UpdateService
.
new
(
@group
,
current_user
,
group_params
).
execute
redirect_to
edit_group_path
(
@group
),
notice:
"Group '
#{
@group
.
name
}
' was successfully updated."
redirect_to
edit_group_path
(
@group
),
notice:
"Group '
#{
@group
.
name
}
' was successfully updated."
...
@@ -97,6 +90,20 @@ class GroupsController < Groups::ApplicationController
...
@@ -97,6 +90,20 @@ class GroupsController < Groups::ApplicationController
protected
protected
def
setup_projects
@projects
=
@projects
.
includes
(
:namespace
)
@projects
=
@projects
.
sorted_by_activity
@projects
=
filter_projects
(
@projects
)
@projects
=
@projects
.
sort
(
@sort
=
params
[
:sort
])
@projects
=
@projects
.
page
(
params
[
:page
])
if
params
[
:filter_projects
].
blank?
@shared_projects
=
GroupProjectsFinder
.
new
(
group
,
only_shared:
true
).
execute
(
current_user
)
end
def
projects
@projects
=
@group
.
projects
.
page
(
params
[
:page
])
end
def
authorize_create_group!
def
authorize_create_group!
unless
can?
(
current_user
,
:create_group
,
nil
)
unless
can?
(
current_user
,
:create_group
,
nil
)
return
render_404
return
render_404
...
...
app/controllers/notification_settings_controller.rb
View file @
8447c6b1
...
@@ -2,9 +2,11 @@ class NotificationSettingsController < ApplicationController
...
@@ -2,9 +2,11 @@ class NotificationSettingsController < ApplicationController
before_action
:authenticate_user!
before_action
:authenticate_user!
def
create
def
create
project
=
current_user
.
projects
.
find
(
params
[
:project
][
:id
])
resource
=
find_resource
@notification_setting
=
current_user
.
notification_settings_for
(
project
)
return
render_404
unless
can_read?
(
resource
)
@notification_setting
=
current_user
.
notification_settings_for
(
resource
)
@saved
=
@notification_setting
.
update_attributes
(
notification_setting_params
)
@saved
=
@notification_setting
.
update_attributes
(
notification_setting_params
)
render_response
render_response
...
@@ -19,6 +21,22 @@ class NotificationSettingsController < ApplicationController
...
@@ -19,6 +21,22 @@ class NotificationSettingsController < ApplicationController
private
private
def
find_resource
resource
=
if
params
[
:project
].
present?
Project
.
find
(
params
[
:project
][
:id
])
elsif
params
[
:namespace
].
present?
Group
.
find
(
params
[
:namespace
][
:id
])
end
end
def
can_read?
(
resource
)
ability_name
=
resource
.
class
.
name
.
downcase
ability_name
=
"read_
#{
ability_name
}
"
.
to_sym
can?
(
current_user
,
ability_name
,
resource
)
end
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
(
"notifications/buttons/_notifications"
,
notification_setting:
@notification_setting
),
...
...
app/views/groups/show.html.haml
View file @
8447c6b1
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
%span
.visibility-icon.has-tooltip
{
data:
{
container:
'body'
},
title:
visibility_icon_description
(
@group
)
}
%span
.visibility-icon.has-tooltip
{
data:
{
container:
'body'
},
title:
visibility_icon_description
(
@group
)
}
=
visibility_level_icon
(
@group
.
visibility_level
,
fw:
false
)
=
visibility_level_icon
(
@group
.
visibility_level
,
fw:
false
)
=
render
'notifications/buttons/notifications'
,
notification_setting:
@notification_setting
-
if
@group
.
description
.
present?
-
if
@group
.
description
.
present?
.cover-desc.description
.cover-desc.description
=
markdown
(
@group
.
description
,
pipeline: :description
)
=
markdown
(
@group
.
description
,
pipeline: :description
)
...
...
app/views/notifications/buttons/_notifications.html.haml
View file @
8447c6b1
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
%button
.dropdown-new.btn.btn-default.notifications-btn
#notifications-button
{
type:
"button"
,
data:
{
toggle:
"modal"
,
target:
"#"
+
notifications_menu_identifier
(
"modal"
,
notification_setting
)
}
}
%button
.dropdown-new.btn.btn-default.notifications-btn
#notifications-button
{
type:
"button"
,
data:
{
toggle:
"modal"
,
target:
"#"
+
notifications_menu_identifier
(
"modal"
,
notification_setting
)
}
}
=
icon
(
"bell"
,
class:
"js-notification-loading"
)
=
icon
(
"bell"
,
class:
"js-notification-loading"
)
=
notification_title
(
notification_setting
.
level
)
=
notification_title
(
notification_setting
.
level
)
%button
.btn.
btn-danger.
dropdown-toggle
{
data:
{
toggle:
"dropdown"
,
target:
notifications_menu_identifier
(
"dropdown"
,
notification_setting
)
}
}
%button
.btn.dropdown-toggle
{
data:
{
toggle:
"dropdown"
,
target:
notifications_menu_identifier
(
"dropdown"
,
notification_setting
)
}
}
%span
.caret
%span
.caret
.sr-only
Toggle dropdown
.sr-only
Toggle dropdown
=
render
"shared/notifications/notification_dropdown"
,
notification_setting:
notification_setting
=
render
"shared/notifications/notification_dropdown"
,
notification_setting:
notification_setting
...
...
spec/controllers/notification_settings_controller_spec.rb
View file @
8447c6b1
...
@@ -2,6 +2,7 @@ require 'spec_helper'
...
@@ -2,6 +2,7 @@ require 'spec_helper'
describe
NotificationSettingsController
do
describe
NotificationSettingsController
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:group
)
{
create
(
:group
,
:internal
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
before
do
...
@@ -20,33 +21,73 @@ describe NotificationSettingsController do
...
@@ -20,33 +21,73 @@ describe NotificationSettingsController do
end
end
context
'when authorized'
do
context
'when authorized'
do
let
(
:custom_events
)
do
events
=
{}
NotificationSetting
::
EMAIL_EVENTS
.
each
do
|
event
|
events
[
event
.
to_s
]
=
true
end
events
end
before
do
before
do
sign_in
(
user
)
sign_in
(
user
)
end
end
it
'returns success'
do
context
'for projects'
do
let
(
:notification_setting
)
{
user
.
notification_settings_for
(
project
)
}
it
'creates notification setting'
do
post
:create
,
post
:create
,
project:
{
id:
project
.
id
},
project:
{
id:
project
.
id
},
notification_setting:
{
level: :participating
}
notification_setting:
{
level: :participating
}
expect
(
response
.
status
).
to
eq
200
expect
(
response
.
status
).
to
eq
200
expect
(
notification_setting
.
level
).
to
eq
(
"participating"
)
expect
(
notification_setting
.
user_id
).
to
eq
(
user
.
id
)
expect
(
notification_setting
.
source_id
).
to
eq
(
project
.
id
)
expect
(
notification_setting
.
source_type
).
to
eq
(
"Project"
)
end
end
context
'and setting custom notification setting'
do
context
'with custom settings'
do
let
(
:custom_events
)
do
it
'creates notification setting'
do
events
=
{}
post
:create
,
project:
{
id:
project
.
id
},
notification_setting:
{
level: :custom
}.
merge
(
custom_events
)
NotificationSetting
::
EMAIL_EVENTS
.
each
do
|
event
|
expect
(
response
.
status
).
to
eq
200
events
[
event
]
=
"true"
expect
(
notification_setting
.
level
).
to
eq
(
"custom"
)
expect
(
notification_setting
.
events
).
to
eq
(
custom_events
)
end
end
end
end
end
it
'returns success'
do
context
'for groups'
do
let
(
:notification_setting
)
{
user
.
notification_settings_for
(
group
)
}
it
'creates notification setting'
do
post
:create
,
post
:create
,
project:
{
id:
project
.
id
},
namespace:
{
id:
group
.
id
},
notification_setting:
{
level: :
participating
,
events:
custom_events
}
notification_setting:
{
level: :
watch
}
expect
(
response
.
status
).
to
eq
200
expect
(
response
.
status
).
to
eq
200
expect
(
notification_setting
.
level
).
to
eq
(
"watch"
)
expect
(
notification_setting
.
user_id
).
to
eq
(
user
.
id
)
expect
(
notification_setting
.
source_id
).
to
eq
(
group
.
id
)
expect
(
notification_setting
.
source_type
).
to
eq
(
"Namespace"
)
end
context
'with custom settings'
do
it
'creates notification setting'
do
post
:create
,
namespace:
{
id:
group
.
id
},
notification_setting:
{
level: :custom
}.
merge
(
custom_events
)
expect
(
response
.
status
).
to
eq
200
expect
(
notification_setting
.
level
).
to
eq
(
"custom"
)
expect
(
notification_setting
.
events
).
to
eq
(
custom_events
)
end
end
end
end
end
end
end
...
...
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