pull/34714/head
kerwin612 2025-06-13 19:13:49 +08:00
parent 780c7e1d95
commit b3a0ec49c2
5 changed files with 4 additions and 36 deletions

View File

@ -228,5 +228,5 @@ func ForkPost(ctx *context.Context) {
} }
log.Trace("Repository forked[%d]: %s/%s", forkRepo.ID, ctxUser.Name, repo.Name) log.Trace("Repository forked[%d]: %s/%s", forkRepo.ID, ctxUser.Name, repo.Name)
ctx.Redirect(ctxUser.HomeLink() + "/" + url.PathEscape(repo.Name)) ctx.JSONRedirect(ctxUser.HomeLink() + "/" + url.PathEscape(repo.Name))
} }

View File

@ -6,7 +6,7 @@
</h3> </h3>
<div class="ui attached segment"> <div class="ui attached segment">
{{template "base/alert" .}} {{template "base/alert" .}}
<form class="ui form left-right-form" action="{{.Link}}" method="post" data-prevent-duplicate> <form class="ui form form-fetch-action left-right-form" action="{{.Link}}" method="post">
{{.CsrfTokenHtml}} {{.CsrfTokenHtml}}
<div class="inline required field {{if .Err_Owner}}error{{end}}"> <div class="inline required field {{if .Err_Owner}}error{{end}}">
<label>{{ctx.Locale.Tr "repo.owner"}}</label> <label>{{ctx.Locale.Tr "repo.owner"}}</label>
@ -75,7 +75,7 @@
<div class="inline field"> <div class="inline field">
<label></label> <label></label>
<button class="ui primary button{{if not .CanForkRepoInNewOwner}} disabled{{end}}" type="submit"> <button class="ui primary button{{if not .CanForkRepoInNewOwner}} disabled{{end}}">
{{ctx.Locale.Tr "repo.fork_repo"}} {{ctx.Locale.Tr "repo.fork_repo"}}
</button> </button>
</div> </div>

View File

@ -51,7 +51,7 @@ func testRepoFork(t *testing.T, session *TestSession, ownerName, repoName, forkO
"repo_name": forkRepoName, "repo_name": forkRepoName,
"fork_single_branch": forkBranch, "fork_single_branch": forkBranch,
}) })
session.MakeRequest(t, req, http.StatusSeeOther) session.MakeRequest(t, req, http.StatusOK)
// Step4: check the existence of the forked repo // Step4: check the existence of the forked repo
req = NewRequestf(t, "GET", "/%s/%s", forkOwnerName, forkRepoName) req = NewRequestf(t, "GET", "/%s/%s", forkOwnerName, forkRepoName)

View File

@ -65,7 +65,6 @@ import {initGlobalButtonClickOnEnter, initGlobalButtons, initGlobalDeleteButton}
import {initGlobalComboMarkdownEditor, initGlobalEnterQuickSubmit, initGlobalFormDirtyLeaveConfirm} from './features/common-form.ts'; import {initGlobalComboMarkdownEditor, initGlobalEnterQuickSubmit, initGlobalFormDirtyLeaveConfirm} from './features/common-form.ts';
import {callInitFunctions} from './modules/init.ts'; import {callInitFunctions} from './modules/init.ts';
import {initRepoViewFileTree} from './features/repo-view-file-tree.ts'; import {initRepoViewFileTree} from './features/repo-view-file-tree.ts';
import {initFormSubmitHandlers} from './modules/form.ts';
initGiteaFomantic(); initGiteaFomantic();
initSubmitEventPolyfill(); initSubmitEventPolyfill();
@ -86,7 +85,6 @@ onDomReady(() => {
initGlobalComboMarkdownEditor, initGlobalComboMarkdownEditor,
initGlobalDeleteButton, initGlobalDeleteButton,
initGlobalInput, initGlobalInput,
initFormSubmitHandlers,
initCommonOrganization, initCommonOrganization,
initCommonIssueListQuickGoto, initCommonIssueListQuickGoto,

View File

@ -1,30 +0,0 @@
/**
* Form handling utilities
*/
import {addDelegatedEventListener} from '../utils/dom.ts';
/**
* Prevent duplicate form submission
* @param form The form element
* @param submitter The submit button element
*/
function preventDuplicateSubmit(form: HTMLFormElement, submitter: HTMLElement) {
form.addEventListener('submit', () => {
submitter.classList.add('disabled');
submitter.setAttribute('disabled', 'disabled');
});
}
/**
* Initialize form submit handlers
*/
export function initFormSubmitHandlers() {
// Add delegated event listener for forms with data-prevent-duplicate attribute
addDelegatedEventListener(document, 'submit', 'form[data-prevent-duplicate]', (form: HTMLFormElement) => {
const submitter = form.querySelector<HTMLElement>('button[type="submit"]');
if (submitter) {
preventDuplicateSubmit(form, submitter);
}
});
}