This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/src/scenes/Dashboard/Dashboard.js

57 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-04-29 05:25:37 +00:00
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
2016-05-07 18:52:08 +00:00
import { fetchAtlasesAsync } from 'actions/AtlasActions';
2016-04-29 05:25:37 +00:00
2016-05-20 04:03:29 +00:00
import Flex from 'components/Flex';
2016-04-29 05:25:37 +00:00
import Layout from 'components/Layout';
2016-05-07 18:52:08 +00:00
import AtlasPreview from 'components/AtlasPreview';
2016-04-30 20:24:13 +00:00
import AtlasPreviewLoading from 'components/AtlasPreviewLoading';
2016-05-07 18:52:08 +00:00
import CenteredContent from 'components/CenteredContent';
2016-04-30 20:24:13 +00:00
2016-04-29 05:25:37 +00:00
import styles from './Dashboard.scss';
class Dashboard extends React.Component {
static propTypes = {
2016-05-07 18:52:08 +00:00
}
componentDidMount = () => {
this.props.fetchAtlasesAsync(this.props.teamId);
2016-04-29 05:25:37 +00:00
}
render() {
return (
2016-05-07 18:52:08 +00:00
<Layout>
<CenteredContent>
2016-05-20 04:03:29 +00:00
<Flex direction="column" flex={ true }>
{ this.props.isLoading ? (
<AtlasPreviewLoading />
) : this.props.items.map((item) => {
2016-05-20 07:34:46 +00:00
return (<AtlasPreview key={ item.id } data={ item } />);
2016-05-20 04:03:29 +00:00
}) }
</Flex>
2016-05-07 18:52:08 +00:00
</CenteredContent>
2016-04-29 05:25:37 +00:00
</Layout>
);
}
}
2016-05-07 18:52:08 +00:00
const mapStateToProps = (state) => {
return {
teamId: state.team ? state.team.id : null,
isLoading: state.atlases.isLoading,
2016-05-18 08:13:52 +00:00
items: Array.isArray(state.atlases.result) ? state.atlases.result.map((id) => state.atlases.entities.atlases[id]) : [], // reselect
2016-05-07 18:52:08 +00:00
}
};
2016-04-29 05:25:37 +00:00
const mapDispatchToProps = (dispatch) => {
2016-05-07 18:52:08 +00:00
return bindActionCreators({
fetchAtlasesAsync,
}, dispatch)
2016-04-29 05:25:37 +00:00
}
export default connect(
2016-05-07 18:52:08 +00:00
mapStateToProps,
mapDispatchToProps
2016-04-29 05:25:37 +00:00
)(Dashboard);