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
ff7fe2d1
Commit
ff7fe2d1
authored
Jun 06, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Drag and drop and sorting from milestone view
parent
5f42009f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
87 additions
and
153 deletions
+87
-153
app/assets/javascripts/milestone.js
app/assets/javascripts/milestone.js
+0
-17
app/assets/stylesheets/pages/milestone.scss
app/assets/stylesheets/pages/milestone.scss
+2
-4
app/controllers/projects/milestones_controller.rb
app/controllers/projects/milestones_controller.rb
+1
-17
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+0
-2
app/models/milestone.rb
app/models/milestone.rb
+0
-32
app/views/shared/milestones/_issuables.html.haml
app/views/shared/milestones/_issuables.html.haml
+2
-2
changelogs/unreleased/issue_20900.yml
changelogs/unreleased/issue_20900.yml
+4
-0
lib/api/milestones.rb
lib/api/milestones.rb
+2
-2
spec/features/milestones/milestones_spec.rb
spec/features/milestones/milestones_spec.rb
+76
-77
No files found.
app/assets/javascripts/milestone.js
View file @
ff7fe2d1
...
@@ -84,7 +84,6 @@
...
@@ -84,7 +84,6 @@
this
.
issuesSortEndpoint
=
$
(
'
#tab-issues
'
).
data
(
'
sort-endpoint
'
);
this
.
issuesSortEndpoint
=
$
(
'
#tab-issues
'
).
data
(
'
sort-endpoint
'
);
this
.
mergeRequestsSortEndpoint
=
$
(
'
#tab-merge-requests
'
).
data
(
'
sort-endpoint
'
);
this
.
mergeRequestsSortEndpoint
=
$
(
'
#tab-merge-requests
'
).
data
(
'
sort-endpoint
'
);
this
.
bindIssuesSorting
();
this
.
bindTabsSwitching
();
this
.
bindTabsSwitching
();
// Load merge request tab if it is active
// Load merge request tab if it is active
...
@@ -94,22 +93,6 @@
...
@@ -94,22 +93,6 @@
this
.
loadInitialTab
();
this
.
loadInitialTab
();
}
}
Milestone
.
prototype
.
bindIssuesSorting
=
function
()
{
if
(
!
this
.
issuesSortEndpoint
)
return
;
$
(
'
#issues-list-unassigned, #issues-list-ongoing, #issues-list-closed
'
).
each
(
function
(
i
,
el
)
{
this
.
createSortable
(
el
,
{
group
:
'
issue-list
'
,
listEls
:
$
(
'
.issues-sortable-list
'
),
fieldName
:
'
issue
'
,
sortCallback
:
(
data
)
=>
{
Milestone
.
sortIssues
(
this
.
issuesSortEndpoint
,
data
);
},
updateCallback
:
Milestone
.
updateIssue
,
});
}.
bind
(
this
));
};
Milestone
.
prototype
.
bindTabsSwitching
=
function
()
{
Milestone
.
prototype
.
bindTabsSwitching
=
function
()
{
return
$
(
'
a[data-toggle="tab"]
'
).
on
(
'
show.bs.tab
'
,
(
e
)
=>
{
return
$
(
'
a[data-toggle="tab"]
'
).
on
(
'
show.bs.tab
'
,
(
e
)
=>
{
const
$target
=
$
(
e
.
target
);
const
$target
=
$
(
e
.
target
);
...
...
app/assets/stylesheets/pages/milestone.scss
View file @
ff7fe2d1
...
@@ -111,8 +111,8 @@
...
@@ -111,8 +111,8 @@
}
}
}
}
.
issues-sortable
-list
,
.
milestone-issues
-list
,
.m
erge_requests-sortable
-list
{
.m
ilestone-merge_requests
-list
{
.issuable-detail
{
.issuable-detail
{
display
:
block
;
display
:
block
;
margin-top
:
7px
;
margin-top
:
7px
;
...
@@ -197,6 +197,4 @@
...
@@ -197,6 +197,4 @@
.issuable-row
{
.issuable-row
{
background-color
:
$white-light
;
background-color
:
$white-light
;
cursor
:
-
webkit-grab
;
cursor
:
grab
;
}
}
app/controllers/projects/milestones_controller.rb
View file @
ff7fe2d1
...
@@ -2,7 +2,7 @@ class Projects::MilestonesController < Projects::ApplicationController
...
@@ -2,7 +2,7 @@ class Projects::MilestonesController < Projects::ApplicationController
include
MilestoneActions
include
MilestoneActions
before_action
:module_enabled
before_action
:module_enabled
before_action
:milestone
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:
sort_issues
,
:sort_merge_requests
,
:
merge_requests
,
:participants
,
:labels
]
before_action
:milestone
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:merge_requests
,
:participants
,
:labels
]
# Allow read any milestone
# Allow read any milestone
before_action
:authorize_read_milestone!
before_action
:authorize_read_milestone!
...
@@ -85,22 +85,6 @@ class Projects::MilestonesController < Projects::ApplicationController
...
@@ -85,22 +85,6 @@ class Projects::MilestonesController < Projects::ApplicationController
end
end
end
end
def
sort_issues
@milestone
.
sort_issues
(
params
[
'sortable_issue'
].
map
(
&
:to_i
))
render
json:
{
saved:
true
}
end
def
sort_merge_requests
@merge_requests
=
@milestone
.
merge_requests
.
where
(
id:
params
[
'sortable_merge_request'
])
@merge_requests
.
each
do
|
merge_request
|
merge_request
.
position
=
params
[
'sortable_merge_request'
].
index
(
merge_request
.
id
.
to_s
)
+
1
merge_request
.
save
end
render
json:
{
saved:
true
}
end
protected
protected
def
milestone
def
milestone
...
...
app/models/concerns/issuable.rb
View file @
ff7fe2d1
...
@@ -67,7 +67,6 @@ module Issuable
...
@@ -67,7 +67,6 @@ module Issuable
scope
:authored
,
->
(
user
)
{
where
(
author_id:
user
)
}
scope
:authored
,
->
(
user
)
{
where
(
author_id:
user
)
}
scope
:recent
,
->
{
reorder
(
id: :desc
)
}
scope
:recent
,
->
{
reorder
(
id: :desc
)
}
scope
:order_position_asc
,
->
{
reorder
(
position: :asc
)
}
scope
:of_projects
,
->
(
ids
)
{
where
(
project_id:
ids
)
}
scope
:of_projects
,
->
(
ids
)
{
where
(
project_id:
ids
)
}
scope
:of_milestones
,
->
(
ids
)
{
where
(
milestone_id:
ids
)
}
scope
:of_milestones
,
->
(
ids
)
{
where
(
milestone_id:
ids
)
}
scope
:with_milestone
,
->
(
title
)
{
left_joins_milestones
.
where
(
milestones:
{
title:
title
})
}
scope
:with_milestone
,
->
(
title
)
{
left_joins_milestones
.
where
(
milestones:
{
title:
title
})
}
...
@@ -139,7 +138,6 @@ module Issuable
...
@@ -139,7 +138,6 @@ module Issuable
when
'upvotes_desc'
then
order_upvotes_desc
when
'upvotes_desc'
then
order_upvotes_desc
when
'label_priority'
then
order_labels_priority
(
excluded_labels:
excluded_labels
)
when
'label_priority'
then
order_labels_priority
(
excluded_labels:
excluded_labels
)
when
'priority'
then
order_due_date_and_labels_priority
(
excluded_labels:
excluded_labels
)
when
'priority'
then
order_due_date_and_labels_priority
(
excluded_labels:
excluded_labels
)
when
'position_asc'
then
order_position_asc
else
else
order_by
(
method
)
order_by
(
method
)
end
end
...
...
app/models/milestone.rb
View file @
ff7fe2d1
...
@@ -164,38 +164,6 @@ class Milestone < ActiveRecord::Base
...
@@ -164,38 +164,6 @@ class Milestone < ActiveRecord::Base
write_attribute
(
:title
,
sanitize_title
(
value
))
if
value
.
present?
write_attribute
(
:title
,
sanitize_title
(
value
))
if
value
.
present?
end
end
# Sorts the issues for the given IDs.
#
# This method runs a single SQL query using a CASE statement to update the
# position of all issues in the current milestone (scoped to the list of IDs).
#
# Given the ids [10, 20, 30] this method produces a SQL query something like
# the following:
#
# UPDATE issues
# SET position = CASE
# WHEN id = 10 THEN 1
# WHEN id = 20 THEN 2
# WHEN id = 30 THEN 3
# ELSE position
# END
# WHERE id IN (10, 20, 30);
#
# This method expects that the IDs given in `ids` are already Fixnums.
def
sort_issues
(
ids
)
pairs
=
[]
ids
.
each_with_index
do
|
id
,
index
|
pairs
<<
id
pairs
<<
index
+
1
end
conditions
=
'WHEN id = ? THEN ? '
*
ids
.
length
issues
.
where
(
id:
ids
).
update_all
([
"position = CASE
#{
conditions
}
ELSE position END"
,
*
pairs
])
end
private
private
def
milestone_format_reference
(
format
=
:iid
)
def
milestone_format_reference
(
format
=
:iid
)
...
...
app/views/shared/milestones/_issuables.html.haml
View file @
ff7fe2d1
...
@@ -11,8 +11,8 @@
...
@@ -11,8 +11,8 @@
=
number_with_delimiter
(
issuables
.
size
)
=
number_with_delimiter
(
issuables
.
size
)
-
class_prefix
=
dom_class
(
issuables
).
pluralize
-
class_prefix
=
dom_class
(
issuables
).
pluralize
%ul
{
class:
"well-list
#{class_prefix}-sortable-list"
,
id:
"#{class_prefix}-list-#{id}"
,
"data-state"
=>
id
}
%ul
{
class:
"well-list
milestone-#{class_prefix}-list"
,
id:
"#{class_prefix}-list-#{id}"
}
=
render
partial:
'shared/milestones/issuable'
,
=
render
partial:
'shared/milestones/issuable'
,
collection:
issuables
.
order_position_asc
,
collection:
issuables
.
recent
,
as: :issuable
,
as: :issuable
,
locals:
{
show_project_name:
show_project_name
,
show_full_project_name:
show_full_project_name
}
locals:
{
show_project_name:
show_project_name
,
show_full_project_name:
show_full_project_name
}
changelogs/unreleased/issue_20900.yml
0 → 100644
View file @
ff7fe2d1
---
title
:
Remove Drag and drop and sorting from milestone view
merge_request
:
author
:
lib/api/milestones.rb
View file @
ff7fe2d1
...
@@ -117,7 +117,7 @@ module API
...
@@ -117,7 +117,7 @@ module API
finder_params
=
{
finder_params
=
{
project_id:
user_project
.
id
,
project_id:
user_project
.
id
,
milestone_title:
milestone
.
title
,
milestone_title:
milestone
.
title
,
sort:
'
position_a
sc'
sort:
'
created_de
sc'
}
}
issues
=
IssuesFinder
.
new
(
current_user
,
finder_params
).
execute
issues
=
IssuesFinder
.
new
(
current_user
,
finder_params
).
execute
...
@@ -140,7 +140,7 @@ module API
...
@@ -140,7 +140,7 @@ module API
finder_params
=
{
finder_params
=
{
project_id:
user_project
.
id
,
project_id:
user_project
.
id
,
milestone_title:
milestone
.
title
,
milestone_title:
milestone
.
title
,
sort:
'
position_a
sc'
sort:
'
created_de
sc'
}
}
merge_requests
=
MergeRequestsFinder
.
new
(
current_user
,
finder_params
).
execute
merge_requests
=
MergeRequestsFinder
.
new
(
current_user
,
finder_params
).
execute
...
...
spec/features/milestones/milestones_spec.rb
View file @
ff7fe2d1
require
'rails_helper'
#
require 'rails_helper'
describe
'Milestone draggable'
,
feature:
true
,
js:
true
do
#
describe 'Milestone draggable', feature: true, js: true do
include
DragTo
#
include DragTo
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
,
title:
8.14
)
}
#
let(:milestone) { create(:milestone, project: project, title: 8.14) }
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
#
let(:project) { create(:empty_project, :public) }
let
(
:user
)
{
create
(
:user
)
}
#
let(:user) { create(:user) }
context
'issues'
do
#
context 'issues' do
let
(
:issue
)
{
page
.
find_by_id
(
'issues-list-unassigned'
).
find
(
'li'
)
}
#
let(:issue) { page.find_by_id('issues-list-unassigned').find('li') }
let
(
:issue_target
)
{
page
.
find_by_id
(
'issues-list-ongoing'
)
}
#
let(:issue_target) { page.find_by_id('issues-list-ongoing') }
it
'does not allow guest to drag issue'
do
#
it 'does not allow guest to drag issue' do
create_and_drag_issue
#
create_and_drag_issue
expect
(
issue_target
).
not_to
have_selector
(
'.issuable-row'
)
#
expect(issue_target).not_to have_selector('.issuable-row')
end
#
end
it
'does not allow authorized user to drag issue'
do
#
it 'does not allow authorized user to drag issue' do
login_as
(
user
)
#
login_as(user)
create_and_drag_issue
#
create_and_drag_issue
expect
(
issue_target
).
not_to
have_selector
(
'.issuable-row'
)
#
expect(issue_target).not_to have_selector('.issuable-row')
end
#
end
it
'allows author to drag issue'
do
#
it 'allows author to drag issue' do
login_as
(
user
)
#
login_as(user)
create_and_drag_issue
(
author:
user
)
#
create_and_drag_issue(author: user)
expect
(
issue_target
).
to
have_selector
(
'.issuable-row'
)
#
expect(issue_target).to have_selector('.issuable-row')
end
#
end
it
'allows admin to drag issue'
do
# it 'allows admin to drag issue' do
login_as
(
:admin
)
# login_as(:admin)
create_and_drag_issue
expect
(
issue_target
).
to
have_selector
(
'.issuable-row'
)
# create_and_drag_issue
end
it
'assigns issue when it has been dragged to ongoing list'
do
# expect(issue_target).to have_selector('.issuable-row')
login_as
(
:admin
)
# end
create_and_drag_issue
# end
>>>>>>>
Remove
Drag
and
drop
and
sorting
from
milestone
view
expect
(
@issue
.
reload
.
assignees
).
not_to
be_empty
# context 'merge requests' do
expect
(
page
).
to
have_selector
(
"#sortable_issue_
#{
@issue
.
iid
}
.assignee-icon img"
,
count:
1
)
# let(:merge_request) { page.find_by_id('merge_requests-list-unassigned').find('li') }
end
# let(:merge_request_target) { page.find_by_id('merge_requests-list-ongoing') }
end
context
'merge requests'
do
# it 'does not allow guest to drag merge request' do
let
(
:merge_request
)
{
page
.
find_by_id
(
'merge_requests-list-unassigned'
).
find
(
'li'
)
}
# create_and_drag_merge_request
let
(
:merge_request_target
)
{
page
.
find_by_id
(
'merge_requests-list-ongoing'
)
}
it
'does not allow guest to drag merge request'
do
# expect(merge_request_target).not_to have_selector('.issuable-row')
create_and_drag_merge_request
# end
expect
(
merge_request_target
).
not_to
have_selector
(
'.issuable-row'
)
# it 'does not allow authorized user to drag merge request' do
end
# login_as(user)
# create_and_drag_merge_request
it
'does not allow authorized user to drag merge request'
do
# expect(merge_request_target).not_to have_selector('.issuable-row')
login_as
(
user
)
# end
create_and_drag_merge_request
expect
(
merge_request_target
).
not_to
have_selector
(
'.issuable-row'
)
# it 'allows author to drag merge request' do
end
# login_as(user)
# create_and_drag_merge_request(author: user)
it
'allows author to drag merge request'
do
# expect(merge_request_target).to have_selector('.issuable-row')
login_as
(
user
)
# end
create_and_drag_merge_request
(
author:
user
)
expect
(
merge_request_target
).
to
have_selector
(
'.issuable-row'
)
# it 'allows admin to drag merge request' do
end
# login_as(:admin)
# create_and_drag_merge_request
it
'allows admin to drag merge request'
do
# expect(merge_request_target).to have_selector('.issuable-row')
login_as
(
:admin
)
# end
create_and_drag_merge_request
# end
expect
(
merge_request_target
).
to
have_selector
(
'.issuable-row'
)
end
end
<<<<<<<
5
f42009f8dcc29d559ee415e92c88858e361f063
def
create_and_drag_issue
(
params
=
{})
def
create_and_drag_issue
(
params
=
{})
@issue
=
create
(
:issue
,
params
.
merge
(
title:
'Foo'
,
project:
project
,
milestone:
milestone
))
@issue
=
create
(
:issue
,
params
.
merge
(
title:
'Foo'
,
project:
project
,
milestone:
milestone
))
=======
# def create_and_drag_issue(params = {})
# create(:issue, params.merge(title: 'Foo', project: project, milestone: milestone))
>>>>>>>
Remove
Drag
and
drop
and
sorting
from
milestone
view
visit
namespace_project_milestone_path
(
project
.
namespace
,
project
,
milestone
)
#
visit namespace_project_milestone_path(project.namespace, project, milestone)
scroll_into_view
(
'.milestone-content'
)
#
scroll_into_view('.milestone-content')
drag_to
(
selector:
'.issues-sortable-list'
,
list_to_index:
1
)
#
drag_to(selector: '.issues-sortable-list', list_to_index: 1)
wait_for_requests
#
wait_for_requests
end
#
end
def
create_and_drag_merge_request
(
params
=
{})
#
def create_and_drag_merge_request(params = {})
create
(
:merge_request
,
params
.
merge
(
title:
'Foo'
,
source_project:
project
,
target_project:
project
,
milestone:
milestone
))
#
create(:merge_request, params.merge(title: 'Foo', source_project: project, target_project: project, milestone: milestone))
visit
namespace_project_milestone_path
(
project
.
namespace
,
project
,
milestone
)
#
visit namespace_project_milestone_path(project.namespace, project, milestone)
page
.
find
(
"a[href='#tab-merge-requests']"
).
click
#
page.find("a[href='#tab-merge-requests']").click
wait_for_requests
#
wait_for_requests
scroll_into_view
(
'.milestone-content'
)
#
scroll_into_view('.milestone-content')
drag_to
(
selector:
'.merge_requests-sortable-list'
,
list_to_index:
1
)
#
drag_to(selector: '.merge_requests-sortable-list', list_to_index: 1)
wait_for_requests
#
wait_for_requests
end
#
end
def
scroll_into_view
(
selector
)
#
def scroll_into_view(selector)
page
.
evaluate_script
(
"document.querySelector('
#{
selector
}
').scrollIntoView();"
)
#
page.evaluate_script("document.querySelector('#{selector}').scrollIntoView();")
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