Conversation
|
📝 WalkthroughWalkthroughThe changes update a dialog component to centralize and unify close-related logic, add navigation with error handling, and prevent accidental tab or window closure while the dialog is open. Separately, the logic for determining if credits are enabled for API keys is modified to consider all non-null values as enabled. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Dialog
participant Router
participant Toast
User->>Dialog: Clicks close/create-another/go-to-details
Dialog->>Dialog: handleCloseAttempt(action)
Dialog->>User: Shows confirmation popover
User->>Dialog: Confirms close
Dialog->>Dialog: handleConfirmClose()
alt action is "create-another"
Dialog->>Dialog: Calls onCreateAnother
else action is "go-to-details"
Dialog->>Router: Navigates to key details
alt Navigation error
Router->>Toast: Show error
end
else action is "close"
Dialog->>Dialog: Closes dialog
end
Note over Dialog: Dialog prevents accidental unload while open
Suggested labels
Suggested reviewers
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Thank you for following the naming conventions for pull request titles! 🙏 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx (1)
79-82: Consider early return after error logging.When
pendingActionis null, the function logs an error but continues execution. Consider adding an early return to prevent potential issues.if (!pendingAction) { console.error("No pending action when confirming close"); + setIsConfirmOpen(false); + setPendingAction(null); return; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx(5 hunks)apps/dashboard/lib/trpc/routers/api/keys/query-api-keys/get-all-keys.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: Test Packages / Test ./internal/id
- GitHub Check: Test Packages / Test ./packages/cache
- GitHub Check: Test Packages / Test ./internal/clickhouse
- GitHub Check: Test Packages / Test ./packages/hono
- GitHub Check: Test Packages / Test ./internal/billing
- GitHub Check: autofix
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
apps/dashboard/lib/trpc/routers/api/keys/query-api-keys/get-all-keys.ts (1)
248-249: LGTM! Improved credit status logic.The change from checking truthy values to checking for non-null properly distinguishes between keys without credit configuration (null) and keys with zero remaining credits. This provides more accurate credit status representation in the API response.
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx (2)
37-52: Good UX improvement with the beforeunload handler.The addition of the
beforeunloadevent listener prevents users from accidentally losing the key secret by closing the tab/window. This is a thoughtful enhancement since the key won't be shown again.
73-126: Well-structured centralized close handling.The refactored close handling with
handleCloseAttemptandhandleConfirmCloseprovides:
- Clear separation of concerns between intent and execution
- Proper error handling for missing keyspaceId
- Helpful error messages with support links
- Consistent state management
The implementation is clean and maintainable.
|
why did we go from the custom alert dialog to a browser alert? |
Custom alert still exists. I just added some extra protection against unwanted close tabs, Like |
|
I see, nice |
What does this PR do?
Fixes # (issue)
If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists
Type of change
How should this be tested?
remaining_credit=0case on key details page. On prod it says Disabled when credit is 0, but it should Enabled and should be disabled only if itsnullFixed version:

Prod:

Checklist
Required
pnpm buildpnpm fmtconsole.logsgit pull origin mainAppreciated
This is how it looks when you try to close the tab on key success dialog
