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-10-24 07:50:05 +00:00
|
|
|
const filteredHeaders = headers.filter( header => ! header.hiddenByDefault );
|
2018-08-31 14:43:25 +00:00
|
|
|
const rows = range( numberOfRows ).map( () =>
|
2018-10-24 07:50:05 +00:00
|
|
|
filteredHeaders.map( () => ( { display: <span className="is-placeholder" /> } ) )
|
2018-08-31 14:43:25 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Table
|
|
|
|
ariaHidden={ true }
|
|
|
|
caption={ caption }
|
|
|
|
classNames="is-loading"
|
2018-10-24 07:50:05 +00:00
|
|
|
headers={ filteredHeaders }
|
2018-08-31 14:43:25 +00:00
|
|
|
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( {
|
2018-10-24 07:50:05 +00:00
|
|
|
hiddenByDefault: PropTypes.bool,
|
2018-08-31 14:43:25 +00:00
|
|
|
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;
|