mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-07-18 07:28:47 +00:00
Followup to https://codeberg.org/forgejo/forgejo/pulls/8859, https://codeberg.org/forgejo/forgejo/pulls/9636. Convert the create branch and rename branch modals in the branch list to native dialogs and convert the create branch and create tag in the commit view to native dialogs. The dialogs in the commit view have been simplified and no longer uses javascript to construct the data in the dialog (thus would be eligible for nojs modals). The dialogs have footer styled actions. The rename branch modal now has a 'branch name' label to indicate the field is required. E2E testing is added. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9760 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
35 lines
1.6 KiB
TypeScript
35 lines
1.6 KiB
TypeScript
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
import {toggleElem} from '../utils/dom.js';
|
|
import {showModal} from '../modules/modal.ts';
|
|
|
|
export function initRepoBranchButton() {
|
|
const createBranchModal = document.querySelector('#create-branch-modal');
|
|
for (const el of document.querySelectorAll('.show-create-branch-modal')) {
|
|
el.addEventListener('click', () => {
|
|
const createBranchModalForm = createBranchModal.querySelector('form');
|
|
const branchFromName = el.getAttribute('data-branch-from');
|
|
|
|
createBranchModalForm.action = createBranchModalForm.getAttribute('data-base-action') + encodeURIComponent(branchFromName);
|
|
createBranchModal.querySelector('#modal-create-branch-from-span').textContent = branchFromName;
|
|
|
|
showModal('create-branch-modal', undefined);
|
|
});
|
|
}
|
|
|
|
const renameBranchModel = document.querySelector('#rename-branch-modal');
|
|
for (const el of document.querySelectorAll('.show-rename-branch-modal')) {
|
|
el.addEventListener('click', () => {
|
|
const oldBranchName = el.getAttribute('data-old-branch-name');
|
|
(renameBranchModel.querySelector('input[name="from"]') as HTMLInputElement).value = oldBranchName;
|
|
|
|
const branchToEl = renameBranchModel.querySelector('.label-branch-from');
|
|
branchToEl.textContent = branchToEl.getAttribute('data-locale').replace('%s', oldBranchName);
|
|
|
|
toggleElem(renameBranchModel.querySelector('.default-branch-warning'), el.getAttribute('data-is-default-branch') === 'true');
|
|
|
|
showModal('rename-branch-modal', undefined);
|
|
});
|
|
}
|
|
}
|