Skip to content

Add form-fetch-action to some forms, fix "fetch action" resp bug#37305

Merged
wxiaoguang merged 13 commits intogo-gitea:mainfrom
PineBale:patch-ts
Apr 20, 2026
Merged

Add form-fetch-action to some forms, fix "fetch action" resp bug#37305
wxiaoguang merged 13 commits intogo-gitea:mainfrom
PineBale:patch-ts

Conversation

@PineBale
Copy link
Copy Markdown
Contributor

@PineBale PineBale commented Apr 20, 2026

Some forms with required fields have a bug of being stuck on loading after clicking button without filling the fields. This pr adds some commits to address this issue.

Changes:

  • Add form-fetch-action to some forms
  • More Json response instead of RenderWithErrDeprecated

Affected forms:

  • Repository deletion
  • Repository wiki data deletion
  • Repository transfer
  • Converting mirror to regular
  • Converting fork to regular

Before:
1

After:

1.mp4

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 20, 2026
@PineBale PineBale changed the title Add form-fetch-action to some forms Add form-fetch-action to some forms Apr 20, 2026
const isRespJson = resp.headers.get('content-type')?.includes('application/json');
const respText = await resp.text();
const respJson = isRespJson ? JSON.parse(await resp.text()) : null;
const respJson = isRespJson ? JSON.parse(respText) : null;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:

Image

Copy link
Copy Markdown
Contributor

@wxiaoguang wxiaoguang Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, good catch, it is a bug (my bug ...)

Comment thread templates/repo/settings/options.tmpl
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 20, 2026
@wxiaoguang wxiaoguang changed the title Add form-fetch-action to some forms Add form-fetch-action to some forms, fix "fetch actions" resp text bug Apr 20, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a fetch-action UX bug where some repository settings forms could get stuck “loading” when required fields weren’t filled, and corrects a fetch-action error-handler response parsing bug. It does this by making the affected settings modals submit via form-fetch-action and ensuring the corresponding backend handlers return JSON errors/redirects that the fetch-action framework can consume.

Changes:

  • Fix double-consuming the Response body in handleFetchActionError by parsing JSON from the already-read respText.
  • Add form-fetch-action to repository settings forms (convert mirror/fork, transfer, delete repo, delete wiki).
  • Switch the relevant settings POST handlers to return JSONError* / JSONRedirect, and update integration tests + test JSON redirect parsing helper accordingly.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
web_src/js/features/common-fetch-action.ts Fixes fetch-action error JSON parsing by avoiding a second resp.text() read.
templates/repo/settings/options.tmpl Converts several settings modal forms to form-fetch-action submission.
routers/web/repo/setting/setting.go Updates affected repo settings actions to respond with JSON errors/redirects.
modules/test/utils.go Adjusts ParseJSONRedirect to detect presence of the redirect field via pointer type.
tests/integration/repo_visibility_test.go Updates assertions to match JSON redirect responses.
tests/integration/pull_create_test.go Updates delete-repo helper to expect JSON redirect response.
tests/integration/editor_test.go Updates convert-fork flow to expect JSON redirect response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/integration/pull_create_test.go
Comment thread tests/integration/editor_test.go
Comment thread tests/integration/repo_visibility_test.go
Comment thread tests/integration/repo_visibility_test.go
@wxiaoguang wxiaoguang changed the title Add form-fetch-action to some forms, fix "fetch actions" resp text bug Add form-fetch-action to some forms, fix "fetch action" resp bug Apr 20, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 20, 2026
@lunny lunny added this to the 1.27.0 milestone Apr 20, 2026
@wxiaoguang wxiaoguang enabled auto-merge (squash) April 20, 2026 17:44
@wxiaoguang wxiaoguang added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 20, 2026
@wxiaoguang wxiaoguang merged commit ca44b5f into go-gitea:main Apr 20, 2026
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 20, 2026
silverwind added a commit to silverwind/gitea that referenced this pull request Apr 20, 2026
…-lang

