2018-08-31 14:43:25 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { Component } from '@wordpress/element';
|
|
|
|
import { range } from 'lodash';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import Table from './table';
|
|
|
|
|
Add loading indicators, error state, and EmptyContent to the revenue report. (#347, woocommerce/woocommerce-admin#348)
* Add loading indiciators for the revenue report.
* Improve accessibility, and fix up some documentation comments.
* Fix top border on mobile
* Add EmptyContent Component and revenue error/empty states. (https://github.com/woocommerce/woocommerce-admin/pull/348)
* Add EmptyContent Component and revenue error/empty states.
* Move relative image handling to ImageAsset, combine secondary and primary action rendering, add some missing isRequired proptypes, add empty error handling.
* Handle PR Feedback: Clean up button css, set a default for illustration, fix deprecation typo, some code cleanup.
2018-09-05 16:45:49 +00:00
|
|
|
/**
|
|
|
|
* `TablePlaceholder` behaves like `Table` but displays placeholder boxes instead of data. This can be used while loading.
|
|
|
|
*/
|
2018-08-31 14:43:25 +00:00
|
|
|
class TablePlaceholder extends Component {
|
|
|
|
render() {
|
2018-10-10 13:57:16 +00:00
|
|
|
const { caption, headers, numberOfRows, query } = this.props;
|
2018-08-31 14:43:25 +00:00
|
|
|
const rows = range( numberOfRows ).map( () =>
|
|
|
|
headers.map( () => ( { display: <span className="is-placeholder" /> } ) )
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Table
|
|
|
|
ariaHidden={ true }
|
|
|
|
caption={ caption }
|
|
|
|
classNames="is-loading"
|
|
|
|
headers={ headers }
|
|
|
|
rowHeader={ false }
|
|
|
|
rows={ rows }
|
2018-10-10 13:57:16 +00:00
|
|
|
query={ query }
|
2018-08-31 14:43:25 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TablePlaceholder.propTypes = {
|
2018-10-10 13:57:16 +00:00
|
|
|
/**
|
|
|
|
* An object of the query parameters passed to the page, ex `{ page: 2, per_page: 5 }`.
|
|
|
|
*/
|
|
|
|
query: PropTypes.object,
|
Add loading indicators, error state, and EmptyContent to the revenue report. (#347, woocommerce/woocommerce-admin#348)
* Add loading indiciators for the revenue report.
* Improve accessibility, and fix up some documentation comments.
* Fix top border on mobile
* Add EmptyContent Component and revenue error/empty states. (https://github.com/woocommerce/woocommerce-admin/pull/348)
* Add EmptyContent Component and revenue error/empty states.
* Move relative image handling to ImageAsset, combine secondary and primary action rendering, add some missing isRequired proptypes, add empty error handling.
* Handle PR Feedback: Clean up button css, set a default for illustration, fix deprecation typo, some code cleanup.
2018-09-05 16:45:49 +00:00
|
|
|
/**
|
|
|
|
* A label for the content in this table.
|
|
|
|
*/
|
2018-08-31 14:43:25 +00:00
|
|
|
caption: PropTypes.string.isRequired,
|
Add loading indicators, error state, and EmptyContent to the revenue report. (#347, woocommerce/woocommerce-admin#348)
* Add loading indiciators for the revenue report.
* Improve accessibility, and fix up some documentation comments.
* Fix top border on mobile
* Add EmptyContent Component and revenue error/empty states. (https://github.com/woocommerce/woocommerce-admin/pull/348)
* Add EmptyContent Component and revenue error/empty states.
* Move relative image handling to ImageAsset, combine secondary and primary action rendering, add some missing isRequired proptypes, add empty error handling.
* Handle PR Feedback: Clean up button css, set a default for illustration, fix deprecation typo, some code cleanup.
2018-09-05 16:45:49 +00:00
|
|
|
/**
|
|
|
|
* An array of column headers (see `Table` props).
|
|
|
|
*/
|
2018-08-31 14:43:25 +00:00
|
|
|
headers: PropTypes.arrayOf(
|
|
|
|
PropTypes.shape( {
|
|
|
|
defaultSort: PropTypes.bool,
|
|
|
|
isSortable: PropTypes.bool,
|
|
|
|
key: PropTypes.string,
|
|
|
|
label: PropTypes.string,
|
|
|
|
required: PropTypes.bool,
|
|
|
|
} )
|
|
|
|
),
|
Add loading indicators, error state, and EmptyContent to the revenue report. (#347, woocommerce/woocommerce-admin#348)
* Add loading indiciators for the revenue report.
* Improve accessibility, and fix up some documentation comments.
* Fix top border on mobile
* Add EmptyContent Component and revenue error/empty states. (https://github.com/woocommerce/woocommerce-admin/pull/348)
* Add EmptyContent Component and revenue error/empty states.
* Move relative image handling to ImageAsset, combine secondary and primary action rendering, add some missing isRequired proptypes, add empty error handling.
* Handle PR Feedback: Clean up button css, set a default for illustration, fix deprecation typo, some code cleanup.
2018-09-05 16:45:49 +00:00
|
|
|
/**
|
|
|
|
* An integer with the number of rows to display.
|
|
|
|
*/
|
2018-08-31 14:43:25 +00:00
|
|
|
numberOfRows: PropTypes.number,
|
|
|
|
};
|
|
|
|
|
|
|
|
TablePlaceholder.defaultProps = {
|
|
|
|
numberOfRows: 5,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default TablePlaceholder;
|