fix(ui): fixed issues with hover menus and diff download items.

- the diff ops are now moved into context menu
- the diff ops could be now used in PR context
- fixed various UI problems with the old solution
This commit is contained in:
RhodeCode Admin 2024-02-12 12:54:05 +01:00
parent 54b5e23168
commit d4070f83d4
4 changed files with 111 additions and 92 deletions

View file

@ -124,24 +124,6 @@
</div>
<div class="fieldset collapsable-content" data-toggle="summary-details" style="display: none;">
<div class="left-label-summary">
<p>${_('Diff options')}:</p>
<div class="right-label-summary">
<div class="diff-actions">
<a href="${h.route_path('repo_commit_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id)}">
${_('Raw Diff')}
</a>
|
<a href="${h.route_path('repo_commit_patch',repo_name=c.repo_name,commit_id=c.commit.raw_id)}">
${_('Patch Diff')}
</a>
|
<a href="${h.route_path('repo_commit_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,_query=dict(diff='download'))}">
${_('Download Diff')}
</a>
</div>
</div>
</div>
</div>
<div class="clear-fix"></div>

View file

@ -277,12 +277,16 @@ return '%s_%s_%i' % (h.md5_safe(commit+filename), type, line)
%>
<div class="filediff-collapse-indicator icon-"></div>
## Comments/Options PILL
<span class="pill-group pull-right">
<span class="pill" op="comments">
<i class="icon-comment"></i> ${len(total_file_comments)}
</span>
<%
from rhodecode.lib.diffs import NEW_FILENODE, DEL_FILENODE, MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE, COPIED_FILENODE
%>
<span class="pill">
<i class="icon-file-text"></i>
${final_file_name}
</span>
## Options PILL
<span class="pill-group pull-right">
<details class="details-reset details-inline-block">
<summary class="noselect">
<i class="pill icon-options cursor-pointer" op="options"></i>
@ -290,24 +294,77 @@ return '%s_%s_%i' % (h.md5_safe(commit+filename), type, line)
<details-menu class="details-dropdown">
<div class="dropdown-item">
<span>${final_path}</span>
<span class="pull-right icon-clipboard clipboard-action" data-clipboard-text="${final_path}" title="Copy file path"></span>
<ul class="inline-menu">
<li class="inline-menu-item"><span class="inline-menu-item-ellipsis">${final_path}</span></li>
<li class="inline-menu-item"><span class="pull-right icon-clipboard clipboard-action" data-clipboard-text="${final_path}" title="Copy file path"></span></li>
</ul>
</div>
<div class="dropdown-divider"></div>
<div class="dropdown-item">
<% permalink = request.current_route_url(_anchor='a_{}'.format(h.FID(filediff.raw_id, filediff.patch['filename']))) %>
<a href="${permalink}">¶ permalink</a>
<span class="pull-right icon-clipboard clipboard-action" data-clipboard-text="${permalink}" title="Copy permalink"></span>
<% permalink = request.current_route_url(_anchor='a_{}'.format(h.FID(filediff.raw_id, filediff.patch['filename']))) %>
<ul class="inline-menu">
<li class="inline-menu-item"><a href="${permalink}">¶ permalink</a></li>
<li class="inline-menu-item"><span class="pull-right icon-clipboard clipboard-action" data-clipboard-text="${permalink}" title="Copy permalink"></span></li>
</ul>
</div>
</details-menu>
</details>
</span>
${diff_ops(final_file_name, filediff)}
## Comments PILL
<span class="pill-group pull-right">
<span class="pill" op="comments">
<i class="icon-comment"></i> ${len(total_file_comments)}
</span>
</span>
## DIFF STATS PILL
<span class="pill-group pull-right">
## ops pills
%if filediff.limited_diff:
<span class="pill tooltip" op="limited"
title="The stats for this diff are not complete">limited diff</span>
%endif
%if NEW_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="created">created</span>
%if filediff['target_mode'].startswith('120'):
<span class="pill" op="symlink">symlink</span>
%else:
<span class="pill" op="mode">${nice_mode(filediff['target_mode'])}</span>
%endif
%endif
%if RENAMED_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="renamed">renamed</span>
%endif
%if COPIED_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="copied">copied</span>
%endif
%if DEL_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="removed">removed</span>
%endif
%if CHMOD_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="mode"> ${nice_mode(filediff['source_mode'])} ➡ ${nice_mode(filediff['target_mode'])}</span>
%endif
%if BIN_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="binary">binary</span>
%if MOD_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="modified">modified</span>
%endif
%endif
<span class="pill" op="added">${('+' if filediff.patch['stats']['added'] else '')}${filediff.patch['stats']['added']}</span>
<span class="pill" op="deleted">${((h.safe_int(filediff.patch['stats']['deleted']) or 0) * -1)}</span>
</span>
</label>
@ -506,64 +563,6 @@ return '%s_%s_%i' % (h.md5_safe(commit+filename), type, line)
</div>
</%def>
<%def name="diff_ops(file_name, filediff)">
<%
from rhodecode.lib.diffs import NEW_FILENODE, DEL_FILENODE, \
MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE, COPIED_FILENODE
%>
<span class="pill">
<i class="icon-file-text"></i>
${file_name}
</span>
<span class="pill-group pull-right">
## ops pills
%if filediff.limited_diff:
<span class="pill tooltip" op="limited" title="The stats for this diff are not complete">limited diff</span>
%endif
%if NEW_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="created">created</span>
%if filediff['target_mode'].startswith('120'):
<span class="pill" op="symlink">symlink</span>
%else:
<span class="pill" op="mode">${nice_mode(filediff['target_mode'])}</span>
%endif
%endif
%if RENAMED_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="renamed">renamed</span>
%endif
%if COPIED_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="copied">copied</span>
%endif
%if DEL_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="removed">removed</span>
%endif
%if CHMOD_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="mode">
${nice_mode(filediff['source_mode'])} ➡ ${nice_mode(filediff['target_mode'])}
</span>
%endif
%if BIN_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="binary">binary</span>
%if MOD_FILENODE in filediff.patch['stats']['ops']:
<span class="pill" op="modified">modified</span>
%endif
%endif
<span class="pill" op="added">${('+' if filediff.patch['stats']['added'] else '')}${filediff.patch['stats']['added']}</span>
<span class="pill" op="deleted">${((h.safe_int(filediff.patch['stats']['deleted']) or 0) * -1)}</span>
</span>
</%def>
<%def name="nice_mode(filemode)">
${(filemode.startswith('100') and filemode[3:] or filemode)}
</%def>
@ -968,10 +967,9 @@ def get_comments_for(diff_type, comments, filename, line_version, line_number):
<i class="icon-options cursor-pointer" op="options"></i>
</summary>
<div>
<details-menu class="details-dropdown" style="top: 35px;">
<div class="dropdown-item">
<div class="dropdown-item">
<div style="padding: 2px 0px">
% if request.GET.get('ignorews', '') == '1':
<a href="${h.current_route_path(request, ignorews=0)}">${_('Show whitespace changes')}</a>
@ -991,8 +989,28 @@ def get_comments_for(diff_type, comments, filename, line_version, line_number):
</div>
</div>
% if commit:
<div class="dropdown-item">
<a href="${h.route_path('repo_commit_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id)}">
${_('Raw Diff')}
</a>
</div>
<div class="dropdown-item">
<a href="${h.route_path('repo_commit_patch',repo_name=c.repo_name,commit_id=c.commit.raw_id)}">
${_('Patch Diff')}
</a>
</div>
<div class="dropdown-item">
<a href="${h.route_path('repo_commit_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,_query=dict(diff='download'))}">
${_('Download Diff')}
</a>
</div>
% endif
</details-menu>
</div>
</details>
</div>