Changeset - 4bf9d7f18253
[Not reviewed]
default
0 2 0
Mads Kiilerich (mads) - 6 years ago 2020-06-18 14:25:23
mads@kiilerich.com
diff: fix ignorews/context link to use the right target as anchor

The value in url_fid might not be a valid anchor.

For changesets, url_fid would be like 'C--9c390eb52cd6' even though the actual
target included the changeset hash and were like 'C-1536d03b4869-9c390eb52cd6'.

For pullrequests and compare, it wouldn't link to anything at all, even though
there was a target like 'C--56535da5df40'.

Instead, pass id_fid as anchor value as a separate argument. That one is a
valid anchor.
2 files changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/changeset.py
Show inline comments
 
@@ -70,7 +70,7 @@ def get_ignore_ws(fid, GET):
 
    return ig_ws_global
 

	
 

	
 
def _ignorews_url(GET, fileid=None):
 
def _ignorews_url(GET, fileid=None, anchor=None):
 
    fileid = str(fileid) if fileid else None
 
    params = defaultdict(list)
 
    _update_with_GET(params, GET)
 
@@ -96,7 +96,7 @@ def _ignorews_url(GET, fileid=None):
 
    if ln_ctx:
 
        params[ctx_key] += [ctx_val]
 

	
 
    params['anchor'] = fileid
 
    params['anchor'] = anchor
 
    icon = h.literal('<i class="icon-strike"></i>')
 
    return h.link_to(icon, h.url.current(**params), title=lbl, **{'data-toggle': 'tooltip'})
 

	
 
@@ -122,7 +122,7 @@ def get_line_ctx(fid, GET):
 
        return 3
 

	
 

	
 
def _context_url(GET, fileid=None):
 
def _context_url(GET, fileid=None, anchor=None):
 
    """
 
    Generates url for context lines
 

	
 
@@ -156,7 +156,7 @@ def _context_url(GET, fileid=None):
 

	
 
    lbl = _('Increase diff context to %(num)s lines') % {'num': ln_ctx}
 

	
 
    params['anchor'] = fileid
 
    params['anchor'] = anchor
 
    icon = h.literal('<i class="icon-sort"></i>')
 
    return h.link_to(icon, h.url.current(**params), title=lbl, **{'data-toggle': 'tooltip'})
 

	
kallithea/templates/changeset/diff_block.html
Show inline comments
 
@@ -65,8 +65,8 @@
 
                      <i class="icon-diff"></i></a>
 
                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=cs_filename,diff2=cs_rev,diff1=a_rev,diff='download')}" data-toggle="tooltip" title="${_('Download diff for this file')}">
 
                      <i class="icon-floppy"></i></a>
 
                  ${c.ignorews_url(request.GET, url_fid)}
 
                  ${c.context_url(request.GET, url_fid)}
 
                  ${c.ignorews_url(request.GET, url_fid, id_fid)}
 
                  ${c.context_url(request.GET, url_fid, id_fid)}
 
                </div>
 
                <div class="pull-right">
 
                    ${_('Show inline comments')}
0 comments (0 inline, 0 general)