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
5d7b46d5
Commit
5d7b46d5
authored
Jul 31, 2019
by
charlie ablett
Committed by
Paul Slaughter
Jul 31, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port CE changes from EE
- DB migration of board milestone values - issue finder & spec updates
parent
bea3d730
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
23 deletions
+51
-23
app/assets/javascripts/milestone_select.js
app/assets/javascripts/milestone_select.js
+5
-3
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+12
-15
app/models/milestone.rb
app/models/milestone.rb
+2
-2
changelogs/unreleased/4221-board-milestone-should-persist-any-none-properly.yml
...4221-board-milestone-should-persist-any-none-properly.yml
+5
-0
db/migrate/20190703001120_default_milestone_to_nil.rb
db/migrate/20190703001120_default_milestone_to_nil.rb
+24
-0
spec/finders/issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+2
-2
spec/requests/api/issues/get_project_issues_spec.rb
spec/requests/api/issues/get_project_issues_spec.rb
+1
-1
No files found.
app/assets/javascripts/milestone_select.js
View file @
5d7b46d5
...
@@ -55,7 +55,7 @@ export default class MilestoneSelect {
...
@@ -55,7 +55,7 @@ export default class MilestoneSelect {
const
$sidebarCollapsedValue
=
$block
.
find
(
'
.sidebar-collapsed-icon
'
);
const
$sidebarCollapsedValue
=
$block
.
find
(
'
.sidebar-collapsed-icon
'
);
const
$value
=
$block
.
find
(
'
.value
'
);
const
$value
=
$block
.
find
(
'
.value
'
);
const
$loading
=
$block
.
find
(
'
.block-loading
'
).
fadeOut
();
const
$loading
=
$block
.
find
(
'
.block-loading
'
).
fadeOut
();
selectedMilestoneDefault
=
showAny
?
''
:
null
;
selectedMilestoneDefault
=
showAny
?
__
(
'
Any Milestone
'
)
:
null
;
selectedMilestoneDefault
=
selectedMilestoneDefault
=
showNo
&&
defaultNo
?
__
(
'
No Milestone
'
)
:
selectedMilestoneDefault
;
showNo
&&
defaultNo
?
__
(
'
No Milestone
'
)
:
selectedMilestoneDefault
;
selectedMilestone
=
$dropdown
.
data
(
'
selected
'
)
||
selectedMilestoneDefault
;
selectedMilestone
=
$dropdown
.
data
(
'
selected
'
)
||
selectedMilestoneDefault
;
...
@@ -74,14 +74,16 @@ export default class MilestoneSelect {
...
@@ -74,14 +74,16 @@ export default class MilestoneSelect {
if
(
showAny
)
{
if
(
showAny
)
{
extraOptions
.
push
({
extraOptions
.
push
({
id
:
null
,
id
:
null
,
name
:
null
,
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
name
:
'
Any
'
,
title
:
__
(
'
Any Milestone
'
),
title
:
__
(
'
Any Milestone
'
),
});
});
}
}
if
(
showNo
)
{
if
(
showNo
)
{
extraOptions
.
push
({
extraOptions
.
push
({
id
:
-
1
,
id
:
-
1
,
name
:
__
(
'
No Milestone
'
),
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
name
:
'
None
'
,
title
:
__
(
'
No Milestone
'
),
title
:
__
(
'
No Milestone
'
),
});
});
}
}
...
...
app/finders/issuable_finder.rb
View file @
5d7b46d5
...
@@ -484,22 +484,19 @@ class IssuableFinder
...
@@ -484,22 +484,19 @@ class IssuableFinder
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
by_milestone
(
items
)
def
by_milestone
(
items
)
if
milestones?
return
items
unless
milestones?
return
items
if
filter_by_any_milestone?
if
filter_by_no_milestone?
if
filter_by_no_milestone?
items
=
items
.
left_joins_milestones
.
where
(
milestone_id:
[
-
1
,
nil
])
items
.
left_joins_milestones
.
where
(
milestone_id:
nil
)
elsif
filter_by_any_milestone?
items
=
items
.
any_milestone
elsif
filter_by_upcoming_milestone?
elsif
filter_by_upcoming_milestone?
upcoming_ids
=
Milestone
.
upcoming_ids
(
projects
,
related_groups
)
upcoming_ids
=
Milestone
.
upcoming_ids
(
projects
,
related_groups
)
items
=
items
.
left_joins_milestones
.
where
(
milestone_id:
upcoming_ids
)
items
.
left_joins_milestones
.
where
(
milestone_id:
upcoming_ids
)
elsif
filter_by_started_milestone?
elsif
filter_by_started_milestone?
items
=
items
.
left_joins_milestones
.
merge
(
Milestone
.
started
)
items
.
left_joins_milestones
.
merge
(
Milestone
.
started
)
else
else
items
=
items
.
with_milestone
(
params
[
:milestone_title
])
items
.
with_milestone
(
params
[
:milestone_title
])
end
end
end
items
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
...
...
app/models/milestone.rb
View file @
5d7b46d5
...
@@ -4,8 +4,8 @@ class Milestone < ApplicationRecord
...
@@ -4,8 +4,8 @@ class Milestone < ApplicationRecord
# Represents a "No Milestone" state used for filtering Issues and Merge
# Represents a "No Milestone" state used for filtering Issues and Merge
# Requests that have no milestone assigned.
# Requests that have no milestone assigned.
MilestoneStruct
=
Struct
.
new
(
:title
,
:name
,
:id
)
MilestoneStruct
=
Struct
.
new
(
:title
,
:name
,
:id
)
None
=
MilestoneStruct
.
new
(
'No Milestone'
,
'No Milestone'
,
0
)
None
=
MilestoneStruct
.
new
(
'No Milestone'
,
'No Milestone'
,
-
1
)
Any
=
MilestoneStruct
.
new
(
'Any Milestone'
,
''
,
-
1
)
Any
=
MilestoneStruct
.
new
(
'Any Milestone'
,
''
,
nil
)
Upcoming
=
MilestoneStruct
.
new
(
'Upcoming'
,
'#upcoming'
,
-
2
)
Upcoming
=
MilestoneStruct
.
new
(
'Upcoming'
,
'#upcoming'
,
-
2
)
Started
=
MilestoneStruct
.
new
(
'Started'
,
'#started'
,
-
3
)
Started
=
MilestoneStruct
.
new
(
'Started'
,
'#started'
,
-
3
)
...
...
changelogs/unreleased/4221-board-milestone-should-persist-any-none-properly.yml
0 → 100644
View file @
5d7b46d5
---
title
:
For milestone filters, treat Any as No Filter (using
null
). Use -1 for No Milestone
merge_request
:
author
:
type
:
changed
db/migrate/20190703001120_default_milestone_to_nil.rb
0 → 100644
View file @
5d7b46d5
# frozen_string_literal: true
class
DefaultMilestoneToNil
<
ActiveRecord
::
Migration
[
5.1
]
DOWNTIME
=
false
def
up
execute
(
update_board_milestones_query
)
end
def
down
# no-op
end
private
# Only 105 records to update, as of 2019/07/18
def
update_board_milestones_query
<<~
HEREDOC
UPDATE boards
SET milestone_id = NULL
WHERE boards.milestone_id = -1
HEREDOC
end
end
spec/finders/issues_finder_spec.rb
View file @
5d7b46d5
...
@@ -113,13 +113,13 @@ describe IssuesFinder do
...
@@ -113,13 +113,13 @@ describe IssuesFinder do
let
(
:params
)
{
{
milestone_title:
'Any'
}
}
let
(
:params
)
{
{
milestone_title:
'Any'
}
}
it
'returns issues with any assigned milestone'
do
it
'returns issues with any assigned milestone'
do
expect
(
issues
).
to
contain_exactly
(
issue1
)
expect
(
issues
).
to
contain_exactly
(
issue1
,
issue2
,
issue3
,
issue4
)
end
end
it
'returns issues with any assigned milestone (deprecated)'
do
it
'returns issues with any assigned milestone (deprecated)'
do
params
[
:milestone_title
]
=
Milestone
::
Any
.
title
params
[
:milestone_title
]
=
Milestone
::
Any
.
title
expect
(
issues
).
to
contain_exactly
(
issue1
)
expect
(
issues
).
to
contain_exactly
(
issue1
,
issue2
,
issue3
,
issue4
)
end
end
end
end
...
...
spec/requests/api/issues/get_project_issues_spec.rb
View file @
5d7b46d5
...
@@ -389,7 +389,7 @@ describe API::Issues do
...
@@ -389,7 +389,7 @@ describe API::Issues do
it
'returns an array of issues with any milestone'
do
it
'returns an array of issues with any milestone'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone:
any_milestone_title
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone:
any_milestone_title
}
expect_paginated_array_response
([
issue
.
id
,
closed_issue
.
id
])
expect_paginated_array_response
([
issue
.
id
,
c
onfidential_issue
.
id
,
c
losed_issue
.
id
])
end
end
context
'without sort params'
do
context
'without sort params'
do
...
...
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