-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
5892eba
commit 97393f6
Showing
7 changed files
with
106 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
import { Divider, List } from '@material-ui/core'; | ||
import * as React from 'react'; | ||
import { RouteComponentProps } from 'react-router'; | ||
import { Routed } from '../../util/routing'; | ||
import { LinkListItem } from '../general/LinkListItem'; | ||
import { LinkDirectory } from './support/LinkDirectory'; | ||
|
||
export interface LinkPageProps extends RouteComponentProps {} | ||
|
||
export const LinkPage = (props: LinkPageProps) => ( | ||
<> | ||
<h1>Useful Links List</h1> | ||
<List> | ||
<LinkListItem href={'https://elite-se.informatik.uni-augsburg.de'} title={'Main Webpage'} /> | ||
<LinkListItem href={'https://github.com/elite-se/elite-se.protokolle'} title={'Exam Protocols'} /> | ||
</List> | ||
@Routed({ path: '/link', displayName: 'Useful Links' }) | ||
export class LinkPage extends React.PureComponent<LinkPageProps> { | ||
render() { | ||
return ( | ||
<> | ||
<h1>Useful Links List</h1> | ||
<List> | ||
<LinkListItem href={'https://elite-se.informatik.uni-augsburg.de'} title={'Main Webpage'} /> | ||
<LinkListItem href={'https://github.com/elite-se/elite-se.protokolle'} title={'Exam Protocols'} /> | ||
</List> | ||
|
||
<Divider /> | ||
<Divider /> | ||
|
||
<LinkDirectory /> | ||
</> | ||
); | ||
<LinkDirectory /> | ||
</> | ||
); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import * as React from 'react'; | ||
import { RouteProps } from 'react-router'; | ||
|
||
// TODO: move to separate package | ||
|
||
/** | ||
* The Routed decorator automatically creates a route for | ||
* the annotated top level page component | ||
* | ||
* @param props route properties | ||
*/ | ||
export function Routed(props: AppRouteProps) { | ||
console.log('producing route decorator:', props); | ||
return (constructor: any) => { | ||
APP_ROUTES.push({ | ||
render: p => React.createElement(constructor, p), | ||
...props, | ||
}); | ||
console.log('added route for', constructor.name); | ||
return constructor; | ||
}; | ||
} | ||
|
||
// If necessary, add support for: H.LocationDescriptor | ((location: H.Location) => H.LocationDescriptor); | ||
type LinkType = string; | ||
|
||
// TODO: Add documentation | ||
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; | ||
} | ||
|
||
// TODO: replace with proper container/service class | ||
/** | ||
* Retrieves the url which other pages can use | ||
* to link to a certain route | ||
* @param route the route to link to | ||
*/ | ||
export function getLinkForPage(route: AppRouteProps): LinkType { | ||
return route.link || route.path; | ||
} | ||
|
||
// TODO: replace with proper container/service class | ||
/** | ||
* Retrieves the humand readable link title/displayed name | ||
* for a given route | ||
* | ||
* @param route | ||
*/ | ||
export function getLinkDisplayNameForPage(route: AppRouteProps): string { | ||
return route.displayName || getLinkForPage(route); | ||
} | ||
|
||
// TODO: replace with proper container/service class | ||
export const APP_ROUTES: AppRouteProps[] = []; |
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
experimental decorators are enable in tsconfig.base.json