-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(local-explorer-ui): Add 404 & 500 error components #13158
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
0ef2c03
Added 404 & 500 error components to all resources
NuroDev 68040bf
Minor workflow linting fixes
NuroDev 80a36b2
Added changeset
NuroDev 5d31d86
Renamed `RouteError` to `ResourceNotFound`
NuroDev f2a970e
Merge branch 'main' into NuroDev/local-explorer-not-found
NuroDev f94611c
Merge branch 'main' into NuroDev/local-explorer-not-found
NuroDev f485ad0
Moved not found component to shared file
NuroDev 469a326
Merge branch 'main' into NuroDev/local-explorer-not-found
NuroDev 775a7ea
Removed unused imports from app root
NuroDev ec4ccfc
Improved resource error message handling
NuroDev 9de75b0
Minor `ResourceNotFound` fixes
NuroDev f939b3d
Overhauled id routes data fetching to correctly redirect not found ro…
NuroDev 8b1a229
Renamed `ResourceNotFound` to `ResourceError`
NuroDev c6a879b
Merge branch 'main' into NuroDev/local-explorer-not-found
NuroDev ccd365f
Updated changeset description
NuroDev d6f0a10
Fixed DO $className not found handling
NuroDev ed18a45
Merge branch 'main' into NuroDev/local-explorer-not-found
NuroDev 3316ac1
Fixed error details mapping
NuroDev ff6b02e
Minor code formatting
NuroDev 6e4751d
Merge branch 'main' into NuroDev/local-explorer-not-found
NuroDev f03d1fe
Merge branch 'main' into NuroDev/local-explorer-not-found
NuroDev 0dec399
Fixed DO table column name
NuroDev 4a5f9c0
Merge branch 'main' into NuroDev/local-explorer-not-found
NuroDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| "@cloudflare/local-explorer-ui": patch | ||
| --- | ||
|
|
||
| Improves local explorer invalid route error handling. | ||
|
|
||
| Visiting a route either as a 404 or 500 error now has dedicated components to handle as such, rather than the generic TanStack error UI. | ||
|
|
||
| Additionally, it also fixes route loaders to correctly throw a 404 error if a resource is not found, rather than showing a generic error. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { Button } from "@cloudflare/kumo"; | ||
| import { Link, type NotFoundRouteProps } from "@tanstack/react-router"; | ||
|
|
||
| export function NotFound(_props: NotFoundRouteProps): JSX.Element { | ||
| return ( | ||
| <div className="text-text-secondary flex flex-1 flex-col items-center justify-center space-y-4 p-12 text-center"> | ||
| <h2 className="text-text text-3xl font-bold">Page not found</h2> | ||
|
|
||
| <p className="text-text-secondary text-sm font-light"> | ||
| The resource you're looking for doesn't exist or has been | ||
| removed. | ||
| </p> | ||
|
|
||
| <Link to="/"> | ||
| <Button variant="secondary">Go home</Button> | ||
| </Link> | ||
| </div> | ||
| ); | ||
| } |
29 changes: 29 additions & 0 deletions
29
packages/local-explorer-ui/src/components/ResourceError.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { Button } from "@cloudflare/kumo"; | ||
| import { WarningIcon } from "@phosphor-icons/react"; | ||
| import { Link, type ErrorComponentProps } from "@tanstack/react-router"; | ||
| import type { WorkersApiResponseCommonFailure } from "../api"; | ||
|
|
||
| const DEFAULT_ERROR_DESCRIPTION = | ||
| "An unknown error occured. Please report this issue to Cloudflare."; | ||
|
|
||
| export function ResourceError({ | ||
| error, | ||
| }: ErrorComponentProps<Error | WorkersApiResponseCommonFailure>): JSX.Element { | ||
| const details = | ||
| ("errors" in error ? error.errors?.[0]?.message : error.message) ?? | ||
| DEFAULT_ERROR_DESCRIPTION; | ||
|
|
||
| return ( | ||
| <div className="text-text-secondary flex flex-1 flex-col items-center justify-center space-y-4 p-12 text-center"> | ||
| <WarningIcon size={48} /> | ||
|
|
||
| <h2 className="text-text text-3xl font-bold">Something went wrong</h2> | ||
|
|
||
| <p className="text-text-secondary text-sm font-light">{details}</p> | ||
|
|
||
| <Link to="/"> | ||
| <Button variant="secondary">Go home</Button> | ||
| </Link> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| import { createFileRoute, Outlet } from "@tanstack/react-router"; | ||
| import { ResourceError } from "../../components/ResourceError"; | ||
|
|
||
| export const Route = createFileRoute("/r2/$bucketName")({ | ||
| component: () => <Outlet />, | ||
| errorComponent: ResourceError, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/local-explorer-ui/src/routes/workflows/$workflowName.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.