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
Léo-Paul Géneau
gitlab-ce
Commits
673bc07c
Commit
673bc07c
authored
Jun 08, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Order merge requests by priority
parent
86fc145c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
10 additions
and
156 deletions
+10
-156
app/assets/javascripts/milestone.js
app/assets/javascripts/milestone.js
+0
-146
app/controllers/concerns/milestone_actions.rb
app/controllers/concerns/milestone_actions.rb
+1
-1
app/models/concerns/milestoneish.rb
app/models/concerns/milestoneish.rb
+3
-3
app/models/dashboard_milestone.rb
app/models/dashboard_milestone.rb
+1
-1
app/models/group_milestone.rb
app/models/group_milestone.rb
+1
-1
app/models/milestone.rb
app/models/milestone.rb
+1
-1
app/views/shared/milestones/_tabs.html.haml
app/views/shared/milestones/_tabs.html.haml
+2
-2
app/views/shared/milestones/_top.html.haml
app/views/shared/milestones/_top.html.haml
+1
-1
No files found.
app/assets/javascripts/milestone.js
View file @
673bc07c
...
@@ -4,86 +4,7 @@
...
@@ -4,86 +4,7 @@
(
function
()
{
(
function
()
{
this
.
Milestone
=
(
function
()
{
this
.
Milestone
=
(
function
()
{
Milestone
.
updateIssue
=
function
(
li
,
issue_url
,
data
)
{
return
$
.
ajax
({
type
:
"
PUT
"
,
url
:
issue_url
,
data
:
data
,
success
:
function
(
_data
)
{
return
Milestone
.
successCallback
(
_data
,
li
);
},
error
:
function
(
data
)
{
return
new
Flash
(
"
Issue update failed
"
,
'
alert
'
);
},
dataType
:
"
json
"
});
};
Milestone
.
sortIssues
=
function
(
url
,
data
)
{
return
$
.
ajax
({
type
:
"
PUT
"
,
url
,
data
:
data
,
success
:
function
(
_data
)
{
return
Milestone
.
successCallback
(
_data
);
},
error
:
function
()
{
return
new
Flash
(
"
Issues update failed
"
,
'
alert
'
);
},
dataType
:
"
json
"
});
};
Milestone
.
sortMergeRequests
=
function
(
url
,
data
)
{
return
$
.
ajax
({
type
:
"
PUT
"
,
url
,
data
:
data
,
success
:
function
(
_data
)
{
return
Milestone
.
successCallback
(
_data
);
},
error
:
function
(
data
)
{
return
new
Flash
(
"
Issue update failed
"
,
'
alert
'
);
},
dataType
:
"
json
"
});
};
Milestone
.
updateMergeRequest
=
function
(
li
,
merge_request_url
,
data
)
{
return
$
.
ajax
({
type
:
"
PUT
"
,
url
:
merge_request_url
,
data
:
data
,
success
:
function
(
_data
)
{
return
Milestone
.
successCallback
(
_data
,
li
);
},
error
:
function
(
data
)
{
return
new
Flash
(
"
Issue update failed
"
,
'
alert
'
);
},
dataType
:
"
json
"
});
};
Milestone
.
successCallback
=
function
(
data
,
element
)
{
const
$avatarContainer
=
$
(
element
).
find
(
'
.assignee-icon
'
);
$avatarContainer
.
empty
();
if
(
data
.
assignees
&&
data
.
assignees
.
length
>
0
)
{
const
$avatars
=
data
.
assignees
.
map
((
assignee
)
=>
{
const
img_tag
=
$
(
'
<img/>
'
);
img_tag
.
attr
(
'
src
'
,
assignee
.
avatar_url
);
img_tag
.
addClass
(
'
avatar s16
'
);
return
img_tag
;
});
$avatarContainer
.
append
(
$avatars
);
}
};
function
Milestone
()
{
function
Milestone
()
{
this
.
issuesSortEndpoint
=
$
(
'
#tab-issues
'
).
data
(
'
sort-endpoint
'
);
this
.
mergeRequestsSortEndpoint
=
$
(
'
#tab-merge-requests
'
).
data
(
'
sort-endpoint
'
);
this
.
bindTabsSwitching
();
this
.
bindTabsSwitching
();
// Load merge request tab if it is active
// Load merge request tab if it is active
...
@@ -102,69 +23,6 @@
...
@@ -102,69 +23,6 @@
});
});
};
};
Milestone
.
prototype
.
bindMergeRequestSorting
=
function
()
{
if
(
!
this
.
mergeRequestsSortEndpoint
)
return
;
$
(
"
#merge_requests-list-unassigned, #merge_requests-list-ongoing, #merge_requests-list-closed
"
).
each
(
function
(
i
,
el
)
{
this
.
createSortable
(
el
,
{
group
:
'
merge-request-list
'
,
listEls
:
$
(
"
.merge_requests-sortable-list:not(#merge_requests-list-merged)
"
),
fieldName
:
'
merge_request
'
,
sortCallback
:
(
data
)
=>
{
Milestone
.
sortMergeRequests
(
this
.
mergeRequestsSortEndpoint
,
data
);
},
updateCallback
:
Milestone
.
updateMergeRequest
,
});
}.
bind
(
this
));
};
Milestone
.
prototype
.
createSortable
=
function
(
el
,
opts
)
{
return
Sortable
.
create
(
el
,
{
group
:
opts
.
group
,
filter
:
'
.is-disabled
'
,
forceFallback
:
true
,
onStart
:
function
(
e
)
{
opts
.
listEls
.
css
(
'
min-height
'
,
e
.
item
.
offsetHeight
);
},
onEnd
:
function
()
{
opts
.
listEls
.
css
(
"
min-height
"
,
"
0px
"
);
},
onUpdate
:
function
(
e
)
{
var
ids
=
this
.
toArray
(),
data
;
if
(
ids
.
length
)
{
data
=
ids
.
map
(
function
(
id
)
{
return
'
sortable_
'
+
opts
.
fieldName
+
'
[]=
'
+
id
;
}).
join
(
'
&
'
);
opts
.
sortCallback
(
data
);
}
},
onAdd
:
function
(
e
)
{
var
data
,
issuableId
,
issuableUrl
,
newState
;
newState
=
e
.
to
.
dataset
.
state
;
issuableUrl
=
e
.
item
.
dataset
.
url
;
data
=
(
function
()
{
switch
(
newState
)
{
case
'
ongoing
'
:
return
`
${
opts
.
fieldName
}
[assignee_ids][]=
${
gon
.
current_user_id
}
`
;
case
'
unassigned
'
:
return
`
${
opts
.
fieldName
}
[assignee_ids][]=0`
;
case
'
closed
'
:
return
opts
.
fieldName
+
'
[state_event]=close
'
;
}
})();
if
(
e
.
from
.
dataset
.
state
===
'
closed
'
)
{
data
+=
'
&
'
+
opts
.
fieldName
+
'
[state_event]=reopen
'
;
}
opts
.
updateCallback
(
e
.
item
,
issuableUrl
,
data
);
this
.
options
.
onUpdate
.
call
(
this
,
e
);
}
});
};
Milestone
.
prototype
.
loadInitialTab
=
function
()
{
Milestone
.
prototype
.
loadInitialTab
=
function
()
{
const
$target
=
$
(
`.js-milestone-tabs a[href="
${
location
.
hash
}
"]`
);
const
$target
=
$
(
`.js-milestone-tabs a[href="
${
location
.
hash
}
"]`
);
...
@@ -186,10 +44,6 @@
...
@@ -186,10 +44,6 @@
.
done
((
data
)
=>
{
.
done
((
data
)
=>
{
$
(
tabElId
).
html
(
data
.
html
);
$
(
tabElId
).
html
(
data
.
html
);
$target
.
addClass
(
'
is-loaded
'
);
$target
.
addClass
(
'
is-loaded
'
);
if
(
tabElId
===
'
#tab-merge-requests
'
)
{
this
.
bindMergeRequestSorting
();
}
});
});
}
}
};
};
...
...
app/controllers/concerns/milestone_actions.rb
View file @
673bc07c
...
@@ -6,7 +6,7 @@ module MilestoneActions
...
@@ -6,7 +6,7 @@ module MilestoneActions
format
.
html
{
redirect_to
milestone_redirect_path
}
format
.
html
{
redirect_to
milestone_redirect_path
}
format
.
json
do
format
.
json
do
render
json:
tabs_json
(
"shared/milestones/_merge_requests_tab"
,
{
render
json:
tabs_json
(
"shared/milestones/_merge_requests_tab"
,
{
merge_requests:
@milestone
.
merge_requests
,
merge_requests:
@milestone
.
merge_requests
.
sort
(
'priority'
)
,
show_project_name:
true
show_project_name:
true
})
})
end
end
...
...
app/models/concerns/milestoneish.rb
View file @
673bc07c
module
Milestoneish
module
Milestoneish
def
closed_items_count
(
user
)
def
closed_items_count
(
user
)
memoize_per_user
(
user
,
:closed_items_count
)
do
memoize_per_user
(
user
,
:closed_items_count
)
do
(
count_issues_by_state
(
user
)[
'closed'
]
.
count
||
0
)
+
merge_requests
.
closed_and_merged
.
size
(
count_issues_by_state
(
user
)[
'closed'
]
&
.
length
||
0
)
+
merge_requests
.
closed_and_merged
.
size
end
end
end
end
...
@@ -39,7 +39,7 @@ module Milestoneish
...
@@ -39,7 +39,7 @@ module Milestoneish
def
issues_visible_to_user
(
user
)
def
issues_visible_to_user
(
user
)
memoize_per_user
(
user
,
:issues_visible_to_user
)
do
memoize_per_user
(
user
,
:issues_visible_to_user
)
do
IssuesFinder
.
new
(
user
,
issues_finder_params
.
merge
({
sort:
'priority'
})
)
IssuesFinder
.
new
(
user
,
issues_finder_params
)
.
execute
.
preload
(
:assignees
).
where
(
milestone_id:
milestoneish_ids
)
.
execute
.
preload
(
:assignees
).
where
(
milestone_id:
milestoneish_ids
)
end
end
end
end
...
@@ -81,6 +81,6 @@ module Milestoneish
...
@@ -81,6 +81,6 @@ module Milestoneish
# override in a class that includes this module to get a faster query
# override in a class that includes this module to get a faster query
# from IssuesFinder
# from IssuesFinder
def
issues_finder_params
def
issues_finder_params
{}
{
sort:
'priority'
}
end
end
end
end
app/models/dashboard_milestone.rb
View file @
673bc07c
class
DashboardMilestone
<
GlobalMilestone
class
DashboardMilestone
<
GlobalMilestone
def
issues_finder_params
def
issues_finder_params
{
authorized_only:
true
}
super
.
merge
({
authorized_only:
true
})
end
end
end
end
app/models/group_milestone.rb
View file @
673bc07c
...
@@ -14,6 +14,6 @@ class GroupMilestone < GlobalMilestone
...
@@ -14,6 +14,6 @@ class GroupMilestone < GlobalMilestone
end
end
def
issues_finder_params
def
issues_finder_params
{
group_id:
group
.
id
}
super
.
merge
({
group_id:
group
.
id
})
end
end
end
end
app/models/milestone.rb
View file @
673bc07c
...
@@ -187,6 +187,6 @@ class Milestone < ActiveRecord::Base
...
@@ -187,6 +187,6 @@ class Milestone < ActiveRecord::Base
end
end
def
issues_finder_params
def
issues_finder_params
{
project_id:
project_id
}
super
.
merge
({
project_id:
project_id
})
end
end
end
end
app/views/shared/milestones/_tabs.html.haml
View file @
673bc07c
...
@@ -32,11 +32,11 @@
...
@@ -32,11 +32,11 @@
-
if
milestone
.
is_a?
(
GlobalMilestone
)
||
can?
(
current_user
,
:read_issue
,
@project
)
-
if
milestone
.
is_a?
(
GlobalMilestone
)
||
can?
(
current_user
,
:read_issue
,
@project
)
.tab-pane.active
#tab-issues
{
data:
{
sort_endpoint:
(
sort_issues_namespace_project_milestone_path
(
@project
.
namespace
,
@project
,
@milestone
)
if
@project
&&
current_user
)
}
}
.tab-pane.active
#tab-issues
{
data:
{
sort_endpoint:
(
sort_issues_namespace_project_milestone_path
(
@project
.
namespace
,
@project
,
@milestone
)
if
@project
&&
current_user
)
}
}
=
render
'shared/milestones/issues_tab'
,
issues:
milestone
.
issues_visible_to_user
(
current_user
).
preload_associations
,
show_project_name:
show_project_name
,
show_full_project_name:
show_full_project_name
=
render
'shared/milestones/issues_tab'
,
issues:
milestone
.
issues_visible_to_user
(
current_user
).
preload_associations
,
show_project_name:
show_project_name
,
show_full_project_name:
show_full_project_name
.tab-pane
#tab-merge-requests
{
data:
{
sort_endpoint:
(
sort_merge_requests_namespace_project_milestone_path
(
@project
.
namespace
,
@project
,
@milestone
)
if
@project
&&
current_user
)
}
}
.tab-pane
#tab-merge-requests
-# loaded async
-# loaded async
=
render
"shared/milestones/tab_loading"
=
render
"shared/milestones/tab_loading"
-
else
-
else
.tab-pane.active
#tab-merge-requests
{
data:
{
sort_endpoint:
(
sort_merge_requests_namespace_project_milestone_path
(
@project
.
namespace
,
@project
,
@milestone
)
if
@project
&&
current_user
)
}
}
.tab-pane.active
#tab-merge-requests
-# loaded async
-# loaded async
=
render
"shared/milestones/tab_loading"
=
render
"shared/milestones/tab_loading"
.tab-pane
#tab-participants
.tab-pane
#tab-participants
...
...
app/views/shared/milestones/_top.html.haml
View file @
673bc07c
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
-
project_name
=
group
?
ms
.
project
.
name
:
ms
.
project
.
name_with_namespace
-
project_name
=
group
?
ms
.
project
.
name
:
ms
.
project
.
name_with_namespace
=
link_to
project_name
,
namespace_project_milestone_path
(
ms
.
project
.
namespace
,
ms
.
project
,
ms
)
=
link_to
project_name
,
namespace_project_milestone_path
(
ms
.
project
.
namespace
,
ms
.
project
,
ms
)
%td
%td
=
ms
.
issues_visible_to_user
(
current_user
).
opened
.
count
=
ms
.
issues_visible_to_user
(
current_user
).
opened
.
length
%td
%td
-
if
ms
.
closed?
-
if
ms
.
closed?
Closed
Closed
...
...
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