File size: 2,976 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
import { get } from 'lodash';
import PropTypes from 'prop-types';
import { createElement, Component } from 'react';
import { connect } from 'react-redux';
import QueryProductsList from 'calypso/components/data/query-products-list';
import QuerySiteDomains from 'calypso/components/data/query-site-domains';
import QuerySitePlans from 'calypso/components/data/query-site-plans';
import PageViewTracker from 'calypso/lib/analytics/page-view-tracker';
import CalypsoShoppingCartProvider from 'calypso/my-sites/checkout/calypso-shopping-cart-provider';
import { getCurrentUser } from 'calypso/state/current-user/selectors';
import { getProductsList } from 'calypso/state/products-list/selectors';
import {
getDomainsBySiteId,
hasLoadedSiteDomains,
isRequestingSiteDomains,
} from 'calypso/state/sites/domains/selectors';
import { getPlansBySite } from 'calypso/state/sites/plans/selectors';
import { getSelectedSite } from 'calypso/state/ui/selectors';
class DomainManagementData extends Component {
static propTypes = {
analyticsPath: PropTypes.string,
analyticsTitle: PropTypes.string,
context: PropTypes.object.isRequired,
domains: PropTypes.array,
isRequestingSiteDomains: PropTypes.bool,
needsDns: PropTypes.bool,
needsDomains: PropTypes.bool,
needsPlans: PropTypes.bool,
needsProductsList: PropTypes.bool,
productsList: PropTypes.object,
selectedDomainName: PropTypes.string,
selectedSite: PropTypes.object,
sitePlans: PropTypes.object,
};
render() {
const { needsDomains, needsPlans, needsProductsList, selectedSite } = this.props;
return (
<div>
<PageViewTracker path={ this.props.analyticsPath } title={ this.props.analyticsTitle } />
{ selectedSite && needsDomains && <QuerySiteDomains siteId={ selectedSite.ID } /> }
{ selectedSite && needsPlans && <QuerySitePlans siteId={ selectedSite.ID } /> }
{ needsProductsList && <QueryProductsList /> }
<CalypsoShoppingCartProvider>
{ createElement( this.props.component, {
context: this.props.context,
domains: selectedSite ? this.props.domains : null,
hasSiteDomainsLoaded: this.props.hasSiteDomainsLoaded,
isRequestingSiteDomains: this.props.isRequestingSiteDomains,
products: this.props.products,
selectedDomainName: this.props.selectedDomainName,
selectedSite,
sitePlans: this.props.sitePlans,
user: this.props.currentUser,
} ) }
</CalypsoShoppingCartProvider>
</div>
);
}
}
export default connect( ( state ) => {
const selectedSite = getSelectedSite( state );
const siteId = get( selectedSite, 'ID', null );
return {
currentUser: getCurrentUser( state ),
domains: getDomainsBySiteId( state, siteId ),
hasSiteDomainsLoaded: hasLoadedSiteDomains( state, siteId ),
isRequestingSiteDomains: isRequestingSiteDomains( state, siteId ),
productsList: getProductsList( state ),
sitePlans: getPlansBySite( state, selectedSite ),
selectedSite,
};
} )( DomainManagementData );
|