Skip to content

Commit 8fed27b

Browse files
authored
Fix various problems (#34708)
* Fix #34707 * Fix dropdown filter handling * Fix #27014
1 parent 65986f4 commit 8fed27b

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

cmd/serv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func runServ(ctx context.Context, c *cli.Command) error {
212212
if git.DefaultFeatures().SupportProcReceive {
213213
// for AGit Flow
214214
if cmd == "ssh_info" {
215-
fmt.Print(`{"type":"gitea","version":1}`)
215+
fmt.Print(`{"type":"agit","version":1}`)
216216
return nil
217217
}
218218
}

routers/web/misc/misc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func SSHInfo(rw http.ResponseWriter, req *http.Request) {
2020
return
2121
}
2222
rw.Header().Set("content-type", "text/json;charset=UTF-8")
23-
_, err := rw.Write([]byte(`{"type":"gitea","version":1}`))
23+
_, err := rw.Write([]byte(`{"type":"agit","version":1}`))
2424
if err != nil {
2525
log.Error("fail to write result: err: %v", err)
2626
rw.WriteHeader(http.StatusInternalServerError)

web_src/fomantic/build/components/dropdown.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ $.fn.dropdown = function(parameters) {
525525
return true;
526526
}
527527
if(settings.onShow.call(element) !== false) {
528+
settings.onAfterFiltered.call(element); // GITEA-PATCH: callback to correctly handle the filtered items
528529
module.animate.show(function() {
529530
if( module.can.click() ) {
530531
module.bind.intent();

web_src/js/features/common-fetch-action.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ async function fetchActionDoRequest(actionElem: HTMLElement, url: string, opt: R
5656
actionElem.classList.remove('is-loading', 'loading-icon-2px');
5757
}
5858

59-
async function formFetchAction(formEl: HTMLFormElement, e: SubmitEvent) {
59+
async function onFormFetchActionSubmit(formEl: HTMLFormElement, e: SubmitEvent) {
6060
e.preventDefault();
61+
await submitFormFetchAction(formEl, submitEventSubmitter(e));
62+
}
63+
64+
export async function submitFormFetchAction(formEl: HTMLFormElement, formSubmitter?: HTMLElement) {
6165
if (formEl.classList.contains('is-loading')) return;
6266

6367
formEl.classList.add('is-loading');
@@ -68,7 +72,6 @@ async function formFetchAction(formEl: HTMLFormElement, e: SubmitEvent) {
6872
const formMethod = formEl.getAttribute('method') || 'get';
6973
const formActionUrl = formEl.getAttribute('action');
7074
const formData = new FormData(formEl);
71-
const formSubmitter = submitEventSubmitter(e);
7275
const [submitterName, submitterValue] = [formSubmitter?.getAttribute('name'), formSubmitter?.getAttribute('value')];
7376
if (submitterName) {
7477
formData.append(submitterName, submitterValue || '');
@@ -96,7 +99,7 @@ async function formFetchAction(formEl: HTMLFormElement, e: SubmitEvent) {
9699
await fetchActionDoRequest(formEl, reqUrl, reqOpt);
97100
}
98101

99-
async function linkAction(el: HTMLElement, e: Event) {
102+
async function onLinkActionClick(el: HTMLElement, e: Event) {
100103
// A "link-action" can post AJAX request to its "data-url"
101104
// Then the browser is redirected to: the "redirect" in response, or "data-redirect" attribute, or current URL by reloading.
102105
// If the "link-action" has "data-modal-confirm" attribute, a confirm modal dialog will be shown before taking action.
@@ -126,6 +129,6 @@ async function linkAction(el: HTMLElement, e: Event) {
126129
}
127130

128131
export function initGlobalFetchAction() {
129-
addDelegatedEventListener(document, 'submit', '.form-fetch-action', formFetchAction);
130-
addDelegatedEventListener(document, 'click', '.link-action', linkAction);
132+
addDelegatedEventListener(document, 'submit', '.form-fetch-action', onFormFetchActionSubmit);
133+
addDelegatedEventListener(document, 'click', '.link-action', onLinkActionClick);
131134
}

web_src/js/features/comp/LabelEdit.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {toggleElem} from '../../utils/dom.ts';
22
import {fomanticQuery} from '../../modules/fomantic/base.ts';
3+
import {submitFormFetchAction} from '../common-fetch-action.ts';
34

45
function nameHasScope(name: string): boolean {
56
return /.*[^/]\/[^/].*/.test(name);
@@ -70,7 +71,7 @@ export function initCompLabelEdit(pageSelector: string) {
7071
form.reportValidity();
7172
return false;
7273
}
73-
form.dispatchEvent(new Event('submit', {bubbles: true}));
74+
submitFormFetchAction(form);
7475
},
7576
}).modal('show');
7677
};

0 commit comments

Comments
 (0)