-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: revalidate /apis after creating new API #2183
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 WalkthroughWalkthroughThe pull request modifies the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
@geraldmaboshe is attempting to deploy a commit to the Unkey Team on Vercel. A member of the Team first needs to authorize it. |
Thank you for following the naming conventions for pull request titles! 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
apps/dashboard/app/(app)/apis/create-api-button.tsx (1)
35-39
: LGTM: Revalidation logic added to address the issue.The changes effectively address the PR objective by adding revalidation after creating a new API. This should ensure that the new API appears in the list without requiring a manual refresh.
Consider removing the empty line at line 39 for better code consistency:
async onSuccess(res) { toast.success("Your API has been created"); await revalidate("/apis") - router.push(`/apis/${res.id}`); },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- apps/dashboard/app/(app)/apis/create-api-button.tsx (2 hunks)
🔇 Additional comments (3)
apps/dashboard/app/(app)/apis/create-api-button.tsx (3)
2-2
: LGTM: New import for revalidation.The addition of the
revalidate
import is appropriate for addressing the issue of updating the API list in real-time after creating a new API.
35-41
: LGTM: Removal of redundant refresh call.The removal of
router.refresh()
is appropriate as it's been replaced by the more specificrevalidate("/apis")
call. This change streamlines the update process and avoids unnecessary refreshes.
Line range hint
1-99
: Summary: Changes effectively address the issue.The modifications to the
CreateApiButton
component successfully implement the required functionality to update the API list in real-time after creating a new API. The use ofrevalidate("/apis")
should resolve the issue across all browsers, including MacOS Safari.To ensure the changes work as expected, please run the following verification script:
This script will help confirm that the changes have been implemented correctly and that no unintended modifications were made.
✅ Verification successful
✅ Verification Successful
The changes in
CreateApiButton
have been correctly implemented:
- Imported and used the
revalidate
function from@/app/actions
.- Removed the
router.refresh()
method.- Ensured the
onSuccess
callback is nowasync
.All verification tests passed, confirming that the API list updates in real-time as intended.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of revalidate function and its usage # Test 1: Check if the revalidate function is imported and used correctly echo "Test 1: Checking revalidate import and usage" rg --type typescript 'import.*revalidate.*from.*@/app/actions' apps/dashboard/app/\(app\)/apis/create-api-button.tsx && rg --type typescript 'await revalidate\("/apis"\)' apps/dashboard/app/\(app\)/apis/create-api-button.tsx # Test 2: Verify that router.refresh() has been removed echo "Test 2: Verifying removal of router.refresh()" ! rg --type typescript 'router\.refresh\(\)' apps/dashboard/app/\(app\)/apis/create-api-button.tsx # Test 3: Check if the onSuccess callback is now async echo "Test 3: Checking if onSuccess is async" rg --type typescript 'async onSuccess\(res\)' apps/dashboard/app/\(app\)/apis/create-api-button.tsxLength of output: 711
Script:
#!/bin/bash # Description: Verify the implementation of revalidate function and its usage with corrected file types # Test 1: Check if the revalidate function is imported and used correctly echo "Test 1: Checking revalidate import and usage" rg --type tsx 'import.*revalidate.*from.*@/app/actions' apps/dashboard/app/\(app\)/apis/create-api-button.tsx && rg --type tsx 'await revalidate\("/apis"\)' apps/dashboard/app/\(app\)/apis/create-api-button.tsx # Test 2: Verify that router.refresh() has been removed echo "Test 2: Verifying removal of router.refresh()" ! rg --type tsx 'router\.refresh\(\)' apps/dashboard/app/\(app\)/apis/create-api-button.tsx # Test 3: Check if the onSuccess callback is now async echo "Test 3: Checking if onSuccess is async" rg --type tsx 'async onSuccess\(res\)' apps/dashboard/app/\(app\)/apis/create-api-button.tsxLength of output: 669
Script:
#!/bin/bash # Description: Verify the implementation of revalidate function and its usage without relying on file type # Test 1: Check if the revalidate function is imported and used correctly echo "Test 1: Checking revalidate import and usage" rg 'import.*revalidate.*from.*@/app/actions' apps/dashboard/app/\(app\)/apis/create-api-button.tsx && rg 'await revalidate\("/apis"\)' apps/dashboard/app/\(app\)/apis/create-api-button.tsx # Test 2: Verify that router.refresh() has been removed echo "Test 2: Verifying removal of router.refresh()" ! rg 'router\.refresh\(\)' apps/dashboard/app/\(app\)/apis/create-api-button.tsx # Test 3: Check if the onSuccess callback is now async echo "Test 3: Checking if onSuccess is async" rg 'async onSuccess\(res\)' apps/dashboard/app/\(app\)/apis/create-api-button.tsxLength of output: 745
Awarding geraldmaboshe: 50 points 🕹️ Well done! Check out your new contribution on oss.gg/geraldmaboshe |
* fix: revalidate /apis after creating new API key * fix: show success message after revalidate suceeds * fix: revalidate cache before routing
* feat/mobile-sidbar-sync-with-desktop * fix(billing): add missing subscription fields and audit logging to upgrade flow (#2179) * fix(billing): add missing subscription fields and audit logging to upgrade flow * fix context properties * refactor: query audit logs from planetscale (#2181) * refactor: query audit logs from planetscale * fix: sort logs * [autofix.ci] apply automated fixes * chore: remove csv export * Update apps/dashboard/app/(app)/audit/[bucket]/page.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fmt: add comma * ci: remove wrong lint command --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * chore: Unkey PDF Viewer template [SIDE QUEST] (#2191) * chore: Unkey PDF Viewer template * feat: add template --------- Co-authored-by: chronark <dev@chronark.com> * perf: add database indices (#2192) * fix: add header again * docs: Removing pnpm test:routes (#2184) * fix: revalidate /apis after creating new API (#2183) * fix: revalidate /apis after creating new API key * fix: show success message after revalidate suceeds * fix: revalidate cache before routing * chore(deps-dev): bump @types/react-dom from 18.2.25 to 18.3.0 (#2187) Bumps [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom) from 18.2.25 to 18.3.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-dom) --- updated-dependencies: - dependency-name: "@types/react-dom" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Refactor/workspace-navigation * ran fmt --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Meg Stepp <mcstepp@users.noreply.github.com> Co-authored-by: Andreas Thomas <dev@chronark.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Nazar Poshtarenko <32395926+unrenamed@users.noreply.github.com> Co-authored-by: Harsh Shrikant Bhat <90265455+harshsbhat@users.noreply.github.com> Co-authored-by: Gerald Maboshe <maboshegerald1@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* feat/mobile-sidbar-sync-with-desktop * fix(billing): add missing subscription fields and audit logging to upgrade flow (unkeyed#2179) * fix(billing): add missing subscription fields and audit logging to upgrade flow * fix context properties * refactor: query audit logs from planetscale (unkeyed#2181) * refactor: query audit logs from planetscale * fix: sort logs * [autofix.ci] apply automated fixes * chore: remove csv export * Update apps/dashboard/app/(app)/audit/[bucket]/page.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fmt: add comma * ci: remove wrong lint command --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * chore: Unkey PDF Viewer template [SIDE QUEST] (unkeyed#2191) * chore: Unkey PDF Viewer template * feat: add template --------- Co-authored-by: chronark <dev@chronark.com> * perf: add database indices (unkeyed#2192) * fix: add header again * docs: Removing pnpm test:routes (unkeyed#2184) * fix: revalidate /apis after creating new API (unkeyed#2183) * fix: revalidate /apis after creating new API key * fix: show success message after revalidate suceeds * fix: revalidate cache before routing * chore(deps-dev): bump @types/react-dom from 18.2.25 to 18.3.0 (unkeyed#2187) Bumps [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom) from 18.2.25 to 18.3.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-dom) --- updated-dependencies: - dependency-name: "@types/react-dom" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Refactor/workspace-navigation * ran fmt --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Meg Stepp <mcstepp@users.noreply.github.com> Co-authored-by: Andreas Thomas <dev@chronark.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Nazar Poshtarenko <32395926+unrenamed@users.noreply.github.com> Co-authored-by: Harsh Shrikant Bhat <90265455+harshsbhat@users.noreply.github.com> Co-authored-by: Gerald Maboshe <maboshegerald1@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Add default bytes and prefix * adding bytes and prefix columns in harness * fmt * Await * Resolved changes * typo * Capital and Extra bracket * [autofix.ci] apply automated fixes * feat: mobile-sidbar-sync-with-desktop (#2180) * feat/mobile-sidbar-sync-with-desktop * fix(billing): add missing subscription fields and audit logging to upgrade flow (#2179) * fix(billing): add missing subscription fields and audit logging to upgrade flow * fix context properties * refactor: query audit logs from planetscale (#2181) * refactor: query audit logs from planetscale * fix: sort logs * [autofix.ci] apply automated fixes * chore: remove csv export * Update apps/dashboard/app/(app)/audit/[bucket]/page.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fmt: add comma * ci: remove wrong lint command --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * chore: Unkey PDF Viewer template [SIDE QUEST] (#2191) * chore: Unkey PDF Viewer template * feat: add template --------- Co-authored-by: chronark <dev@chronark.com> * perf: add database indices (#2192) * fix: add header again * docs: Removing pnpm test:routes (#2184) * fix: revalidate /apis after creating new API (#2183) * fix: revalidate /apis after creating new API key * fix: show success message after revalidate suceeds * fix: revalidate cache before routing * chore(deps-dev): bump @types/react-dom from 18.2.25 to 18.3.0 (#2187) Bumps [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom) from 18.2.25 to 18.3.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-dom) --- updated-dependencies: - dependency-name: "@types/react-dom" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Refactor/workspace-navigation * ran fmt --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Meg Stepp <mcstepp@users.noreply.github.com> Co-authored-by: Andreas Thomas <dev@chronark.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Nazar Poshtarenko <32395926+unrenamed@users.noreply.github.com> Co-authored-by: Harsh Shrikant Bhat <90265455+harshsbhat@users.noreply.github.com> Co-authored-by: Gerald Maboshe <maboshegerald1@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix: update go sdk code examples to the current sdk version (#2200) * fix: update go sdk code examples to the current sdk version * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Andreas Thomas <dev@chronark.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Akshay <100031493+AkshayBandi027@users.noreply.github.com> Co-authored-by: Meg Stepp <mcstepp@users.noreply.github.com> Co-authored-by: Andreas Thomas <dev@chronark.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Nazar Poshtarenko <32395926+unrenamed@users.noreply.github.com> Co-authored-by: Gerald Maboshe <maboshegerald1@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
What does this PR do?
Fixes #2138
This PR addresses the issue where newly created APIs were not
immediately visible in the API root keys list.
By calling revalidate("/apis") after successful key creation, we ensure
that the list is updated including on MacOS Safari.
Type of change
How should this be tested?
Checklist
Required
pnpm build
pnpm fmt
console.logs
git pull origin main
Appreciated
Screen.Recording.2024-10-04.at.6.57.19.PM.mov
Summary by CodeRabbit
New Features
Create API
button to refresh the API list upon successful creation of a new API.Bug Fixes