commit-page: show unresolved TODOs on commit page below comments.
This commit is contained in:
parent
adca0da138
commit
9c43777217
5 changed files with 43 additions and 1 deletions
|
|
@ -208,6 +208,7 @@ class ChangesetController(BaseRepoController):
|
|||
|
||||
c.statuses = []
|
||||
c.comments = []
|
||||
c.unresolved_comments = []
|
||||
if len(c.commit_ranges) == 1:
|
||||
commit = c.commit_ranges[0]
|
||||
c.comments = CommentsModel().get_comments(
|
||||
|
|
@ -226,6 +227,9 @@ class ChangesetController(BaseRepoController):
|
|||
for pr in prs:
|
||||
c.comments.extend(pr.comments)
|
||||
|
||||
c.unresolved_comments = CommentsModel()\
|
||||
.get_commit_unresolved_todos(commit.raw_id)
|
||||
|
||||
# Iterate over ranges (default commit view is always one commit)
|
||||
for commit in c.commit_ranges:
|
||||
c.changes[commit.raw_id] = []
|
||||
|
|
@ -275,7 +279,6 @@ class ChangesetController(BaseRepoController):
|
|||
# sort comments by how they were generated
|
||||
c.comments = sorted(c.comments, key=lambda x: x.comment_id)
|
||||
|
||||
|
||||
if len(c.commit_ranges) == 1:
|
||||
c.commit = c.commit_ranges[0]
|
||||
c.parent_tmpl = ''.join(
|
||||
|
|
|
|||
|
|
@ -146,6 +146,23 @@ class CommentsModel(BaseModel):
|
|||
|
||||
return todos
|
||||
|
||||
def get_commit_unresolved_todos(self, commit_id, show_outdated=True):
|
||||
|
||||
todos = Session().query(ChangesetComment) \
|
||||
.filter(ChangesetComment.revision == commit_id) \
|
||||
.filter(ChangesetComment.resolved_by == None) \
|
||||
.filter(ChangesetComment.comment_type
|
||||
== ChangesetComment.COMMENT_TYPE_TODO)
|
||||
|
||||
if not show_outdated:
|
||||
todos = todos.filter(
|
||||
coalesce(ChangesetComment.display_state, '') !=
|
||||
ChangesetComment.COMMENT_OUTDATED)
|
||||
|
||||
todos = todos.all()
|
||||
|
||||
return todos
|
||||
|
||||
def create(self, text, repo, user, commit_id=None, pull_request=None,
|
||||
f_path=None, line_no=None, status_change=None,
|
||||
status_change_type=None, comment_type=None,
|
||||
|
|
|
|||
|
|
@ -241,6 +241,9 @@ function scrollToElement(element, percent, time) {
|
|||
time = (time === undefined ? 100 : time);
|
||||
|
||||
var $element = $(element);
|
||||
if ($element.length == 0) {
|
||||
throw('Cannot scroll to {0}'.format(element))
|
||||
}
|
||||
var elOffset = $element.offset().top;
|
||||
var elHeight = $element.height();
|
||||
var windowHeight = $(window).height();
|
||||
|
|
|
|||
|
|
@ -461,6 +461,7 @@ var CommentsController = function() {
|
|||
};
|
||||
|
||||
this.scrollToComment = function(node, offset, outdated) {
|
||||
var offset = offset || 1;
|
||||
var outdated = outdated || false;
|
||||
var klass = outdated ? 'div.comment-outdated' : 'div.comment-current';
|
||||
|
||||
|
|
@ -486,6 +487,7 @@ var CommentsController = function() {
|
|||
nextIdx = 0;
|
||||
}
|
||||
var $next = $(klass).eq(nextIdx);
|
||||
|
||||
var $cb = $next.closest('.cb');
|
||||
$cb.removeClass('cb-collapsed');
|
||||
|
||||
|
|
|
|||
|
|
@ -155,6 +155,23 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fieldset">
|
||||
<div class="left-label">
|
||||
${_('Unresolved TODOs')}:
|
||||
</div>
|
||||
<div class="right-content">
|
||||
<div class="comments-number">
|
||||
% if c.unresolved_comments:
|
||||
% for co in c.unresolved_comments:
|
||||
<a class="permalink" href="#comment-${co.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${co.comment_id}'))"> #${co.comment_id}</a>${'' if loop.last else ','}
|
||||
% endfor
|
||||
% else:
|
||||
${_('There are no unresolved TODOs')}
|
||||
% endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> <!-- end summary-detail -->
|
||||
|
||||
<div id="commit-stats" class="sidebar-right">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue