Skip to content

Commit

Permalink
feat: update header with link to catalog-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
hegeaal committed Nov 3, 2023
1 parent c561647 commit 4dd9b8c
Show file tree
Hide file tree
Showing 6 changed files with 258 additions and 222 deletions.
3 changes: 2 additions & 1 deletion config.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ window.env = {
CATALOG_COMMENTS_SERVICE_HOST: '$CATALOG_COMMENTS_SERVICE_HOST',
CONCEPT_CATALOG_FRONTEND_BASE_URI: '$CONCEPT_CATALOG_FRONTEND_BASE_URI',
CATALOG_ADMIN_SERVICE_BASE_URI: '$CATALOG_ADMIN_SERVICE_BASE_URI',
CATALOG_ADMIN_BASE_URI: '$CATALOG_ADMIN_BASE_URI',
FDK_PORTAL_BASE_URI: '$FDK_PORTAL_BASE_URI',
USE_DEMO_LOGO: '$USE_DEMO_LOGO'
USE_DEMO_LOGO: '$USE_DEMO_LOGO',
};
378 changes: 189 additions & 189 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@fellesdatakatalog/button": "^0.2.10",
"@fellesdatakatalog/external-footer": "^0.3.0",
"@fellesdatakatalog/icons": "^0.8.4",
"@fellesdatakatalog/internal-header": "^0.5.11",
"@fellesdatakatalog/internal-header": "^0.8.0",
"@fellesdatakatalog/link": "^0.2.15",
"@fellesdatakatalog/theme": "^0.5.4",
"@reduxjs/toolkit": "^1.9.7",
Expand Down
54 changes: 23 additions & 31 deletions src/app/App.tsx
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>
);
};
41 changes: 41 additions & 0 deletions src/components/header/index.tsx
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>
);
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const env = (window as any).env || {
// 'https://begrepskatalog.staging.fellesdatakatalog.digdir.no';
// env.CATALOG_ADMIN_SERVICE_BASE_URI =
// 'https://catalog-admin-service.staging.fellesdatakatalog.digdir.no';
// env.CATALOG_ADMIN_BASE_URI = 'https://catalog-admin.staging.fellesdatakatalog.digdir.no';
// env.USE_DEMO_LOGO = false;

const config = {
Expand Down Expand Up @@ -60,6 +61,7 @@ const config = {
},
conceptCatalogFrontendBaseUri: env.CONCEPT_CATALOG_FRONTEND_BASE_URI,
catalogAdminServiceBaseUri: env.CATALOG_ADMIN_SERVICE_BASE_URI,
catalogAdminBaseUri: env.CATALOG_ADMIN_BASE_URI,
useDemoLogo: env.USE_DEMO_LOGO
};

Expand Down

0 comments on commit 4dd9b8c

Please sign in to comment.