diff --git a/packages/frontend/package.json b/packages/frontend/package.json
index acbb49c..6fec32b 100644
--- a/packages/frontend/package.json
+++ b/packages/frontend/package.json
@@ -26,7 +26,6 @@
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
"elite-feature-flags": "^1.0.0",
- "elite-configuration": "^1.0.0",
- "elite-routing": "^1.0.0"
+ "elite-configuration": "^1.0.0"
}
}
diff --git a/packages/frontend/src/components/App.tsx b/packages/frontend/src/components/App.tsx
index 4fa933c..a277b98 100644
--- a/packages/frontend/src/components/App.tsx
+++ b/packages/frontend/src/components/App.tsx
@@ -1,27 +1,25 @@
+import { getConfiguration } from 'elite-configuration';
+import { FeatureFlagsProvider } from 'elite-feature-flags';
+import { Configuration } from 'elite-types';
import * as React from 'react';
import { hot } from 'react-hot-loader';
-import { Route, Switch, Redirect } from 'react-router';
+import { Redirect, Route, Switch } from 'react-router';
import { Router } from 'react-router-dom';
import history from '../util/history';
-import { FeatureFlagsProvider } from 'elite-feature-flags';
-import { Configuration } from 'elite-types';
-import { getConfiguration } from 'elite-configuration';
-import { getAllRegisteredAppRoutes } from 'elite-routing';
-import { AppPaths, registerRoutes } from '../util/routes';
+import { AppPath, APP_ROUTES } from '../util/routes';
// Global bootstrap: install subsystems and load configuration
-registerRoutes();
const configuration: Configuration = getConfiguration();
export const AppComponent = () => (
- {getAllRegisteredAppRoutes().map((routeProps, index) => (
+ {APP_ROUTES.map((routeProps, index) => (
))}
{/* Error 404 Fallback */}
-
+
diff --git a/packages/frontend/src/components/pages/HomePage.tsx b/packages/frontend/src/components/pages/HomePage.tsx
index f3e3656..272989c 100644
--- a/packages/frontend/src/components/pages/HomePage.tsx
+++ b/packages/frontend/src/components/pages/HomePage.tsx
@@ -1,8 +1,8 @@
+import { Divider } from '@material-ui/core';
+import { FeatureFlag } from 'elite-feature-flags';
import * as React from 'react';
import { RouteComponentProps } from 'react-router';
import { LinkDirectory } from './support/LinkDirectory';
-import { Divider } from '@material-ui/core';
-import { FeatureFlag } from 'elite-feature-flags';
export interface HomePageProps extends RouteComponentProps {}
diff --git a/packages/frontend/src/components/pages/support/LinkDirectory.tsx b/packages/frontend/src/components/pages/support/LinkDirectory.tsx
index ec54a4f..84964f2 100644
--- a/packages/frontend/src/components/pages/support/LinkDirectory.tsx
+++ b/packages/frontend/src/components/pages/support/LinkDirectory.tsx
@@ -1,10 +1,10 @@
import * as React from 'react';
import { Link } from 'react-router-dom';
-import { getLinkForRoute, getDisplayNameForRoute, getAllRegisteredAppRoutes } from 'elite-routing';
+import { APP_ROUTES, getDisplayNameForRoute, getLinkForRoute } from '../../../util/routes';
export const LinkDirectory = () => (
- {getAllRegisteredAppRoutes().map((route, index) => (
+ {APP_ROUTES.map((route, index) => (
-
{getDisplayNameForRoute(route)}
diff --git a/packages/frontend/src/util/routes.tsx b/packages/frontend/src/util/routes.tsx
index da2b0b0..2428e6e 100644
--- a/packages/frontend/src/util/routes.tsx
+++ b/packages/frontend/src/util/routes.tsx
@@ -1,22 +1,105 @@
import * as React from 'react';
import { HomePage } from '../components/pages/HomePage';
import { LinkPage } from '../components/pages/LinkPage';
-import { registerAppRoute } from 'elite-routing';
+import { RouteProps } from 'react-router';
-export enum AppPaths {
+// If necessary, add support for: H.LocationDescriptor | ((location: H.Location) => H.LocationDescriptor);
+type LinkType = string;
+
+/**
+ * Each Approute can have a specific link (i.e., path with filled parameter placeholders),
+ * a display Name, i.e., text of the link and a nonoptional (!) path
+ *
+ * TODO: move to types package to be able to move app routes to their own
+ * individual packages
+ */
+export interface AppRouteProps extends RouteProps {
+ // Use this if the link target differs from the path specification,
+ // i.e., if the path url contains paramter specifications etc
+ readonly link?: LinkType;
+
+ // link text (Human readable!)
+ readonly displayName?: string;
+
+ // AppRoutes must have a path - deoptionalize this property
+ readonly path: AppPath;
+}
+
+/**
+ * All available paths in this app
+ */
+export enum AppPath {
HOME = '/home',
LINK = '/link',
+ ERROR = '/',
+}
+
+/**
+ * Route for the Home page of this app
+ *
+ * TODO: replace with imported version (except of path: property)
+ * once HomePage is moved to different package
+ */
+const HOME_ROUTE: AppRouteProps = {
+ path: AppPath.HOME,
+ displayName: 'Home',
+ render: props => ,
+};
+
+/**
+ * Route for the Link page of this app
+ *
+ * TODO: replace `with imported version (except of path: property
+ * once LinkPage is moved to different package)
+ */
+const LINK_ROUTE: AppRouteProps = {
+ path: AppPath.LINK,
+ displayName: 'Useful Links',
+ render: props => ,
+};
+
+export const APP_ROUTES: AppRouteProps[] = [HOME_ROUTE, LINK_ROUTE];
+
+/**
+ * Retrieves the url which other pages can use to link to a certain
+ * app path
+ *
+ * @param route
+ */
+export function getLinkForRoute(route: AppRouteProps): LinkType {
+ return route.link || route.path;
+}
+
+/**
+ * Retrieves the url which other pages can use to link to a certain
+ * app path
+ *
+ * @param path
+ */
+export function getLinkForPath(path: AppPath): LinkType {
+ const route = APP_ROUTES.find(route => route.path == path);
+ if (!route) return AppPath.ERROR;
+
+ return getLinkForRoute(route);
+}
+
+/**
+ * Retrieves the human readable link title/displayed name for
+ * a given route
+ *
+ * @param route
+ */
+export function getDisplayNameForRoute(route: AppRouteProps): string {
+ return route.displayName || getLinkForRoute(route);
}
-export function registerRoutes() {
- registerAppRoute({
- path: AppPaths.HOME,
- displayName: 'Home',
- render: props => ,
- });
- registerAppRoute({
- path: AppPaths.LINK,
- displayName: 'Useful Links',
- render: props => ,
- });
+/**
+ * Retrieves the human readable link title/displayed name for
+ * a given path
+ *
+ * @param path
+ */
+export function getDisplayNameForPath(path: AppPath): string {
+ const route = APP_ROUTES.find(route => route.path == path);
+ return route ? getDisplayNameForRoute(route) : 'Error';
}
diff --git a/packages/frontend/tsconfig.json b/packages/frontend/tsconfig.json
index 7b0a9ff..c4af582 100644
--- a/packages/frontend/tsconfig.json
+++ b/packages/frontend/tsconfig.json
@@ -13,9 +13,6 @@
{
"path": "../feature-flags"
},
- {
- "path": "../routing"
- },
{
"path": "../types"
}
diff --git a/packages/routing/package.json b/packages/routing/package.json
deleted file mode 100644
index 9f2e324..0000000
--- a/packages/routing/package.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "name": "elite-routing",
- "version": "1.0.0",
- "private": true,
- "publishConfig": {
- "access": "public"
- },
- "types": "dist/index.d.ts",
- "main": "dist/index.js",
- "scripts": {
- "clean": "rm -rf dist/ node_modules/ tsconfig.tsbuildinfo"
- },
- "devDependencies": {
- "@types/react": "^16.9.11",
- "@types/react-router": "^5.1.3",
- "elite-types": "^1.0.0"
- },
- "dependencies": {
- "react": "^16.12.0"
- }
-}
diff --git a/packages/routing/src/index.ts b/packages/routing/src/index.ts
deleted file mode 100644
index 161ba39..0000000
--- a/packages/routing/src/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './routing';
diff --git a/packages/routing/src/routing.tsx b/packages/routing/src/routing.tsx
deleted file mode 100644
index 3b125f3..0000000
--- a/packages/routing/src/routing.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import * as React from 'react';
-import { RouteProps } from 'react-router';
-
-// If necessary, add support for: H.LocationDescriptor | ((location: H.Location) => H.LocationDescriptor);
-type LinkType = string;
-
-/**
- * Each Approute can have a specific link (i.e., path with filled parameter placeholders),
- * a display Name, i.e., text of the link and a nonoptional (!) path
- */
-export interface AppRouteProps extends RouteProps {
- // Use this if the link target differs from the path specification,
- // i.e., if the path url contains paramter specifications etc
- readonly link?: LinkType;
-
- // link text (Human readable!)
- readonly displayName?: string;
-
- // AppRoutes must have a path - deoptionalize this property
- readonly path: string;
-}
-
-/**
- * Container for all registered app routes
- */
-const appRoutes: { [path: string]: AppRouteProps } = {};
-
-/**
- * Function to retrieve all currently registered app routes
- */
-export function getAllRegisteredAppRoutes() {
- return Object.values(appRoutes);
-}
-
-/**
- * Function for registering a new App route
- * @param props AppRouteProps. Note that a render() function must be provided
- */
-export function registerAppRoute(props: AppRouteProps & Required>) {
- if (appRoutes[props.path]) {
- throw new Error(`ERROR: detected illegal duplicate app route ${props.path}`);
- }
-
- appRoutes[props.path] = props;
- console.log('added route ', props.path);
-}
-
-/**
- * Retrieves the url which other pages can use
- * to link to a certain route
- * @param route the route to link to
- */
-export function getLinkForRoute(route: AppRouteProps): LinkType {
- return route.link || route.path;
-}
-
-/**
- * Retrieves the humand readable link title/displayed name
- * for a given route
- *
- * @param route
- */
-export function getDisplayNameForRoute(route: AppRouteProps): string {
- return route.displayName || getLinkForRoute(route);
-}
diff --git a/packages/routing/tsconfig.json b/packages/routing/tsconfig.json
deleted file mode 100644
index ccfc6c0..0000000
--- a/packages/routing/tsconfig.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "extends": "../../tsconfig.base.json",
- "compilerOptions": {
- "rootDir": "src",
- "outDir": "dist",
- "baseUrl": "src"
- },
- "include": ["src/**/*"],
- "references": [
- {
- "path": "../types"
- }
- ]
-}