feat: 导航到生成/审查页面时,将所选 Base/Head 作为 URL 参数传递
This commit is contained in:
@@ -169,6 +169,7 @@
|
|||||||
if (refsResp.ok) {
|
if (refsResp.ok) {
|
||||||
currentRefs = await refsResp.json();
|
currentRefs = await refsResp.json();
|
||||||
populateRefSelects(currentRefs);
|
populateRefSelects(currentRefs);
|
||||||
|
updateButtonLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init graph with click-to-select
|
// Init graph with click-to-select
|
||||||
@@ -305,6 +306,8 @@
|
|||||||
showTab('diff');
|
showTab('diff');
|
||||||
loadDiff();
|
loadDiff();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateButtonLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure a select has an option with given value
|
// Ensure a select has an option with given value
|
||||||
@@ -331,12 +334,25 @@
|
|||||||
if (baseHash || headHash) {
|
if (baseHash || headHash) {
|
||||||
GitGraph.setSelection(baseHash || null, headHash || null);
|
GitGraph.setSelection(baseHash || null, headHash || null);
|
||||||
}
|
}
|
||||||
|
updateButtonLinks();
|
||||||
};
|
};
|
||||||
|
|
||||||
baseSelect.addEventListener('change', sync);
|
baseSelect.addEventListener('change', sync);
|
||||||
headSelect.addEventListener('change', sync);
|
headSelect.addEventListener('change', sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateButtonLinks() {
|
||||||
|
const base = document.getElementById('select-base').value;
|
||||||
|
const head = document.getElementById('select-head').value;
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
if (base) params.set('base', base);
|
||||||
|
if (head) params.set('head', head);
|
||||||
|
const qs = params.toString();
|
||||||
|
const suffix = qs ? '?' + qs : '';
|
||||||
|
document.getElementById('btn-generate').href = `/repo/${repoId}/generate${suffix}`;
|
||||||
|
document.getElementById('btn-review').href = `/repo/${repoId}/review${suffix}`;
|
||||||
|
}
|
||||||
|
|
||||||
function showTab(tab) {
|
function showTab(tab) {
|
||||||
document.getElementById('panel-graph').classList.toggle('hidden', tab !== 'graph');
|
document.getElementById('panel-graph').classList.toggle('hidden', tab !== 'graph');
|
||||||
document.getElementById('panel-diff').classList.toggle('hidden', tab !== 'diff');
|
document.getElementById('panel-diff').classList.toggle('hidden', tab !== 'diff');
|
||||||
|
|||||||
Reference in New Issue
Block a user