* origin/main:
  Update go js dependencies (go-gitea#37312)
  Update GitHub Actions to latest major versions (go-gitea#37313)
  Revert "Add WebKit to e2e test matrix (go-gitea#37298)" (go-gitea#37315)
  Add `form-fetch-action` to some forms, fix "fetch action" resp bug (go-gitea#37305)
  Move heatmap to first-party code (go-gitea#37262)
  Use updated yaml fields for snapcraft (go-gitea#37318)
  Remove dead code identified by `deadcode` tool (go-gitea#37271)
  Enable strict TypeScript, add `errorMessage` helper (go-gitea#37292)
  Fix vite manifest update masking build errors (go-gitea#37279)
  bump snapcraft base (go-gitea#37301)

# Conflicts:
#	web_src/js/modules/errors.ts
@PineBale PineBale deleted the patch-ts branch April 21, 2026 03:01
silverwind added a commit to 6543-forks/gitea that referenced this pull request Apr 21, 2026
…n-better

* origin/main: (645 commits)
  When the requested arch rpm is missing fall back to noarch (go-gitea#37236)
  Fix `relative-time` error and improve global error handler (go-gitea#37241)
  Enhance styling in actions page (go-gitea#37323)
  fix(oauth): Error on auth sources with spaces (go-gitea#37327)
  Fix actions concurrency groups cross-branch leak (go-gitea#37311)
  Fix bug when accessing user badges (go-gitea#37321)
  Fix AppFullLink (go-gitea#37325)
  Update go js dependencies (go-gitea#37312)
  Update GitHub Actions to latest major versions (go-gitea#37313)
  Revert "Add WebKit to e2e test matrix (go-gitea#37298)" (go-gitea#37315)
  Add `form-fetch-action` to some forms, fix "fetch action" resp bug (go-gitea#37305)
  Move heatmap to first-party code (go-gitea#37262)
  Use updated yaml fields for snapcraft (go-gitea#37318)
  Remove dead code identified by `deadcode` tool (go-gitea#37271)
  Enable strict TypeScript, add `errorMessage` helper (go-gitea#37292)
  Fix vite manifest update masking build errors (go-gitea#37279)
  bump snapcraft base (go-gitea#37301)
  Add WebKit to e2e test matrix (go-gitea#37298)
  Don't add useless labels which will bother changelog generation (go-gitea#37267)
  Fix Repository transferring page (go-gitea#37277)
  ...

# Conflicts:
#	options/locale/locale_en-US.ini
#	templates/package/content/debian.tmpl
zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 22, 2026
* main: (25 commits)
  Add URL to `Learn more about blocking a user` (go-gitea#37355)
  fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs (go-gitea#37288)
  Add event.schedule context for schedule actions task (go-gitea#37320)
  Fix typos (go-gitea#37346)
  Fix an issue where changing an organization’s visibility caused problems when users had forked its repositories. (go-gitea#37324)
  Fail vite build on rolldown warnings via NODE_ENV=test (go-gitea#37270)
  Use modern "git update-index --cacheinfo" syntax to support more file names (go-gitea#37338)
  Fix URL related escaping for oauth2 (go-gitea#37334)
  When the requested arch rpm is missing fall back to noarch (go-gitea#37236)
  Fix `relative-time` error and improve global error handler (go-gitea#37241)
  Enhance styling in actions page (go-gitea#37323)
  fix(oauth): Error on auth sources with spaces (go-gitea#37327)
  Fix actions concurrency groups cross-branch leak (go-gitea#37311)
  Fix bug when accessing user badges (go-gitea#37321)
  Fix AppFullLink (go-gitea#37325)
  Update go js dependencies (go-gitea#37312)
  Update GitHub Actions to latest major versions (go-gitea#37313)
  Revert "Add WebKit to e2e test matrix (go-gitea#37298)" (go-gitea#37315)
  Add `form-fetch-action` to some forms, fix "fetch action" resp bug (go-gitea#37305)
  Move heatmap to first-party code (go-gitea#37262)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants