-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove routing package and reimplement old routing style #13
- Loading branch information
1 parent
ea58e75
commit fcc1d4d
Showing
10 changed files
with
108 additions
and
132 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
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
4 changes: 2 additions & 2 deletions
4
packages/frontend/src/components/pages/support/LinkDirectory.tsx
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,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 => <HomePage {...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 => <LinkPage {...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 => <HomePage {...props} />, | ||
}); | ||
registerAppRoute({ | ||
path: AppPaths.LINK, | ||
displayName: 'Useful Links', | ||
render: props => <LinkPage {...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'; | ||
} |
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 |
---|---|---|
|
@@ -13,9 +13,6 @@ | |
{ | ||
"path": "../feature-flags" | ||
}, | ||
{ | ||
"path": "../routing" | ||
}, | ||
{ | ||
"path": "../types" | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.