cd0a803341
Branch Policy Check / Verify merge target (pull_request) Has been cancelled
Universal: PR Check / Branch Policy (pull_request) Has been cancelled
Universal: PR Check / Validate PR (pull_request) Has been cancelled
Branch Cleanup / Delete merged branch (pull_request) Has been cancelled
PR RC Release / Build RC Release (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Remove the branch/tag selector from the issue sidebar and new issue
form. The Issue.Ref field was added 8 years ago and provides minimal
value — it only saves a branch name and optionally restricts which
branch's commits can auto-close the issue.
Removed:
- Branch selector template (branch_selector_field.tmpl)
- Sidebar and new-form includes
- Ref badge from issue lists
- POST /{index}/ref web route and UpdateIssueRef handler
- GetRefEndNamesAndURLs calls from list renderers
- JS handler for branch selector dropdown
Preserved:
- DB column (Issue.Ref) — still used by commit-close logic
- API response still includes ref for backward compatibility
Closes #307
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
92 lines
3.9 KiB
TypeScript
92 lines
3.9 KiB
TypeScript
import {POST} from '../modules/fetch.ts';
|
|
import {queryElems, toggleElem} from '../utils/dom.ts';
|
|
import {IssueSidebarComboList} from './repo-issue-sidebar-combolist.ts';
|
|
import {registerGlobalInitFunc} from '../modules/observer.ts';
|
|
import {parseIssuePageInfo} from '../utils.ts';
|
|
import {html} from '../utils/html.ts';
|
|
import {fomanticQuery} from '../modules/fomantic/base.ts';
|
|
import {showTemporaryTooltip} from '../modules/tippy.ts';
|
|
|
|
const {appSubUrl} = window.config;
|
|
|
|
function initRepoIssueDue(elSidebar: HTMLElement) {
|
|
const form = elSidebar.querySelector<HTMLFormElement>('.issue-due-form');
|
|
if (!form) return;
|
|
const deadline = form.querySelector<HTMLInputElement>('input[name=deadline]')!;
|
|
elSidebar.querySelector('.issue-due-edit')?.addEventListener('click', () => {
|
|
toggleElem(form);
|
|
});
|
|
elSidebar.querySelector('.issue-due-remove')?.addEventListener('click', () => {
|
|
deadline.value = '';
|
|
form.dispatchEvent(new Event('submit', {cancelable: true, bubbles: true}));
|
|
});
|
|
}
|
|
|
|
export function initRepoIssueSidebarDependency(elSidebar: HTMLElement) {
|
|
const elDropdown = elSidebar.querySelector('#new-dependency-drop-list');
|
|
if (!elDropdown) return;
|
|
|
|
const issuePageInfo = parseIssuePageInfo();
|
|
const crossRepoSearch = elDropdown.getAttribute('data-issue-cross-repo-search');
|
|
let issueSearchUrl = `${issuePageInfo.repoLink}/issues/search?q={query}&type=${issuePageInfo.issueDependencySearchType}`;
|
|
if (crossRepoSearch === 'true') {
|
|
issueSearchUrl = `${appSubUrl}/issues/search?q={query}&priority_repo_id=${issuePageInfo.repoId}&type=${issuePageInfo.issueDependencySearchType}`;
|
|
}
|
|
fomanticQuery(elDropdown).dropdown({
|
|
fullTextSearch: true,
|
|
apiSettings: {
|
|
cache: false,
|
|
rawResponse: true,
|
|
url: issueSearchUrl,
|
|
onResponse(response: any) {
|
|
const filteredResponse = {success: true, results: [] as Array<Record<string, any>>};
|
|
const currIssueId = elDropdown.getAttribute('data-issue-id');
|
|
// Parse the response from the api to work with our dropdown
|
|
for (const issue of response) {
|
|
// Don't list current issue in the dependency list.
|
|
if (String(issue.id) === currIssueId) continue;
|
|
filteredResponse.results.push({
|
|
value: issue.id,
|
|
name: html`<div class="gt-ellipsis">#${issue.number} ${issue.title}</div><div class="text small tw-break-anywhere">${issue.repository.full_name}</div>`,
|
|
});
|
|
}
|
|
return filteredResponse;
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
export function initRepoPullRequestAllowMaintainerEdit(elSidebar: HTMLElement) {
|
|
const wrapper = elSidebar.querySelector('#allow-edits-from-maintainers')!;
|
|
if (!wrapper) return;
|
|
const checkbox = wrapper.querySelector<HTMLInputElement>('input[type="checkbox"]')!;
|
|
checkbox.addEventListener('input', async () => {
|
|
const url = `${wrapper.getAttribute('data-url')}/set_allow_maintainer_edit`;
|
|
wrapper.classList.add('is-loading');
|
|
try {
|
|
const resp = await POST(url, {data: new URLSearchParams({allow_maintainer_edit: String(checkbox.checked)})});
|
|
if (!resp.ok) {
|
|
throw new Error('Failed to update maintainer edit permission');
|
|
}
|
|
const data = await resp.json();
|
|
checkbox.checked = data.allow_maintainer_edit;
|
|
} catch (error) {
|
|
checkbox.checked = !checkbox.checked;
|
|
console.error(error);
|
|
showTemporaryTooltip(wrapper, wrapper.getAttribute('data-prompt-error')!);
|
|
} finally {
|
|
wrapper.classList.remove('is-loading');
|
|
}
|
|
});
|
|
}
|
|
|
|
export function initRepoIssueSidebar() {
|
|
registerGlobalInitFunc('initRepoIssueSidebar', (elSidebar) => {
|
|
initRepoIssueDue(elSidebar);
|
|
initRepoIssueSidebarDependency(elSidebar);
|
|
initRepoPullRequestAllowMaintainerEdit(elSidebar);
|
|
// init the combo list: a dropdown for selecting items, and a list for showing selected items and related actions
|
|
queryElems(elSidebar, '.issue-sidebar-combo', (el) => new IssueSidebarComboList(el).init());
|
|
});
|
|
}
|