[PR #1128] [MERGED] fix: API token deletion not reflected in cache until page reload #1411

Closed
opened 2026-02-26 19:33:08 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/documenso/documenso/pull/1128
Author: @cchirag
Created: 4/29/2024
Status: Merged
Merged: 7/24/2024
Merged by: @Mythie

Base: mainHead: fix/issue-1011-api-token-deletion


📝 Commits (6)

  • 0934065 fix(client): fixed issue number 1011 where the token was visible even after deletion
  • e373664 Merge branch 'main' into fix/issue-1011-api-token-deletion
  • 0a06198 fix: simplify implementation
  • f443d87 fix: update teams to support changes
  • 52b09b0 Merge branch 'main' into fix/issue-1011-api-token-deletion
  • 3d3c2ae fix: loosen form token type, revert team token changes

📊 Changes

3 files changed (+53 additions, -28 deletions)

View changed files

📝 apps/web/src/app/(dashboard)/settings/tokens/page.tsx (+1 -1)
📝 apps/web/src/app/(teams)/t/[teamUrl]/settings/tokens/page.tsx (+2 -2)
📝 apps/web/src/components/forms/token.tsx (+50 -25)

📄 Description


name: Pull Request
about: Submit changes to the project for review and inclusion

Description

When a user creates an API token and deletes it immediately (without refreshing the page), the element that rendered the token (with the copy button) and the form that was used to create the token were not getting reset

Fixes Issue 1011

Changes Made

  • Moved the Form Component and the Listing Component (one with the delete button) to a common client side component.
  • Used Forward Ref on the Form Component to expose the form reset functionality to the Parent Component (newly created one). This kept the form's declaration and implementation within the form component while exposing only the reset functionality using useImperativeHandle hook.
  • Passed a ref to the Form Component from the newly created Parent Component. Declared a handleOnDelete function and it is called after the delete mutation is successful. The handleOnDelete function calls the form reset function.

Testing Performed

  • Tested Create Token and Delete Token and the results were as expected.
  • Tested on Chrome

Checklist

  • I have tested these changes locally and they work as expected.
  • I have followed the project's coding style guidelines.

Additional Notes

As I have noticed, this is the first time useImperativeHandle hook is being used in the project. Is there any reason it is deliberately avoided or were there no cases where it was needed?

Summary by CodeRabbit

  • New Features

    • Introduced a streamlined ApiTokenFormAndList component for managing API tokens, enhancing the user interface for token creation and deletion.
    • Updated ApiTokenForm to allow parent components to reset the form state, improving control and usability.
  • Bug Fixes

    • Improved error handling and user feedback in the ApiTokenForm.
  • Refactor

    • Cleaned up and consolidated rendering logic in the ApiTokensPage for better maintainability and readability.
    • Enhanced the organization of class names in the MarketingLayout for improved code readability.
  • Style

    • Minor style adjustments made to adhere to coding standards.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/documenso/documenso/pull/1128 **Author:** [@cchirag](https://github.com/cchirag) **Created:** 4/29/2024 **Status:** ✅ Merged **Merged:** 7/24/2024 **Merged by:** [@Mythie](https://github.com/Mythie) **Base:** `main` ← **Head:** `fix/issue-1011-api-token-deletion` --- ### 📝 Commits (6) - [`0934065`](https://github.com/documenso/documenso/commit/0934065c901e172a75b69b121d5116acd9ff3205) fix(client): fixed issue number 1011 where the token was visible even after deletion - [`e373664`](https://github.com/documenso/documenso/commit/e37366491ff6f97e6143a82e34026468c542e89f) Merge branch 'main' into fix/issue-1011-api-token-deletion - [`0a06198`](https://github.com/documenso/documenso/commit/0a06198932a2b5a1323fa94983e8a7c7d12d0daa) fix: simplify implementation - [`f443d87`](https://github.com/documenso/documenso/commit/f443d8771a81778d0f9e6b2049db210b82dc6de8) fix: update teams to support changes - [`52b09b0`](https://github.com/documenso/documenso/commit/52b09b0eb27b4db717ea7b2938bbb4d9c2c2bf89) Merge branch 'main' into fix/issue-1011-api-token-deletion - [`3d3c2ae`](https://github.com/documenso/documenso/commit/3d3c2ae39ce5409e7da92bc833d9616cfa6c7568) fix: loosen form token type, revert team token changes ### 📊 Changes **3 files changed** (+53 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `apps/web/src/app/(dashboard)/settings/tokens/page.tsx` (+1 -1) 📝 `apps/web/src/app/(teams)/t/[teamUrl]/settings/tokens/page.tsx` (+2 -2) 📝 `apps/web/src/components/forms/token.tsx` (+50 -25) </details> ### 📄 Description --- name: Pull Request about: Submit changes to the project for review and inclusion --- ## Description When a user creates an API token and deletes it immediately (without refreshing the page), the element that rendered the token (with the copy button) and the form that was used to create the token were not getting reset ## Related Issue Fixes [Issue 1011](https://github.com/documenso/documenso/issues/1011) ## Changes Made - Moved the Form Component and the Listing Component (one with the delete button) to a common client side component. - Used Forward Ref on the Form Component to expose the form reset functionality to the Parent Component (newly created one). This kept the form's declaration and implementation within the form component while exposing only the reset functionality using useImperativeHandle hook. - Passed a ref to the Form Component from the newly created Parent Component. Declared a handleOnDelete function and it is called after the delete mutation is successful. The handleOnDelete function calls the form reset function. ## Testing Performed - Tested Create Token and Delete Token and the results were as expected. - Tested on Chrome ## Checklist <!--- Please check the boxes that apply to this pull request. --> <!--- You can add or remove items as needed. --> - [X] I have tested these changes locally and they work as expected. - [X] I have followed the project's coding style guidelines. ## Additional Notes As I have noticed, this is the first time useImperativeHandle hook is being used in the project. Is there any reason it is deliberately avoided or were there no cases where it was needed? <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a streamlined `ApiTokenFormAndList` component for managing API tokens, enhancing the user interface for token creation and deletion. - Updated `ApiTokenForm` to allow parent components to reset the form state, improving control and usability. - **Bug Fixes** - Improved error handling and user feedback in the `ApiTokenForm`. - **Refactor** - Cleaned up and consolidated rendering logic in the `ApiTokensPage` for better maintainability and readability. - Enhanced the organization of class names in the `MarketingLayout` for improved code readability. - **Style** - Minor style adjustments made to adhere to coding standards. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 19:33:08 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
starred/documenso#1411
No description provided.