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
Boxiang Sun
gitlab-ce
Commits
36dc4a5c
Commit
36dc4a5c
authored
Jul 12, 2016
by
Cairo Noleto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow bulk (un)subscription from issues in issue index
fixies #19747
parent
acbcbd4a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
8 deletions
+84
-8
CHANGELOG
CHANGELOG
+1
-0
app/assets/javascripts/issues-bulk-assignment.js.coffee
app/assets/javascripts/issues-bulk-assignment.js.coffee
+7
-6
app/assets/javascripts/subscription_select.js.coffee
app/assets/javascripts/subscription_select.js.coffee
+18
-0
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-0
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+10
-0
app/services/issues/bulk_update_service.rb
app/services/issues/bulk_update_service.rb
+1
-1
app/views/shared/issuable/_filter.html.haml
app/views/shared/issuable/_filter.html.haml
+8
-1
spec/services/issues/bulk_update_service_spec.rb
spec/services/issues/bulk_update_service_spec.rb
+38
-0
No files found.
CHANGELOG
View file @
36dc4a5c
...
@@ -91,6 +91,7 @@ v 8.10.0 (unreleased)
...
@@ -91,6 +91,7 @@ v 8.10.0 (unreleased)
- Redesign Builds and Pipelines pages
- Redesign Builds and Pipelines pages
- Change status color and icon for running builds
- Change status color and icon for running builds
- Fix markdown rendering for: consecutive labels references, label references that begin with a digit or contains `.`
- Fix markdown rendering for: consecutive labels references, label references that begin with a digit or contains `.`
- Allow bulk (un)subscription from issues in issue index
v 8.9.6
v 8.9.6
- Fix importing of events under notes for GitLab projects. !5154
- Fix importing of events under notes for GitLab projects. !5154
...
...
app/assets/javascripts/issues-bulk-assignment.js.coffee
View file @
36dc4a5c
...
@@ -85,12 +85,13 @@ class @IssuableBulkActions
...
@@ -85,12 +85,13 @@ class @IssuableBulkActions
getFormDataAsObject
:
->
getFormDataAsObject
:
->
formData
=
formData
=
update
:
update
:
state_event
:
@
form
.
find
(
'input[name="update[state_event]"]'
).
val
()
state_event
:
@
form
.
find
(
'input[name="update[state_event]"]'
).
val
()
assignee_id
:
@
form
.
find
(
'input[name="update[assignee_id]"]'
).
val
()
assignee_id
:
@
form
.
find
(
'input[name="update[assignee_id]"]'
).
val
()
milestone_id
:
@
form
.
find
(
'input[name="update[milestone_id]"]'
).
val
()
milestone_id
:
@
form
.
find
(
'input[name="update[milestone_id]"]'
).
val
()
issues_ids
:
@
form
.
find
(
'input[name="update[issues_ids]"]'
).
val
()
issues_ids
:
@
form
.
find
(
'input[name="update[issues_ids]"]'
).
val
()
add_label_ids
:
[]
subscription_event
:
@
form
.
find
(
'input[name="update[subscription_event]"]'
).
val
()
remove_label_ids
:
[]
add_label_ids
:
[]
remove_label_ids
:
[]
if
@
willUpdateLabels
if
@
willUpdateLabels
@
getLabelsToApply
().
map
(
id
)
->
@
getLabelsToApply
().
map
(
id
)
->
...
...
app/assets/javascripts/subscription_select.js.coffee
0 → 100644
View file @
36dc4a5c
class
@
SubscriptionSelect
constructor
:
->
$
(
'.js-subscription-event'
).
each
(
i
,
el
)
->
fieldName
=
$
(
el
).
data
(
"field-name"
)
$
(
el
).
glDropdown
(
selectable
:
true
fieldName
:
fieldName
toggleLabel
:
(
selected
,
el
,
instance
)
=>
label
=
'Subscription'
$item
=
instance
.
dropdown
.
find
(
'.is-active'
)
label
=
$item
.
text
()
if
$item
.
length
label
clicked
:
(
item
,
$el
,
e
)
->
e
.
preventDefault
()
id
:
(
obj
,
el
)
->
$
(
el
).
data
(
"id"
)
)
app/controllers/projects/issues_controller.rb
View file @
36dc4a5c
...
@@ -230,6 +230,7 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -230,6 +230,7 @@ class Projects::IssuesController < Projects::ApplicationController
:assignee_id
,
:assignee_id
,
:milestone_id
,
:milestone_id
,
:state_event
,
:state_event
,
:subscription_event
,
label_ids:
[],
label_ids:
[],
add_label_ids:
[],
add_label_ids:
[],
remove_label_ids:
[]
remove_label_ids:
[]
...
...
app/services/issuable_base_service.rb
View file @
36dc4a5c
...
@@ -101,6 +101,7 @@ class IssuableBaseService < BaseService
...
@@ -101,6 +101,7 @@ class IssuableBaseService < BaseService
def
update
(
issuable
)
def
update
(
issuable
)
change_state
(
issuable
)
change_state
(
issuable
)
change_subscription
(
issuable
)
filter_params
filter_params
old_labels
=
issuable
.
labels
.
to_a
old_labels
=
issuable
.
labels
.
to_a
...
@@ -124,6 +125,15 @@ class IssuableBaseService < BaseService
...
@@ -124,6 +125,15 @@ class IssuableBaseService < BaseService
end
end
end
end
def
change_subscription
(
issuable
)
case
params
.
delete
(
:subscription_event
)
when
'subscribe'
issuable
.
subscribe
(
current_user
)
when
'unsubscribe'
issuable
.
unsubscribe
(
current_user
)
end
end
def
has_changes?
(
issuable
,
old_labels:
[])
def
has_changes?
(
issuable
,
old_labels:
[])
valid_attrs
=
[
:title
,
:description
,
:assignee_id
,
:milestone_id
,
:target_branch
]
valid_attrs
=
[
:title
,
:description
,
:assignee_id
,
:milestone_id
,
:target_branch
]
...
...
app/services/issues/bulk_update_service.rb
View file @
36dc4a5c
...
@@ -4,7 +4,7 @@ module Issues
...
@@ -4,7 +4,7 @@ module Issues
issues_ids
=
params
.
delete
(
:issues_ids
).
split
(
","
)
issues_ids
=
params
.
delete
(
:issues_ids
).
split
(
","
)
issue_params
=
params
issue_params
=
params
%i(state_event milestone_id assignee_id add_label_ids remove_label_ids)
.
each
do
|
key
|
%i(state_event milestone_id assignee_id add_label_ids remove_label_ids
subscription_event
)
.
each
do
|
key
|
issue_params
.
delete
(
key
)
unless
issue_params
[
key
].
present?
issue_params
.
delete
(
key
)
unless
issue_params
[
key
].
present?
end
end
...
...
app/views/shared/issuable/_filter.html.haml
View file @
36dc4a5c
...
@@ -44,9 +44,15 @@
...
@@ -44,9 +44,15 @@
placeholder:
"Search authors"
,
data:
{
first_user:
(
current_user
.
username
if
current_user
),
null_user:
true
,
current_user:
true
,
project_id:
@project
.
id
,
field_name:
"update[assignee_id]"
}
})
placeholder:
"Search authors"
,
data:
{
first_user:
(
current_user
.
username
if
current_user
),
null_user:
true
,
current_user:
true
,
project_id:
@project
.
id
,
field_name:
"update[assignee_id]"
}
})
.filter-item.inline
.filter-item.inline
=
dropdown_tag
(
"Milestone"
,
options:
{
title:
"Assign milestone"
,
toggle_class:
'js-milestone-select js-extra-options js-filter-submit js-filter-bulk-update'
,
filter:
true
,
dropdown_class:
"dropdown-menu-selectable dropdown-menu-milestone"
,
placeholder:
"Search milestones"
,
data:
{
show_no:
true
,
field_name:
"update[milestone_id]"
,
project_id:
@project
.
id
,
milestones:
namespace_project_milestones_path
(
@project
.
namespace
,
@project
,
:json
),
use_id:
true
}
})
=
dropdown_tag
(
"Milestone"
,
options:
{
title:
"Assign milestone"
,
toggle_class:
'js-milestone-select js-extra-options js-filter-submit js-filter-bulk-update'
,
filter:
true
,
dropdown_class:
"dropdown-menu-selectable dropdown-menu-milestone"
,
placeholder:
"Search milestones"
,
data:
{
show_no:
true
,
field_name:
"update[milestone_id]"
,
project_id:
@project
.
id
,
milestones:
namespace_project_milestones_path
(
@project
.
namespace
,
@project
,
:json
),
use_id:
true
}
})
.filter-item.inline.labels-filter
.filter-item.inline.labels-filter
=
render
"shared/issuable/label_dropdown"
,
classes:
[
'js-filter-bulk-update'
,
'js-multiselect'
],
show_create:
false
,
show_footer:
false
,
extra_options:
false
,
filter_submit:
false
,
show_footer:
false
,
data_options:
{
persist_when_hide:
"true"
,
field_name:
"update[label_ids][]"
,
show_no:
false
,
show_any:
false
,
use_id:
true
}
=
render
"shared/issuable/label_dropdown"
,
classes:
[
'js-filter-bulk-update'
,
'js-multiselect'
],
show_create:
false
,
show_footer:
false
,
extra_options:
false
,
filter_submit:
false
,
show_footer:
false
,
data_options:
{
persist_when_hide:
"true"
,
field_name:
"update[label_ids][]"
,
show_no:
false
,
show_any:
false
,
use_id:
true
}
.filter-item.inline
=
dropdown_tag
(
"Subscription"
,
options:
{
toggle_class:
"js-subscription-event"
,
title:
"Change subscription"
,
dropdown_class:
"dropdown-menu-selectable"
,
data:
{
field_name:
"update[subscription_event]"
}
}
)
do
%ul
%li
%a
{
href:
"#"
,
data:
{
id:
"subscribe"
}}
Subscribe
%li
%a
{
href:
"#"
,
data:
{
id:
"unsubscribe"
}}
Unsubscribe
=
hidden_field_tag
'update[issues_ids]'
,
[]
=
hidden_field_tag
'update[issues_ids]'
,
[]
=
hidden_field_tag
:state_event
,
params
[
:state_event
]
=
hidden_field_tag
:state_event
,
params
[
:state_event
]
...
@@ -63,6 +69,7 @@
...
@@ -63,6 +69,7 @@
new
LabelsSelect
();
new
LabelsSelect
();
new
MilestoneSelect
();
new
MilestoneSelect
();
new
IssueStatusSelect
();
new
IssueStatusSelect
();
new
SubscriptionSelect
();
$
(
'
form.filter-form
'
).
on
(
'
submit
'
,
function
(
event
)
{
$
(
'
form.filter-form
'
).
on
(
'
submit
'
,
function
(
event
)
{
event
.
preventDefault
();
event
.
preventDefault
();
Turbolinks
.
visit
(
this
.
action
+
'
&
'
+
$
(
this
).
serialize
());
Turbolinks
.
visit
(
this
.
action
+
'
&
'
+
$
(
this
).
serialize
());
...
...
spec/services/issues/bulk_update_service_spec.rb
View file @
36dc4a5c
...
@@ -262,4 +262,42 @@ describe Issues::BulkUpdateService, services: true do
...
@@ -262,4 +262,42 @@ describe Issues::BulkUpdateService, services: true do
end
end
end
end
end
end
describe
:subscribe_issues
do
let
(
:issues
)
{
create_list
(
:issue
,
5
,
project:
project
)
}
let
(
:params
)
do
{
subscription_event:
'subscribe'
,
issues_ids:
issues
.
map
(
&
:id
).
join
(
','
)
}
end
it
'subscribes the given user'
do
issues
.
each
do
|
issue
|
expect
(
issue
.
subscribed?
(
user
)).
to
be_truthy
end
end
end
describe
:unsubscribe_issues
do
let
(
:issues
)
{
create_list
(
:closed_issue
,
5
,
project:
project
)
}
let
(
:params
)
do
{
subscription_event:
'unsubscribe'
,
issues_ids:
issues
.
map
(
&
:id
).
join
(
','
)
}
end
before
do
issues
.
each
do
|
issue
|
issue
.
subscriptions
.
create
(
user:
user
,
subscribed:
true
)
end
end
it
'unsubscribes the given user'
do
issues
.
each
do
|
issue
|
expect
(
issue
.
subscribed?
(
user
)).
to
be_falsey
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