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

Commit 91028f5

Browse files
last two components moved
1 parent 5bbd5ed commit 91028f5

File tree

2 files changed

+37
-15
lines changed

2 files changed

+37
-15
lines changed
Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
import React from 'react';
2-
import { CssBaseline, AppBar, Toolbar, Typography } from '@material-ui/core';
1+
import { AppBar, CssBaseline, Toolbar, Typography } from '@material-ui/core';
32
import { MuiThemeProvider } from '@material-ui/core/styles';
3+
import React, { ComponentType } from 'react';
44
import { Observable as obs } from 'rxjs';
55
import {
6-
mount,
7-
withAuthorization,
86
AuthorizationProvider,
7+
Loading,
8+
mount,
99
NavigationProvider,
1010
Notifications,
11-
Loading,
11+
withAuthorization,
1212
} from './components';
1313
import { SqlStreamStore } from './components/Icons';
14+
import { connect, createState } from './reactive';
1415
import { actions, store, Viewer } from './stream-store';
1516
import theme from './theme';
16-
import { createState, connect } from './reactive';
17+
import { HalLink, HalLinks } from './types';
1718
import { mediaTypes } from './utils';
1819

1920
const getSelfAlias = links =>
@@ -27,23 +28,37 @@ const getSelfAlias = links =>
2728
.map(({ rel }) => rel);
2829

2930
const self$ = store.hal$.links$
30-
.filter(links => links.self)
31+
.filter(links => !!links.self)
3132
.map(getSelfAlias)
3233
.filter(rel => !!rel)
3334
.map(([link]) => link);
3435

35-
const state$ = createState(
36+
interface SqlStreamStoreBrowserState {
37+
loading: boolean;
38+
mediaType: string;
39+
links: HalLinks;
40+
self: HalLink;
41+
}
42+
const state$ = createState<SqlStreamStoreBrowserState>(
3643
obs.merge(
3744
self$.map(self => ['self', () => self]),
3845
store.hal$.links$.map(links => ['links', () => links]),
3946
store.hal$.forms$.map(forms => ['forms', () => forms]),
4047
store.hal$.loading$.map(loading => ['loading', () => loading]),
4148
store.hal$.mediaType$.map(mediaType => ['mediaType', () => mediaType]),
4249
),
43-
obs.of({ links: {}, forms: {}, loading: false }),
50+
obs.of({
51+
forms: {},
52+
links: {},
53+
loading: false,
54+
mediaType: mediaTypes.hal,
55+
self: {
56+
href: '',
57+
},
58+
}),
4459
);
4560

46-
const onNavigate = (link, authorization) =>
61+
const onNavigate = (link: HalLink, authorization: string | undefined) =>
4762
link.href.indexOf('#') === -1 &&
4863
actions.get.request.next({ link, headers: { authorization } });
4964

@@ -64,8 +79,12 @@ const Hero = () => (
6479
</AppBar>
6580
);
6681

67-
const SqlStreamStoreBrowser = withAuthorization()(
68-
mount(initialNavigation)(({ loading, ...props }) => (
82+
const SqlStreamStoreBrowser: ComponentType<
83+
SqlStreamStoreBrowserState
84+
> = withAuthorization()(
85+
mount<SqlStreamStoreBrowserState & { authorization: string | undefined }>(
86+
initialNavigation,
87+
)(({ loading, ...props }) => (
6988
<MuiThemeProvider theme={theme}>
7089
<div>
7190
<CssBaseline />
@@ -80,7 +99,9 @@ const SqlStreamStoreBrowser = withAuthorization()(
8099
)),
81100
);
82101

83-
const AuthorizedSqlStreamStoreBrowser = ({ authorization, ...props }) => (
102+
const AuthorizedSqlStreamStoreBrowser: ComponentType<
103+
SqlStreamStoreBrowserState & { authorization: string | undefined }
104+
> = ({ authorization, ...props }) => (
84105
<AuthorizationProvider authorization={authorization}>
85106
<SqlStreamStoreBrowser {...props} />
86107
</AuthorizationProvider>

src/theme.js renamed to src/theme.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { createMuiTheme } from '@material-ui/core/styles';
2+
import { PaletteOptions } from '@material-ui/core/styles/createPalette';
23

3-
const palette = {
4-
type: 'light',
4+
const palette: PaletteOptions = {
55
action: {
66
active: '#42c0fb',
77
},
8+
type: 'light',
89
};
910

1011
const typography = {

0 commit comments

Comments
 (0)