Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 2d05085

Browse files
the many anys are gone!
1 parent 5c0a93e commit 2d05085

File tree

12 files changed

+72
-38
lines changed

12 files changed

+72
-38
lines changed

src/components/HyperMediaControls/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Card, CardActions } from '@material-ui/core';
22
import { JSONSchema7 } from 'json-schema';
3-
import React, { ComponentType, StatelessComponent } from 'react';
3+
import React, { ComponentType } from 'react';
44
import { Observable } from 'rxjs';
55
import { connect, createState } from '../../reactive';
66
import { navigation, rels, store } from '../../stream-store';
@@ -59,4 +59,6 @@ const HyperMediaControls: ComponentType<
5959
</Card>
6060
);
6161

62-
export default connect(state$)(HyperMediaControls);
62+
export default connect<HyperMediaControlsProps, HyperMediaControlsState>(
63+
state$,
64+
)(HyperMediaControls);

src/components/StripeyTable/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ import {
99
WithStyles,
1010
withStyles,
1111
} from '@material-ui/core';
12-
import { TableCellProps } from '@material-ui/core/TableCell';
1312
import { TableRowProps } from '@material-ui/core/TableRow';
14-
import React, { ComponentType } from 'react';
13+
import React from 'react';
1514

1615
const TableCell = withStyles(theme => ({
1716
head: {
1817
backgroundColor: theme.palette.primary.dark,
1918
color: theme.palette.common.white,
2019
},
21-
}))(MaterialTableCell) as ComponentType<TableCellProps>;
20+
}))(MaterialTableCell);
2221

2322
const tableRowStyles = (theme: Theme) => ({
2423
row: {
@@ -35,6 +34,6 @@ const TableRow = withStyles(tableRowStyles)(
3534
}: TableRowProps & WithStyles<typeof tableRowStyles>) => (
3635
<MaterialTableRow {...props} className={classes.row} />
3736
),
38-
) as ComponentType<TableRowProps>;
37+
);
3938

4039
export { Table, TableBody, TableHead, TableCell, TableRow, TableFooter };

src/stream-store/Viewer/HalViewer/Home.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,13 @@ const Info: StatelessComponent<InfoState> = ({ provider, versions }) => (
7373
</Table>
7474
);
7575

