|
|
@@ -1,9 +1,13 @@
|
|
|
import { connect } from 'react-redux';
|
|
|
import React, { Component } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
|
+import classNames from 'classnames';
|
|
|
import uniqid from 'uniqid';
|
|
|
|
|
|
-import { getDocs } from 'selectors/crud';
|
|
|
+import {
|
|
|
+ getCrudLoading,
|
|
|
+ getDocs
|
|
|
+} from 'selectors/crud';
|
|
|
|
|
|
import {
|
|
|
docCreated,
|
|
|
@@ -12,10 +16,14 @@ import {
|
|
|
docDeleted
|
|
|
} from 'actions/crud';
|
|
|
|
|
|
+import LoadingIndicator from 'components/LoadingIndicator';
|
|
|
import CrudDocument from 'components/CrudDocument';
|
|
|
import AddCrudItem from 'components/AddCrudItem';
|
|
|
|
|
|
+import './style.scss';
|
|
|
+
|
|
|
const mapStateToProps = (state, { route }) => ({
|
|
|
+ loading: getCrudLoading(state, route),
|
|
|
items: getDocs(state, route)
|
|
|
});
|
|
|
|
|
|
@@ -36,6 +44,7 @@ class CrudList extends Component {
|
|
|
static propTypes = {
|
|
|
title: PropTypes.string.isRequired,
|
|
|
route: PropTypes.string.isRequired,
|
|
|
+ loading: PropTypes.bool.isRequired,
|
|
|
docFields: PropTypes.object.isRequired,
|
|
|
items: PropTypes.array.isRequired,
|
|
|
onCreate: PropTypes.func.isRequired,
|
|
|
@@ -68,6 +77,7 @@ class CrudList extends Component {
|
|
|
const {
|
|
|
title,
|
|
|
items,
|
|
|
+ loading,
|
|
|
docFields
|
|
|
} = this.props;
|
|
|
|
|
|
@@ -83,7 +93,7 @@ class CrudList extends Component {
|
|
|
));
|
|
|
|
|
|
return (
|
|
|
- <div className="crud-list-wrapper">
|
|
|
+ <div className={classNames('crud-list-wrapper', { loading })}>
|
|
|
<div className="head">
|
|
|
<h3 className="title">{title}</h3>
|
|
|
<div className="meta">
|
|
|
@@ -91,6 +101,7 @@ class CrudList extends Component {
|
|
|
onClick={this.onRefresh}>
|
|
|
{'Refresh'}
|
|
|
</button>
|
|
|
+ <LoadingIndicator loading={loading} />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div className="body">
|