-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
/instances/:id looks up instance and redirects to project instance route
- Loading branch information
1 parent
cfda163
commit b1a6317
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,18 @@ | ||
import { redirect, type LoaderFunctionArgs } from 'react-router-dom' | ||
|
||
import { apiQueryClient } from '@oxide/api' | ||
|
||
import { trigger404 } from 'app/components/ErrorBoundary' | ||
import { pb } from 'app/util/path-builder' | ||
|
||
export async function instanceLookupLoader({ params }: LoaderFunctionArgs) { | ||
const instance = await apiQueryClient.fetchQuery('instanceView', { | ||
path: { instance: params.instance! }, | ||
}) | ||
if (!instance) throw trigger404 | ||
const project = await apiQueryClient.fetchQuery('projectView', { | ||
path: { project: instance.projectId }, | ||
}) | ||
if (!project) throw trigger404 | ||
return redirect(pb.instance({ project: project.name, instance: instance.name })) | ||
} |
This file contains 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