76-
const Index: StatelessComponent<IndexState> = ({ provider, versions }) => (
76+
const Index: ComponentType<IndexState & HalViewerProps> = ({
77+
provider,
78+
versions,
79+
}) => (
7780
<section>
7881
<Info provider={provider} versions={versions} />
7982
</section>
8083
);
8184

82-
export default connect(state$)(Index) as ComponentType<HalViewerProps>;
85+
export default connect<HalViewerProps, IndexState>(state$)(Index);

src/stream-store/Viewer/HalViewer/Stream.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ interface StreamState {
9292
messages: Array<Message & HalResource>;
9393
}
9494

95-
const Stream: StatelessComponent<StreamState> = ({ messages = [] }) => (
95+
const Stream: ComponentType<StreamState & HalViewerProps> = ({
96+
messages = [],
97+
}) => (
9698
<section>
9799
<Messages messages={messages} />
98100
</section>
99101
);
100102

101-
export default connect(state$)(Stream) as ComponentType<HalViewerProps>;
103+
export default connect<HalViewerProps, StreamState>(state$)(Stream);

src/stream-store/Viewer/HalViewer/StreamBrowser.ts renamed to src/stream-store/Viewer/HalViewer/StreamBrowser.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { ComponentType } from 'react';
1+
import React, { ComponentType } from 'react';
22
import { Observable as obs } from 'rxjs';
3-
import StreamBrowser from '../../../components/StreamBrowser';
3+
import { StreamBrowser } from '../../../components';
44
import { connect, createState } from '../../../reactive';
55
import { HalResource } from '../../../types';
66
import rels from '../../rels';
@@ -21,4 +21,12 @@ const state$ = createState<StreamBrowserState>(
2121
obs.of<StreamBrowserState>({ loading: false, streams: [] }),
2222
);
2323

24-
export default connect(state$)(StreamBrowser);
24+
const StreamBrowserComponent: ComponentType<
25+
StreamBrowserState & HalViewerProps
26+
> = ({ streams, loading }) => (
27+
<StreamBrowser loading={loading} streams={streams} />
28+
);
29+
30+
export default connect<HalViewerProps, StreamBrowserState>(state$)(
31+
StreamBrowserComponent,
32+
);

src/stream-store/Viewer/HalViewer/StreamMessage.tsx

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ import {
1111
import React, {
1212
ComponentType,
1313
CSSProperties,
14+
FormEvent,
15+
FormEventHandler,
1416
PureComponent,
17+
ReactEventHandler,
18+
ReactNode,
1519
StatelessComponent,
1620
} from 'react';
1721
import Inspector, {
22+
NodeRendererProps,
1823
ObjectLabel,
1924
ObjectName,
2025
ObjectRootLabel,
@@ -51,7 +56,7 @@ const message$ = store.hal$.body$.map(({ payload, metadata, ...body }) => ({
5156
payload: tryParseJson(payload),
5257
}));
5358

54-
interface StreamMessageState {
59+
interface StreamMessageState extends HalResource {
5560
message: {
5661
messageId: string;
5762
createdUtc: string;
@@ -67,6 +72,8 @@ interface StreamMessageState {
6772
const state$ = createState<StreamMessageState>(
6873
message$.map(message => ['message', () => message]),
6974
obs.of<StreamMessageState>({
75+
_embedded: {},
76+
_links: {},
7077
message: {
7178
createdUtc: '',
7279
messageId: '',
@@ -127,10 +134,10 @@ const StreamMessageDetails: StatelessComponent<
127134
</TableRow>
128135
);
129136

130-
const isPotentialStreamId = data =>
137+
const isPotentialStreamId = (data: any) =>
131138
typeof data === 'number' || typeof data === 'string';
132139

133-
const getStreamLinks = ({ _embedded }): HalResource[] =>
140+
const getStreamLinks = ({ _embedded }: HalResource): HalResource[] =>
134141
_embedded[rels.feed] || [];
135142

136143
interface StreamMessageJsonState {
@@ -167,10 +174,10 @@ const StreamMessageJson = withStyles(style)(class extends PureComponent<
167174
streams: [],
168175
};
169176

170-
_handlePotentialStreamIdClick = async (
171-
{ currentTarget: anchorElement },
172-
pattern,
173-
) => {
177+
_handlePotentialStreamIdClick: (
178+
e: FormEvent,
179+
pattern: string,
180+
) => Promise<void> = async ({ currentTarget: anchorElement }, pattern) => {
174181
const { authorization, _links } = this.props;
175182

176183
this.setState({
@@ -212,7 +219,13 @@ const StreamMessageJson = withStyles(style)(class extends PureComponent<
212219
open: false,
213220
});
214221

215-
_renderNode = ({ depth, name, data, path, isNonenumerable, ...props }) =>
222+
_renderNode = ({
223+
depth,
224+
name,
225+
data,
226+
isNonenumerable,
227+
...props
228+
}: NodeRendererProps & { children?: ReactNode }) =>
216229
depth === 0 ? (
217230
<ObjectRootLabel name={name} data={{}} {...props} />
218231
) : isPotentialStreamId(data) ? (
@@ -282,7 +295,8 @@ class StreamMessageTabs extends PureComponent<
282295
value: 0,
283296
};
284297

285-
_handleChange = (e, value) => this.setState({ value });
298+
_handleChange: (e: FormEvent, value: number) => void = (e, value) =>
299+
this.setState({ value });
286300

287301
render() {
288302
const {
@@ -315,7 +329,7 @@ class StreamMessageTabs extends PureComponent<
315329
}
316330
}
317331

318-
const StreamMessage: StatelessComponent<StreamMessageState & HalResource> = ({
332+
const StreamMessage: ComponentType<StreamMessageState & HalViewerProps> = ({
319333
message,
320334
...props
321335
}) => (
@@ -332,4 +346,6 @@ const StreamMessage: StatelessComponent<StreamMessageState & HalResource> = ({
332346
</section>
333347
);
334348

335-
export default connect(state$)(StreamMessage) as ComponentType<HalViewerProps>;
349+
export default connect<HalViewerProps, StreamMessageState>(state$)(
350+
StreamMessage,
351+
);

src/stream-store/Viewer/HalViewer/StreamMetadata.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ class StreamMetadataJson extends PureComponent<
124124
}
125125
}
126126

127-
const StreamMetadata: StatelessComponent<StreamMetadataState> = ({
128-
metadata,
129-
}) => (
127+
const StreamMetadata: StatelessComponent<
128+
StreamMetadataState & HalViewerProps
129+
> = ({ metadata }) => (
130130
<section>
131131
<Table style={{ tableLayout: 'auto' }}>
132132
<TableHead>
@@ -140,4 +140,6 @@ const StreamMetadata: StatelessComponent<StreamMetadataState> = ({
140140
</section>
141141
);
142142

143-
export default connect(state$)(StreamMetadata) as ComponentType<HalViewerProps>;
143+
export default connect<HalViewerProps, StreamMetadataState>(state$)(
144+
StreamMetadata,
145+
);

src/stream-store/Viewer/HalViewer/Unrecognized.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import { preventDefault } from '../../../utils';
1515
import store from '../../store';
1616
import { HalViewerProps } from './types';
1717

18-
interface UnregcognizedRelViewerState {
18+
interface UnrecognizedRelViewerState {
1919
data: object;
2020
}
21-
const state$ = createState<UnregcognizedRelViewerState>(
21+
const state$ = createState<UnrecognizedRelViewerState>(
2222
store.hal$.body$.map(data => ['data', () => data]),
23-
obs.of<UnregcognizedRelViewerState>({
23+
obs.of<UnrecognizedRelViewerState>({
2424
data: {},
2525
}),
2626
);
@@ -56,7 +56,7 @@ const MaybeLinkLabel: ComponentType<ObjectLabelProps> = withNavigation<
5656
);
5757

5858
class UnrecognizedRelViewer extends React.PureComponent<
59-
UnregcognizedRelViewerState
59+
UnrecognizedRelViewerState & HalViewerProps
6060
> {
6161
_nodeRenderer = ({ depth, ...props }: NodeRendererProps) =>
6262
depth === 0 ? (
@@ -76,4 +76,6 @@ class UnrecognizedRelViewer extends React.PureComponent<
7676
}
7777
}
7878

79-
export default connect(state$)(UnrecognizedRelViewer);
79+
export default connect<HalViewerProps, UnrecognizedRelViewerState>(state$)(
80+
UnrecognizedRelViewer,
81+
);

src/stream-store/Viewer/MarkdownViewer/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Typography } from '@material-ui/core';
2-
import React from 'react';
2+
import React, { ComponentType } from 'react';
33
import Remarkable from 'react-remarkable';
44
import { Observable } from 'rxjs';
55
import { connect, createState } from '../../../reactive';
@@ -17,7 +17,7 @@ const state$ = createState<MarkdownViewerState>(
1717
}),
1818
);
1919

20-
const MarkdownViewer = ({ body }: { body: string }) => (
20+
const MarkdownViewer: ComponentType<MarkdownViewerState> = ({ body }) => (
2121
<Typography>
2222
<Remarkable
2323
options={{
@@ -28,4 +28,4 @@ const MarkdownViewer = ({ body }: { body: string }) => (
2828
</Remarkable>
2929
</Typography>
3030
);
31-
export default connect(state$)(MarkdownViewer);
31+
export default connect<{}, MarkdownViewerState>(state$)(MarkdownViewer);

src/stream-store/Viewer/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const viewers = {
88
[mediaTypes.hal]: HalViewer,
99
};
1010

11-
const Viewer = ({ mediaType, ...props }: { mediaType: string } & any) =>
11+
const Viewer = ({ mediaType, ...props }: { mediaType: string }) =>
1212
createElement(viewers[mediaType] || 'div', props);
1313

1414
export default Viewer;

0 commit comments

Comments
 (0)