Skip to content

Commit 8c0e084

Browse files
committed
fix(greenhouse): retain org search param in the url
1 parent 2426c16 commit 8c0e084

3 files changed

Lines changed: 45 additions & 27 deletions

File tree

apps/greenhouse/src/components/nav/PluginNav.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ const PluginNav = () => {
6969
const { data: authData, loggedIn, login, logout } = useAuth()
7070

7171
const navigateToApp = (appId: string) => {
72-
navigate({ to: `/${appId}` })
72+
navigate({
73+
to: `/${appId}`,
74+
search: (prev: { org?: string }) => {
75+
const { org } = prev
76+
return { org } // preserve only the "org" search parameter when navigating
77+
},
78+
})
7379
}
7480

7581
return (

apps/greenhouse/src/routeTree.gen.ts

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,60 +8,60 @@
88
// You should NOT make any changes in this file as it will be overwritten.
99
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
1010

11-
import { Route as rootRouteImport } from "./routes/__root"
12-
import { Route as IndexRouteImport } from "./routes/index"
13-
import { Route as ExtensionIdSplatRouteImport } from "./routes/$extensionId.$"
11+
import { Route as rootRouteImport } from './routes/__root'
12+
import { Route as IndexRouteImport } from './routes/index'
13+
import { Route as ExtensionIdSplatRouteImport } from './routes/$extensionId.$'
1414

1515
const IndexRoute = IndexRouteImport.update({
16-
id: "/",
17-
path: "/",
16+
id: '/',
17+
path: '/',
1818
getParentRoute: () => rootRouteImport,
1919
} as any)
2020
const ExtensionIdSplatRoute = ExtensionIdSplatRouteImport.update({
21-
id: "/$extensionId/$",
22-
path: "/$extensionId/$",
21+
id: '/$extensionId/$',
22+
path: '/$extensionId/$',
2323
getParentRoute: () => rootRouteImport,
2424
} as any)
2525

2626
export interface FileRoutesByFullPath {
27-
"/": typeof IndexRoute
28-
"/$extensionId/$": typeof ExtensionIdSplatRoute
27+
'/': typeof IndexRoute
28+
'/$extensionId/$': typeof ExtensionIdSplatRoute
2929
}
3030
export interface FileRoutesByTo {
31-
"/": typeof IndexRoute
32-
"/$extensionId/$": typeof ExtensionIdSplatRoute
31+
'/': typeof IndexRoute
32+
'/$extensionId/$': typeof ExtensionIdSplatRoute
3333
}
3434
export interface FileRoutesById {
3535
__root__: typeof rootRouteImport
36-
"/": typeof IndexRoute
37-
"/$extensionId/$": typeof ExtensionIdSplatRoute
36+
'/': typeof IndexRoute
37+
'/$extensionId/$': typeof ExtensionIdSplatRoute
3838
}
3939
export interface FileRouteTypes {
4040
fileRoutesByFullPath: FileRoutesByFullPath
41-
fullPaths: "/" | "/$extensionId/$"
41+
fullPaths: '/' | '/$extensionId/$'
4242
fileRoutesByTo: FileRoutesByTo
43-
to: "/" | "/$extensionId/$"
44-
id: "__root__" | "/" | "/$extensionId/$"
43+
to: '/' | '/$extensionId/$'
44+
id: '__root__' | '/' | '/$extensionId/$'
4545
fileRoutesById: FileRoutesById
4646
}
4747
export interface RootRouteChildren {
4848
IndexRoute: typeof IndexRoute
4949
ExtensionIdSplatRoute: typeof ExtensionIdSplatRoute
5050
}
5151

52-
declare module "@tanstack/react-router" {
52+
declare module '@tanstack/react-router' {
5353
interface FileRoutesByPath {
54-
"/": {
55-
id: "/"
56-
path: "/"
57-
fullPath: "/"
54+
'/': {
55+
id: '/'
56+
path: '/'
57+
fullPath: '/'
5858
preLoaderRoute: typeof IndexRouteImport
5959
parentRoute: typeof rootRouteImport
6060
}
61-
"/$extensionId/$": {
62-
id: "/$extensionId/$"
63-
path: "/$extensionId/$"
64-
fullPath: "/$extensionId/$"
61+
'/$extensionId/$': {
62+
id: '/$extensionId/$'
63+
path: '/$extensionId/$'
64+
fullPath: '/$extensionId/$'
6565
preLoaderRoute: typeof ExtensionIdSplatRouteImport
6666
parentRoute: typeof rootRouteImport
6767
}
@@ -72,4 +72,6 @@ const rootRouteChildren: RootRouteChildren = {
7272
IndexRoute: IndexRoute,
7373
ExtensionIdSplatRoute: ExtensionIdSplatRoute,
7474
}
75-
export const routeTree = rootRouteImport._addFileChildren(rootRouteChildren)._addFileTypes<FileRouteTypes>()
75+
export const routeTree = rootRouteImport
76+
._addFileChildren(rootRouteChildren)
77+
._addFileTypes<FileRouteTypes>()

apps/greenhouse/src/routes/$extensionId.$.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@
55

66
import React from "react"
77
import { createFileRoute } from "@tanstack/react-router"
8+
import { z } from "zod"
89

910
import { usePlugin } from "../components/StoreProvider"
1011
import { useAuth } from "../components/AuthProvider"
1112
import Extension from "../components/Extension"
1213

14+
const searchSchema = z.object({
15+
/**
16+
* TODO: remove it when no longer needed
17+
* but we need to keep "org" search parameter due to it's significance in the shell app.
18+
*/
19+
org: z.string().optional(),
20+
})
21+
1322
export const Route = createFileRoute("/$extensionId/$")({
23+
validateSearch: searchSchema,
1424
component: RouteComponent,
1525
})
1626

0 commit comments

Comments
 (0)