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

Commit f0accca

Browse files
Merge pull request #6 from thefringeninja/list-streams
Add Support for Listing Streams
2 parents 0a1e117 + 59d6692 commit f0accca

File tree

11 files changed

+281
-40
lines changed

11 files changed

+281
-40
lines changed

src/components/HyperMediaControls/LinkButton.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const TemplatedLinkButton = withAuthorization()(
3737
key={name}
3838
label={name}
3939
onChange={this._onChange(name)}
40+
fullWidth
4041
/>
4142
))}
4243
</Dialog>

src/components/HyperMediaControls/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { connect, createState } from '../../reactive';
44
import { navigation, store } from '../../stream-store';
55
import LinkButton from './LinkButton';
66
import FormButton from './FormButton';
7+
import { rels } from '../../stream-store';
8+
9+
const isNotSelf = (rel, links) =>
10+
links[rels.self] && links[rel].href !== links[rels.self].href;
711

812
const state$ = createState(store.url$.map(url => ['url', () => url]));
913

@@ -13,6 +17,7 @@ const HyperMediaControls = ({ forms, url, actions, links, onNavigate }) => (
1317
<div>
1418
{Object.keys(links)
1519
.filter(rel => !navigation.has(rel))
20+
.filter(rel => isNotSelf(rel, links))
1621
.map(rel => (
1722
<LinkButton
1823
key={rel}

src/components/Icons/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export { default as Error } from '@material-ui/icons/Error';
99
export { default as Info } from '@material-ui/icons/Info';
1010
export { default as Publish } from '@material-ui/icons/Publish';
1111
export { default as Settings } from '@material-ui/icons/Settings';
12+
export { default as Notes } from '@material-ui/icons/Notes';
1213
export { default as DeleteForever } from '@material-ui/icons/DeleteForever';
1314
export { default as FirstPage } from '@material-ui/icons/FirstPage';
1415
export { default as LastPage } from '@material-ui/icons/LastPage';
@@ -18,3 +19,4 @@ export { default as RssFeed } from '@material-ui/icons/RssFeed';
1819
export { default as Refresh } from '@material-ui/icons/Refresh';
1920
export { default as SpaceBar } from '@material-ui/icons/SpaceBar';
2021
export { default as Search } from '@material-ui/icons/Search';
22+
export { default as List } from '@material-ui/icons/List';

src/components/RelIcon.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
Refresh,
1212
Search,
1313
SqlStreamStore,
14+
List,
1415
} from './Icons';
1516
import { rels } from '../stream-store';
1617

@@ -25,6 +26,7 @@ const fontIconByRel = {
2526
[rels.metadata]: Settings,
2627
[rels.delete]: DeleteForever,
2728
[rels.find]: Search,
29+
[rels.browse]: List,
2830
};
2931

3032
const RelIcon = ({ rel, ...props }) =>

src/components/StreamBrowser.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from 'react';
2+
import {
3+
List,
4+
ListItem,
5+
ListItemText,
6+
LinearProgress,
7+
Typography,
8+
withStyles,
9+
} from '@material-ui/core';
10+
import Hyperlink from './Hyperlink';
11+
12+
const StreamBrowser = withStyles(theme => ({
13+
browser: {
14+
padding: theme.spacing.unit * 2.5,
15+
},
16+
}))(({ streams, onNavigate, classes, loading }) => (
17+
<div className={classes.browser}>
18+
<Typography variant={'title'}>Stream Browser</Typography>
19+
{loading ? (
20+
<LinearProgress />
21+
) : streams.length ? (
22+
<List>
23+
{streams.map(({ title, href }) => (
24+
<ListItem key={href}>
25+
<ListItemText>
26+
<Hyperlink href={href} onNavigate={onNavigate}>
27+
{title}
28+
</Hyperlink>
29+
</ListItemText>
30+
</ListItem>
31+
))}
32+
</List>
33+
) : (
34+
<Typography variant={'body2'}>
35+
No matching streams found.
36+
</Typography>
37+
)}
38+
</div>
39+
));
40+
41+
export default StreamBrowser;

src/components/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ export {
22
default as AuthorizationProvider,
33
withAuthorization,
44
} from './AuthorizationProvider';
5+
export { default as Hyperlink } from './Hyperlink';
6+
export { default as HyperMediaControls } from './HyperMediaControls';
7+
export { default as Loading } from './Loading';
58
export { default as NavigationLinks } from './NavigationLinks';
69
export { default as Notifications } from './Notifications';
7-
export { default as HyperMediaControls } from './HyperMediaControls';
10+
export { default as StreamBrowser } from './StreamBrowser';
811
export { default as mount } from './mount';
9-
export { default as Hyperlink } from './Hyperlink';
10-
export { default as Loading } from './Loading';

src/stream-store/rels.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const rels = {
1111
append: 'streamStore:append',
1212
delete: 'streamStore:delete',
1313
find: 'streamStore:find',
14+
browse: 'streamStore:feed-browser',
1415
};
1516

1617
export default rels;

src/stream-store/views/Home.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const state$ = createState(
1717
links$.map(links => ['links', links]),
1818
recent$.map(recent => ['recent', recent]),
1919
),
20-
obs.of({ recent: { streamIds: [] }, links: {} }),
20+
obs.of({ recent: { matches: [] }, links: {} }),
2121
);
2222

2323
const relsToTitle = {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react';
2+
import { Observable as obs } from 'rxjs';
3+
import StreamBrowser from '../../components/StreamBrowser';
4+
import { createState, connect } from '../../reactive';
5+
import rels from '../rels';
6+
import store from '../store';
7+
8+
const streams$ = store.body$.map(({ _embedded = {} }) => () =>
9+
(_embedded[rels.feed] || [])
10+
.map(({ _links = {} }) => _links[rels.feed])
11+
.filter(link => link),
12+
);
13+
14+
const state$ = createState(
15+
streams$.map(streams => ['streams', streams]),
16+
obs.of({ streams: [] }),
17+
);
18+
19+
export default connect(state$)(StreamBrowser);

0 commit comments

Comments
 (0)