From 40c2026cb0b8364ddf5c7fb8af174faafeb31d99 Mon Sep 17 00:00:00 2001 From: thefringeninja Date: Wed, 24 Oct 2018 11:15:00 +1000 Subject: [PATCH 01/17] defining hal ink types --- src/types/index.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/types/index.d.ts diff --git a/src/types/index.d.ts b/src/types/index.d.ts new file mode 100644 index 0000000..4daf25c --- /dev/null +++ b/src/types/index.d.ts @@ -0,0 +1,14 @@ +export interface HalLink { + readonly href: string; + readonly title?: string; + readonly type?: string; + readonly templated?: boolean; + readonly deprecation?: string; + readonly hreflang?: string; + readonly name?: string; +} + +export interface HalLinks { + [rel: string]: HalLink[]; +} + From 1879121c159176d0a8d238d73959bb75fce9c981 Mon Sep 17 00:00:00 2001 From: thefringeninja Date: Wed, 24 Oct 2018 11:34:42 +1000 Subject: [PATCH 02/17] embedded resources --- src/types/index.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 4daf25c..8a08bbb 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -12,3 +12,12 @@ export interface HalLinks { [rel: string]: HalLink[]; } +export interface EmbeddedResource { + readonly _links?: HalLinks; + readonly _embedded: EmbeddedResources; +} + +export interface EmbeddedResources { + [rel: string]: EmbeddedResource | EmbeddedResource[]; +} +} From 772b1fee52efc4db43059e30bbaaae719502d992 Mon Sep 17 00:00:00 2001 From: thefringeninja Date: Wed, 24 Oct 2018 11:43:24 +1000 Subject: [PATCH 03/17] converted NavigationLinks --- ...NavigationLinks.js => NavigationLinks.tsx} | 35 +++++++++++++------ .../{navigation.js => navigation.ts} | 0 src/stream-store/{rels.js => rels.ts} | 2 +- src/types/index.d.ts | 4 +++ tsconfig.json | 1 + 5 files changed, 31 insertions(+), 11 deletions(-) rename src/components/{NavigationLinks.js => NavigationLinks.tsx} (55%) rename src/stream-store/{navigation.js => navigation.ts} (100%) rename src/stream-store/{rels.js => rels.ts} (92%) diff --git a/src/components/NavigationLinks.js b/src/components/NavigationLinks.tsx similarity index 55% rename from src/components/NavigationLinks.js rename to src/components/NavigationLinks.tsx index 44a4040..0e2538b 100644 --- a/src/components/NavigationLinks.js +++ b/src/components/NavigationLinks.tsx @@ -1,12 +1,26 @@ -import React, { PureComponent } from 'react'; +import React, { + FormEventHandler, + PureComponent, + StatelessComponent, +} from 'react'; import { IconButton } from '@material-ui/core'; +import { HalLink, HalLinks, NavigatableProps } from '../types'; import RelIcon from './RelIcon'; import { withNavigation } from './NavigationProvider'; import { navigation } from '../stream-store'; -const FeedNavigationLink = withNavigation()( - class What extends PureComponent { - _handleOnClick = e => { +interface FeedNavigationLinkProps { + link: HalLink; + rel: string; +} + +const FeedNavigationLink: StatelessComponent< + FeedNavigationLinkProps +> = withNavigation()( + class What extends PureComponent< + FeedNavigationLinkProps & NavigatableProps + > { + _handleOnClick: FormEventHandler = e => { const { onNavigate, authorization, link } = this.props; e.preventDefault(); @@ -21,19 +35,20 @@ const FeedNavigationLink = withNavigation()( render() { const { rel, link } = this.props; return ( - + ); } }, ); +interface NavigationLinksProps { + links: HalLinks; +} -const NavigationLinks = ({ links }) => ( +const NavigationLinks: StatelessComponent = ({ + links, +}) => (