@@ -24,18 +24,12 @@ export const createPath = (
2424) => {
2525 const { detailsView = false , pathSegment = '' } = config ;
2626
27- const details = detailsView ? '/:resourceName' : '' ;
27+ const details = detailsView ? '/:resourceName? ' : '' ;
2828
2929 return `${ pathSegment } ${ details } ` ;
3030} ;
3131
32- const ColumnWrapper = ( {
33- defaultColumn = 'list' ,
34- list,
35- details,
36- create,
37- ...props
38- } ) => {
32+ const ColumnWrapper = ( { list, details, create, ...props } ) => {
3933 const [ layoutState , setLayoutColumn ] = useRecoilState ( columnLayoutState ) ;
4034 const [ searchParams ] = useSearchParams ( ) ;
4135 const layout = searchParams . get ( 'layout' ) ;
@@ -57,6 +51,8 @@ const ColumnWrapper = ({
5751 [ props . namespaceId , namespaceIdFromParams ] ,
5852 ) ;
5953
54+ const defaultColumn = resourceName ? 'details' : 'list' ;
55+
6056 const initialLayoutState = layout
6157 ? {
6258 layout : layout ,
@@ -210,22 +206,19 @@ export const createResourceRoutes = ({
210206 List = null ,
211207 Details = null ,
212208 Create = null ,
213- namespaced = true ,
214209 resourceType = '' ,
215210 resourceI18Key = '' ,
211+ customPath = null ,
216212 ...props
217213} ) => {
218214 const pathSegment = resourceType . toLowerCase ( ) ;
219215
220- const listPath = createPath ( { pathSegment } ) ;
221- const detailsPath = Details
222- ? createPath ( { pathSegment, detailsView : true } )
223- : '' ;
216+ const path = customPath || createPath ( { pathSegment, detailsView : true } ) ;
224217
225218 return (
226- < React . Fragment key = { listPath } >
219+ < React . Fragment key = { path } >
227220 < Route
228- path = { listPath }
221+ path = { path }
229222 exact
230223 element = {
231224 < Suspense fallback = { < Spinner /> } >
@@ -243,27 +236,6 @@ export const createResourceRoutes = ({
243236 </ Suspense >
244237 }
245238 />
246- { detailsPath ? (
247- < Route
248- path = { detailsPath }
249- element = {
250- < Suspense fallback = { < Spinner /> } >
251- < ColumnWrapper
252- resourceType = { resourceType }
253- resourceI18Key = { resourceI18Key }
254- hasDetailsView = { true }
255- list = { < List /> }
256- details = { < Details /> }
257- create = { Create ? < Create /> : null }
258- defaultColumn = "details"
259- { ...props }
260- >
261- < Details />
262- </ ColumnWrapper >
263- </ Suspense >
264- }
265- />
266- ) : null }
267239 </ React . Fragment >
268240 ) ;
269241} ;
0 commit comments