fix(ui): improve Git notes editing (#11365)

Closes #11355, namely:

1. bug: editing the note does not edit the orginal content, but the rendered content
    - https://codeberg.org/forgejo/forgejo/pulls/11365/commits/16368c4ccb7c5e4711599abe5a607d0a9da81f9b
    - edit raw notes instead of rendered notes
2. bug: editing existing note on single-commit PR page leads to 404 page because it sends a POST request to `/OWNER/REPO/pulls/ID/commits/COMMIT_HASH/notes`
    - https://codeberg.org/forgejo/forgejo/pulls/11365/commits/f036fc55db6b32975f6b0d78d0a7b0e34cd5e866
    - add new paths for the actions on pull request pages for `/OWNER/REPO/pulls/ID/commits/COMMIT_HASH/notes` and `/OWNER/REPO/pulls/ID/commits/COMMIT_HASH/notes/remove`
3. feat: both for adding and editing there is no `Cancel` button
    - https://codeberg.org/forgejo/forgejo/pulls/11365/commits/58d8c7cc872f34ddb092fe2c28d757580d16a320
    - moved both the `Cancel` and the `Save`/`Edit` button to the right for better consistency how, e.g., issue comments are edited/created.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11365
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Robert Wolff <mahlzahn@posteo.de>
Co-committed-by: Robert Wolff <mahlzahn@posteo.de>
This commit is contained in:
Robert Wolff 2026-03-10 23:49:18 +01:00 committed by Gusted
parent f1a08a7ab1
commit 296e6a284e
9 changed files with 204 additions and 46 deletions

View file

@ -28,18 +28,18 @@ export function initCommitStatuses() {
}
export function initCommitNotes() {
const notesEditButton = document.getElementById('commit-notes-edit-button');
if (notesEditButton !== null) {
notesEditButton.addEventListener('click', () => {
document.getElementById('commit-notes-display-area').classList.add('tw-hidden');
document.getElementById('commit-notes-edit-area').classList.remove('tw-hidden');
});
}
document.getElementById('commit-notes-edit-button')?.addEventListener('click', () => {
document.getElementById('commit-notes-display-area').classList.add('tw-hidden');
document.getElementById('commit-notes-edit-area').classList.remove('tw-hidden');
});
const notesAddButton = document.getElementById('commit-notes-add-button');
if (notesAddButton !== null) {
notesAddButton.addEventListener('click', () => {
document.getElementById('commit-notes-add-area').classList.remove('tw-hidden');
});
}
document.getElementById('commit-notes-add-button')?.addEventListener('click', () => {
document.getElementById('commit-notes-edit-area').classList.remove('tw-hidden');
});
document.getElementById('commit-notes-cancel-button')?.addEventListener('click', () => {
document.getElementById('commit-notes-edit-form').reset();
document.getElementById('commit-notes-display-area')?.classList.remove('tw-hidden');
document.getElementById('commit-notes-edit-area').classList.add('tw-hidden');
});
}