@@ -33,10 +33,9 @@ const RepoHome = () => {
3333 { key : 'concepts' , label : t ( 'concept.concepts' ) } ,
3434 { key : 'mappings' , label : t ( 'mapping.mappings' ) } ,
3535 ]
36- const TAB_KEYS = TABS . map ( tab => tab . key )
37- const findTab = ( ) => TAB_KEYS . includes ( params ?. tab || params ?. repoVersion ) ? params . tab || params . repoVersion : 'concepts'
38- const versionFromURL = ( TAB_KEYS . includes ( params ?. repoVersion ) ? '' : params . repoVersion ) || ''
39- const [ tab , setTab ] = React . useState ( findTab )
36+ const isCollection = params . repoType === 'collections'
37+
38+ const [ tabs , setTabs ] = React . useState ( isCollection ? [ ...TABS , { key : 'references' , label : t ( 'reference.references' ) } ] : [ ...TABS ] )
4039 const [ status , setStatus ] = React . useState ( false )
4140 const [ repo , setRepo ] = React . useState ( false )
4241 const [ owner , setOwner ] = React . useState ( false )
@@ -51,6 +50,11 @@ const RepoHome = () => {
5150 const [ releaseVersion , setReleaseVersion ] = React . useState ( false )
5251 const [ showSummary , setShowSummary ] = React . useState ( true )
5352
53+ const TAB_KEYS = tabs . map ( tab => tab . key )
54+ const findTab = ( ) => TAB_KEYS . includes ( params ?. tab || params ?. repoVersion ) ? params . tab || params . repoVersion : 'concepts'
55+ const versionFromURL = ( TAB_KEYS . includes ( params ?. repoVersion ) ? '' : params . repoVersion ) || ''
56+
57+ const [ tab , setTab ] = React . useState ( findTab )
5458 const { setAlert } = React . useContext ( OperationsContext ) ;
5559
5660 const getURL = ( ) => ( ( toParentURI ( location . pathname ) + '/' ) . replace ( '//' , '/' ) + versionFromURL + '/' ) . replace ( '//' , '/' )
@@ -65,6 +69,11 @@ const RepoHome = () => {
6569 setRepo ( _repo )
6670 fetchOwner ( )
6771 fetchRepoSummary ( )
72+ if ( isCollection )
73+ setTabs ( [ ...TABS , { key : 'references' , label : t ( 'reference.references' ) } ] )
74+ else
75+ setTabs ( [ ...TABS ] )
76+
6877 if ( isConceptURL || isMappingURL )
6978 setShowItem ( true )
7079 } )
@@ -101,6 +110,8 @@ const RepoHome = () => {
101110 setTab ( 'concepts' )
102111 if ( location . pathname . includes ( '/mappings' ) )
103112 setTab ( 'mappings' )
113+ if ( location . pathname . includes ( '/references' ) )
114+ setTab ( 'references' )
104115 }
105116 fetchRepo ( )
106117 fetchVersions ( )
@@ -112,7 +123,7 @@ const RepoHome = () => {
112123 let url = version . version_url
113124 if ( reload && version ?. version === 'HEAD' )
114125 url += 'HEAD/'
115- history . push ( url + tab )
126+ history . push ( url + ( tab || 'concepts' ) )
116127 }
117128
118129 const onTabChange = ( event , newTab ) => {
@@ -204,11 +215,14 @@ const RepoHome = () => {
204215
205216 const isConceptURL = tab === 'concepts'
206217 const isMappingURL = tab === 'mappings'
218+ const isReferenceURL = tab === 'references'
207219 const getConceptURLFromMainURL = ( ) => ( isConceptURL && params . resource ) ? getURL ( ) + 'concepts/' + params . resource + '/' : false
208220 const getMappingURLFromMainURL = ( ) => ( isMappingURL && params . resource ) ? getURL ( ) + 'mappings/' + params . resource + '/' : false
221+ const getReferenceURLFromMainURL = ( ) => ( isReferenceURL && params . resource ) ? getURL ( ) + 'references/' + params . resource + '/' : false
209222 const showConceptURL = ( ( showItem ?. concept_class || params . resource ) && isConceptURL ) ? showItem ?. version_url || showItem ?. url || getConceptURLFromMainURL ( ) : false
210223 const showMappingURL = ( ( showItem ?. map_type || params . resource ) && isMappingURL ) ? showItem ?. version_url || showItem ?. url || getMappingURLFromMainURL ( ) : false
211- const isSplitView = conceptForm || mappingForm || showConceptURL || showMappingURL || versionForm
224+ const showReferenceURL = ( ( showItem ?. expression || params . resource ) && isReferenceURL ) ? showItem ?. version_url || showItem ?. url || getReferenceURLFromMainURL ( ) : false
225+ const isSplitView = conceptForm || mappingForm || showConceptURL || showMappingURL || showReferenceURL || versionForm
212226
213227 const onVersionEditClick = ( ) => isVersion && setVersionForm ( true )
214228 const onReleaseVersionClick = ( ) => isVersion && setReleaseVersion ( true )
@@ -233,9 +247,9 @@ const RepoHome = () => {
233247 onReleaseVersionClick = { ( ) => onReleaseVersionClick ( ) }
234248 />
235249 < div className = 'padding-0 col-xs-12' style = { { width : isSplitView ? '100%' : ( showSummary ? 'calc(100% - 272px)' : 'calc(100% - 12px)' ) } } >
236- < CommonTabs TABS = { TABS } value = { tab } onChange = { onTabChange } />
250+ < CommonTabs TABS = { tabs } value = { tab } onChange = { onTabChange } />
237251 {
238- repo ?. id && [ 'concepts' , 'mappings' ] . includes ( tab ) &&
252+ repo ?. id && [ 'concepts' , 'mappings' , 'references' ] . includes ( tab ) &&
239253 < Search
240254 loading = { loading }
241255 summary = { repoSummary || repo ?. summary }
0 commit comments