-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update header with link to catalog-admin
- Loading branch information
Showing
6 changed files
with
258 additions
and
222 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,40 +1,32 @@ | ||
import React from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; | ||
import { | ||
BrowserRouter as Router, | ||
Route, | ||
Switch | ||
} from 'react-router-dom'; | ||
import _ from 'lodash'; | ||
import Footer from '@fellesdatakatalog/external-footer'; | ||
import Header from '@fellesdatakatalog/internal-header'; | ||
import Link from '@fellesdatakatalog/link'; | ||
|
||
import { routeConfig } from './routeConfig'; | ||
import { Breadcrumbs } from '../components/breadcrumbs/breadcrumbs.component'; | ||
import { authService } from '../services/auth-service'; | ||
|
||
import { getConfig } from '../config'; | ||
import { store } from './redux/store'; | ||
import { Header } from '../components/header'; | ||
|
||
export const App: React.FC = () => { | ||
|
||
export const App: React.FC = () => ( | ||
<Provider store={store}> | ||
<Router> | ||
<Header | ||
homeUrl={getConfig().registrationHost} | ||
username={authService.getUser()?.name} | ||
onLogout={authService.logout} | ||
useDemoLogo={getConfig().useDemoLogo} | ||
> | ||
<Link href={`${getConfig().searchHost}/guidance`}>Registrere data</Link> | ||
<Link href={getConfig().adminGui.host}>Høste data</Link> | ||
<Link href={getConfig().searchHost} external> | ||
Søk i Felles datakatalog | ||
</Link> | ||
</Header> | ||
<Breadcrumbs /> | ||
<Switch> | ||
{routeConfig.map((route, i) => ( | ||
<Route key={`${i}-${_.get(route, 'path', '')}`} {...route} /> | ||
))} | ||
</Switch> | ||
<Footer /> | ||
</Router> | ||
</Provider> | ||
); | ||
return ( | ||
<Provider store={store}> | ||
<Router> | ||
<Header/> | ||
<Breadcrumbs /> | ||
<Switch> | ||
{routeConfig.map((route, i) => ( | ||
<Route key={`${i}-${_.get(route, 'path', '')}`} {...route} /> | ||
))} | ||
</Switch> | ||
<Footer /> | ||
</Router> | ||
</Provider> | ||
); | ||
}; |
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,41 @@ | ||
import React, { FC, HTMLAttributes } from 'react'; | ||
|
||
import HeaderBase from '@fellesdatakatalog/internal-header'; | ||
|
||
interface Props extends HTMLAttributes<HTMLInputElement> {} | ||
|
||
import Link from '@fellesdatakatalog/link'; | ||
import authService from '../../services/auth-service'; | ||
import { getConfig } from '../../config'; | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
const showManageConceptCatalogsUrl = () => { | ||
const resourceRoles = authService.getResourceRoles(); | ||
const location = useLocation(); | ||
const pathParts = location.pathname.split('/'); | ||
const currentCatalogId = pathParts ? pathParts[1] : undefined; | ||
|
||
return resourceRoles.some((role) => { | ||
const roleOrgNumber = role?.resourceId; | ||
return authService.hasOrganizationAdminPermission( | ||
currentCatalogId ? currentCatalogId : roleOrgNumber | ||
); | ||
}); | ||
}; | ||
|
||
export const Header: FC<Props> = () => ( | ||
<HeaderBase | ||
homeUrl={getConfig().registrationHost} | ||
username={authService.getUser()?.name} | ||
onLogout={authService.logout} | ||
useDemoLogo={getConfig().useDemoLogo} | ||
showManageConceptCatalogsUrl={showManageConceptCatalogsUrl()} | ||
manageConceptCatalogsUrl={getConfig().catalogAdminBaseUri} | ||
> | ||
<Link href={`${getConfig().searchHost}/guidance`}>Registrere data</Link> | ||
<Link href={getConfig().adminGui.host}>Høste data</Link> | ||
<Link href={getConfig().searchHost} external> | ||
Søk i Felles datakatalog | ||
</Link> | ||
</HeaderBase> | ||
); |
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