Show More
@@ -1,147 +1,147 b'' | |||||
1 | ## snippet for sidebar elements |
|
1 | ## snippet for sidebar elements | |
2 | ## usage: |
|
2 | ## usage: | |
3 | ## <%namespace name="sidebar" file="/base/sidebar.mako"/> |
|
3 | ## <%namespace name="sidebar" file="/base/sidebar.mako"/> | |
4 | ## ${sidebar.comments_table()} |
|
4 | ## ${sidebar.comments_table()} | |
5 | <%namespace name="base" file="/base/base.mako"/> |
|
5 | <%namespace name="base" file="/base/base.mako"/> | |
6 |
|
6 | |||
7 | <%def name="comments_table(comments, counter_num, todo_comments=False, existing_ids=None, is_pr=True)"> |
|
7 | <%def name="comments_table(comments, counter_num, todo_comments=False, existing_ids=None, is_pr=True)"> | |
8 | <% |
|
8 | <% | |
9 | if todo_comments: |
|
9 | if todo_comments: | |
10 | cls_ = 'todos-content-table' |
|
10 | cls_ = 'todos-content-table' | |
11 | def sorter(entry): |
|
11 | def sorter(entry): | |
12 | user_id = entry.author.user_id |
|
12 | user_id = entry.author.user_id | |
13 | resolved = '1' if entry.resolved else '0' |
|
13 | resolved = '1' if entry.resolved else '0' | |
14 | if user_id == c.rhodecode_user.user_id: |
|
14 | if user_id == c.rhodecode_user.user_id: | |
15 | # own comments first |
|
15 | # own comments first | |
16 | user_id = 0 |
|
16 | user_id = 0 | |
17 | return '{}'.format(str(entry.comment_id).zfill(10000)) |
|
17 | return '{}'.format(str(entry.comment_id).zfill(10000)) | |
18 | else: |
|
18 | else: | |
19 | cls_ = 'comments-content-table' |
|
19 | cls_ = 'comments-content-table' | |
20 | def sorter(entry): |
|
20 | def sorter(entry): | |
21 | user_id = entry.author.user_id |
|
21 | user_id = entry.author.user_id | |
22 | return '{}'.format(str(entry.comment_id).zfill(10000)) |
|
22 | return '{}'.format(str(entry.comment_id).zfill(10000)) | |
23 |
|
23 | |||
24 | existing_ids = existing_ids or [] |
|
24 | existing_ids = existing_ids or [] | |
25 |
|
25 | |||
26 | %> |
|
26 | %> | |
27 |
|
27 | |||
28 | <table class="todo-table ${cls_}" data-total-count="${len(comments)}" data-counter="${counter_num}"> |
|
28 | <table class="todo-table ${cls_}" data-total-count="${len(comments)}" data-counter="${counter_num}"> | |
29 |
|
29 | |||
30 | % for loop_obj, comment_obj in h.looper(reversed(sorted(comments, key=sorter))): |
|
30 | % for loop_obj, comment_obj in h.looper(reversed(sorted(comments, key=sorter))): | |
31 | <% |
|
31 | <% | |
32 | display = '' |
|
32 | display = '' | |
33 | _cls = '' |
|
33 | _cls = '' | |
34 | %> |
|
34 | %> | |
35 |
|
35 | |||
36 | <% |
|
36 | <% | |
37 | comment_ver_index = comment_obj.get_index_version(getattr(c, 'versions', [])) |
|
37 | comment_ver_index = comment_obj.get_index_version(getattr(c, 'versions', [])) | |
38 | prev_comment_ver_index = 0 |
|
38 | prev_comment_ver_index = 0 | |
39 | if loop_obj.previous: |
|
39 | if loop_obj.previous: | |
40 | prev_comment_ver_index = loop_obj.previous.get_index_version(getattr(c, 'versions', [])) |
|
40 | prev_comment_ver_index = loop_obj.previous.get_index_version(getattr(c, 'versions', [])) | |
41 |
|
41 | |||
42 | ver_info = None |
|
42 | ver_info = None | |
43 | if getattr(c, 'versions', []): |
|
43 | if getattr(c, 'versions', []): | |
44 | ver_info = c.versions[comment_ver_index-1] if comment_ver_index else None |
|
44 | ver_info = c.versions[comment_ver_index-1] if comment_ver_index else None | |
45 | %> |
|
45 | %> | |
46 | <% hidden_at_ver = comment_obj.outdated_at_version_js(c.at_version_num) %> |
|
46 | <% hidden_at_ver = comment_obj.outdated_at_version_js(c.at_version_num) %> | |
47 | <% is_from_old_ver = comment_obj.older_than_version_js(c.at_version_num) %> |
|
47 | <% is_from_old_ver = comment_obj.older_than_version_js(c.at_version_num) %> | |
48 | <% |
|
48 | <% | |
49 | if (prev_comment_ver_index > comment_ver_index): |
|
49 | if (prev_comment_ver_index > comment_ver_index): | |
50 | comments_ver_divider = comment_ver_index |
|
50 | comments_ver_divider = comment_ver_index | |
51 | else: |
|
51 | else: | |
52 | comments_ver_divider = None |
|
52 | comments_ver_divider = None | |
53 | %> |
|
53 | %> | |
54 |
|
54 | |||
55 | % if todo_comments: |
|
55 | % if todo_comments: | |
56 | % if comment_obj.resolved: |
|
56 | % if comment_obj.resolved: | |
57 | <% _cls = 'resolved-todo' %> |
|
57 | <% _cls = 'resolved-todo' %> | |
58 | <% display = 'none' %> |
|
58 | <% display = 'none' %> | |
59 | % endif |
|
59 | % endif | |
60 | % else: |
|
60 | % else: | |
61 | ## SKIP TODOs we display them in other area |
|
61 | ## SKIP TODOs we display them in other area | |
62 | % if comment_obj.is_todo: |
|
62 | % if comment_obj.is_todo: | |
63 | <% display = 'none' %> |
|
63 | <% display = 'none' %> | |
64 | % endif |
|
64 | % endif | |
65 | ## Skip outdated comments |
|
65 | ## Skip outdated comments | |
66 | % if comment_obj.outdated: |
|
66 | % if comment_obj.outdated: | |
67 | <% display = 'none' %> |
|
67 | <% display = 'none' %> | |
68 | <% _cls = 'hidden-comment' %> |
|
68 | <% _cls = 'hidden-comment' %> | |
69 | % endif |
|
69 | % endif | |
70 | % endif |
|
70 | % endif | |
71 |
|
71 | |||
72 | % if not todo_comments and comments_ver_divider: |
|
72 | % if not todo_comments and comments_ver_divider: | |
73 | <tr class="old-comments-marker"> |
|
73 | <tr class="old-comments-marker"> | |
74 | <td colspan="3"> |
|
74 | <td colspan="3"> | |
75 | % if ver_info: |
|
75 | % if ver_info: | |
76 | <code>v${comments_ver_divider} ${h.age_component(ver_info.created_on, time_is_local=True, tooltip=False)}</code> |
|
76 | <code>v${comments_ver_divider} ${h.age_component(ver_info.created_on, time_is_local=True, tooltip=False)}</code> | |
77 | % else: |
|
77 | % else: | |
78 | <code>v${comments_ver_divider}</code> |
|
78 | <code>v${comments_ver_divider}</code> | |
79 | % endif |
|
79 | % endif | |
80 | </td> |
|
80 | </td> | |
81 | </tr> |
|
81 | </tr> | |
82 |
|
82 | |||
83 | % endif |
|
83 | % endif | |
84 |
|
84 | |||
85 | <tr class="${_cls}" style="display: ${display};" data-sidebar-comment-id="${comment_obj.comment_id}"> |
|
85 | <tr class="${_cls}" style="display: ${display};" data-sidebar-comment-id="${comment_obj.comment_id}"> | |
86 | <td class="td-todo-number"> |
|
86 | <td class="td-todo-number"> | |
87 | <% |
|
87 | <% | |
88 | version_info = '' |
|
88 | version_info = '' | |
89 | if is_pr: |
|
89 | if is_pr: | |
90 | version_info = (' made in older version (v{})'.format(comment_ver_index) if is_from_old_ver == 'true' else ' made in this version') |
|
90 | version_info = (' made in older version (v{})'.format(comment_ver_index) if is_from_old_ver == 'true' else ' made in this version') | |
91 | %> |
|
91 | %> | |
92 |
## |
|
92 | ## new comments, since refresh | |
93 | % if existing_ids and comment_obj.comment_id not in existing_ids: |
|
93 | % if existing_ids and comment_obj.comment_id not in existing_ids: | |
94 | <div class="tooltip" style="position: absolute; left: 8px" title="New comment"> |
|
94 | <div class="tooltip" style="position: absolute; left: 8px; color: #682668" title="New comment"> | |
95 | ! |
|
95 | ! | |
96 | </div> |
|
96 | </div> | |
97 | % endif |
|
97 | % endif | |
98 |
|
98 | |||
99 | <% |
|
99 | <% | |
100 | data = h.json.dumps({ |
|
100 | data = h.json.dumps({ | |
101 | 'comment_id': comment_obj.comment_id, |
|
101 | 'comment_id': comment_obj.comment_id, | |
102 | 'version_info': version_info, |
|
102 | 'version_info': version_info, | |
103 | 'file_name': comment_obj.f_path, |
|
103 | 'file_name': comment_obj.f_path, | |
104 | 'line_no': comment_obj.line_no, |
|
104 | 'line_no': comment_obj.line_no, | |
105 | 'outdated': comment_obj.outdated, |
|
105 | 'outdated': comment_obj.outdated, | |
106 | 'inline': comment_obj.is_inline, |
|
106 | 'inline': comment_obj.is_inline, | |
107 | 'is_todo': comment_obj.is_todo, |
|
107 | 'is_todo': comment_obj.is_todo, | |
108 | 'created_on': h.format_date(comment_obj.created_on), |
|
108 | 'created_on': h.format_date(comment_obj.created_on), | |
109 | 'datetime': '{}{}'.format(comment_obj.created_on, h.get_timezone(comment_obj.created_on, time_is_local=True)), |
|
109 | 'datetime': '{}{}'.format(comment_obj.created_on, h.get_timezone(comment_obj.created_on, time_is_local=True)), | |
110 | 'review_status': (comment_obj.review_status or '') |
|
110 | 'review_status': (comment_obj.review_status or '') | |
111 | }) |
|
111 | }) | |
112 |
|
112 | |||
113 | if comment_obj.outdated: |
|
113 | if comment_obj.outdated: | |
114 | icon = 'icon-comment-toggle' |
|
114 | icon = 'icon-comment-toggle' | |
115 | elif comment_obj.is_inline: |
|
115 | elif comment_obj.is_inline: | |
116 | icon = 'icon-code' |
|
116 | icon = 'icon-code' | |
117 | else: |
|
117 | else: | |
118 | icon = 'icon-comment' |
|
118 | icon = 'icon-comment' | |
119 | %> |
|
119 | %> | |
120 |
|
120 | |||
121 | <i id="commentHovercard${comment_obj.comment_id}" |
|
121 | <i id="commentHovercard${comment_obj.comment_id}" | |
122 | class="${icon} tooltip-hovercard" |
|
122 | class="${icon} tooltip-hovercard" | |
123 | data-hovercard-url="javascript:sidebarComment(${comment_obj.comment_id})" |
|
123 | data-hovercard-url="javascript:sidebarComment(${comment_obj.comment_id})" | |
124 | data-comment-json-b64='${h.b64(data)}'> |
|
124 | data-comment-json-b64='${h.b64(data)}'> | |
125 | </i> |
|
125 | </i> | |
126 |
|
126 | |||
127 | </td> |
|
127 | </td> | |
128 |
|
128 | |||
129 | <td class="td-todo-gravatar"> |
|
129 | <td class="td-todo-gravatar"> | |
130 | ${base.gravatar(comment_obj.author.email, 16, user=comment_obj.author, tooltip=True, extra_class=['no-margin'])} |
|
130 | ${base.gravatar(comment_obj.author.email, 16, user=comment_obj.author, tooltip=True, extra_class=['no-margin'])} | |
131 | </td> |
|
131 | </td> | |
132 | <td class="todo-comment-text-wrapper"> |
|
132 | <td class="todo-comment-text-wrapper"> | |
133 | <div class="todo-comment-text ${('todo-resolved' if comment_obj.resolved else '')}"> |
|
133 | <div class="todo-comment-text ${('todo-resolved' if comment_obj.resolved else '')}"> | |
134 | <a class="${('todo-resolved' if comment_obj.resolved else '')} permalink" |
|
134 | <a class="${('todo-resolved' if comment_obj.resolved else '')} permalink" | |
135 | href="#comment-${comment_obj.comment_id}" |
|
135 | href="#comment-${comment_obj.comment_id}" | |
136 | onclick="return Rhodecode.comments.scrollToComment($('#comment-${comment_obj.comment_id}'), 0, ${hidden_at_ver})"> |
|
136 | onclick="return Rhodecode.comments.scrollToComment($('#comment-${comment_obj.comment_id}'), 0, ${hidden_at_ver})"> | |
137 |
|
137 | |||
138 | ${h.chop_at_smart(comment_obj.text, '\n', suffix_if_chopped='...')} |
|
138 | ${h.chop_at_smart(comment_obj.text, '\n', suffix_if_chopped='...')} | |
139 | </a> |
|
139 | </a> | |
140 | </div> |
|
140 | </div> | |
141 | </td> |
|
141 | </td> | |
142 | </tr> |
|
142 | </tr> | |
143 | % endfor |
|
143 | % endfor | |
144 |
|
144 | |||
145 | </table> |
|
145 | </table> | |
146 |
|
146 | |||
147 | </%def> No newline at end of file |
|
147 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now