Release v0.4.1 — Approve Button Fix for Private Repos #7

Merged
Mike Bros merged 2 commits from release/0.4.1 into main 2026-03-22 02:52:07 +00:00
Collaborator

Release v0.4.1 — Approve Button Fix for Private Repos

Changes

  • OP#2783: Fix approve button on private repos and allow admin self-approval

Summary

The one-click approve button added in v0.4.0 had two issues:

  1. Private repos: The button used fetch() to call the Forgejo API to check existing reviews. Forgejo 14's stateless CSRF protection doesn't accept session cookies for programmatic fetch requests, so on private repos the API returned 404 and the button was silently removed. Fixed by reading review state from the sidebar DOM instead.

  2. Self-approval blocked for admins: The button was unconditionally hidden when the logged-in user was the PR author. Now allows self-approval when the user has merge permission (the #pull-request-merge-form element exists).

  3. Simplified click handler: Removed the API fallback for getting the commit ID — uses window.config.pageData exclusively.

Checklist

  • All version tasks closed in Gravity PM
  • Version file matches Gravity PM version
  • Manually tested — template deployed and verified on live instance

References

Version: 0.4.1 — Approve Button Fix for Private Repos (Gravity PM ID: 187)
Release task: OP#2784

## Release v0.4.1 — Approve Button Fix for Private Repos ### Changes - OP#2783: Fix approve button on private repos and allow admin self-approval ### Summary The one-click approve button added in v0.4.0 had two issues: 1. **Private repos:** The button used `fetch()` to call the Forgejo API to check existing reviews. Forgejo 14's stateless CSRF protection doesn't accept session cookies for programmatic fetch requests, so on private repos the API returned 404 and the button was silently removed. Fixed by reading review state from the sidebar DOM instead. 2. **Self-approval blocked for admins:** The button was unconditionally hidden when the logged-in user was the PR author. Now allows self-approval when the user has merge permission (the `#pull-request-merge-form` element exists). 3. **Simplified click handler:** Removed the API fallback for getting the commit ID — uses `window.config.pageData` exclusively. ### Checklist - [x] All version tasks closed in Gravity PM - [x] Version file matches Gravity PM version - [x] Manually tested — template deployed and verified on live instance ### References Version: 0.4.1 — Approve Button Fix for Private Repos (Gravity PM ID: 187) Release task: OP#2784
Replace API-based review detection with DOM-based sidebar reading.
Forgejo 14's stateless CSRF blocks session cookies on fetch() API calls,
causing the button to be removed on private repos. Also allow users with
merge permission to approve their own PRs.

Closes OP#2783

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Refs OP#2784

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Mike Bros approved these changes 2026-03-22 02:52:01 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mike/neptune-forgejo!7
No description provided.