Mercurial > hg
diff mercurial/templates/static/followlines.js @ 32070:a298f5c61b34 stable
hgweb: do not show "descending" link in followlines UI for filelog heads
When on a filelog head, we are certain that there will be no descendant so the
target of the "descending" link will lead to an empty log result. Do not
display the link in this case.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Mon, 24 Apr 2017 10:32:15 +0200 |
parents | 6ce09d2cc2db |
children | 1cf0b651fa70 |
line wrap: on
line diff
--- a/mercurial/templates/static/followlines.js Mon Apr 24 18:33:23 2017 +0200 +++ b/mercurial/templates/static/followlines.js Mon Apr 24 10:32:15 2017 +0200 @@ -17,6 +17,8 @@ return; } + var isHead = parseInt(sourcelines.dataset.ishead || "0"); + // tooltip to invite on lines selection var tooltip = document.createElement('div'); tooltip.id = 'followlines-tooltip'; @@ -153,7 +155,7 @@ // append the <div id="followlines"> element to last line of the // selection block - var divAndButton = followlinesBox(targetUri, startId, endId); + var divAndButton = followlinesBox(targetUri, startId, endId, isHead); var div = divAndButton[0], button = divAndButton[1]; inviteElement.appendChild(div); @@ -186,7 +188,7 @@ sourcelines.addEventListener('click', lineSelectStart); //** return a <div id="followlines"> and inner cancel <button> elements */ - function followlinesBox(targetUri, fromline, toline) { + function followlinesBox(targetUri, fromline, toline, isHead) { // <div id="followlines"> var div = document.createElement('div'); div.id = 'followlines'; @@ -213,13 +215,16 @@ aAsc.setAttribute('href', url); aAsc.textContent = 'ascending'; aDiv.appendChild(aAsc); - var sep = document.createTextNode(' / '); - aDiv.appendChild(sep); - // link to "descending" followlines - var aDesc = document.createElement('a'); - aDesc.setAttribute('href', url + '&descend='); - aDesc.textContent = 'descending'; - aDiv.appendChild(aDesc); + + if (!isHead) { + var sep = document.createTextNode(' / '); + aDiv.appendChild(sep); + // link to "descending" followlines + var aDesc = document.createElement('a'); + aDesc.setAttribute('href', url + '&descend='); + aDesc.textContent = 'descending'; + aDiv.appendChild(aDesc); + } div.appendChild(aDiv);