Skip to content

Commit

Permalink
Domains: Make sure there is only one way to pass component to Data co…
Browse files Browse the repository at this point in the history
…mponent
  • Loading branch information
gziolo committed Dec 3, 2015
1 parent 77a7ed7 commit 01003ce
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 41 deletions.
7 changes: 4 additions & 3 deletions client/components/data/domain-management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ const MyComponent = React.createClass( {
render() {
return (
<DomainManagementData
component={ MyChildComponent }
context={ context }
productsList={ productsList }
sites={ sites }>
{ MyChildComponent }
</DomainManagementData>
sites={ sites } />
);
}
} );
Expand All @@ -51,12 +50,14 @@ The component expects to receive all listed props:

* `context` - a request context
* `productsList` - a collection of all the products users can have on WordPress.com
* `selectedDomainName` - the domain name currently selected (optional)
* `sites` - a list of user sites

The child component should receive processed props defined during the render:

* `context` - a request context
* `products` - a collection of all the products users can have on WordPress.com
* `selectedDomainName` - the domain name currently selected (optional)
* `selectedSite` - the site currently selected

As well as:
Expand Down
4 changes: 1 addition & 3 deletions client/components/data/domain-management/dns/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ module.exports = React.createClass( {
stores={ stores }
getStateFromStores={ getStateFromStores }
selectedDomainName={ this.props.selectedDomainName }
selectedSite={ this.props.sites.getSelectedSite() }>
{ this.props.children }
</StoreConnection>
selectedSite={ this.props.sites.getSelectedSite() } />
);
}
} );
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ const EmailForwardingData = React.createClass( {
stores={ [ EmailForwardingStore ] }
getStateFromStores={ getStateFromStores }
selectedDomainName={ this.props.selectedDomainName }
selectedSite={ this.props.sites.getSelectedSite() }>
{ this.props.children }
</StoreConnection>
selectedSite={ this.props.sites.getSelectedSite() } />
);
}
} );
Expand Down
4 changes: 1 addition & 3 deletions client/components/data/domain-management/email/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ module.exports = React.createClass( {
selectedDomainName={ this.props.selectedDomainName }
selectedSite={ this.props.sites.getSelectedSite() }
context={ this.props.context }
user={ this.props.user }>
{ this.props.children }
</StoreConnection>
user={ this.props.user } />
);
}
} );
8 changes: 5 additions & 3 deletions client/components/data/domain-management/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function getStateFromStores( props ) {
context: props.context,
domains: ( props.selectedSite ? DomainsStore.getForSite( props.selectedSite.ID ) : null ),
products: props.products,
selectedDomainName: props.selectedDomainName,
selectedSite: props.selectedSite
};
}
Expand All @@ -33,6 +34,7 @@ module.exports = React.createClass( {
propTypes: {
context: React.PropTypes.object.isRequired,
productsList: React.PropTypes.object.isRequired,
selectedDomainName: React.PropTypes.string,
sites: React.PropTypes.object.isRequired
},

Expand All @@ -57,13 +59,13 @@ module.exports = React.createClass( {
render: function() {
return (
<StoreConnection
component={ this.props.component }
stores={ stores }
getStateFromStores={ getStateFromStores }
products={ this.props.productsList.get() }
selectedDomainName={ this.props.selectedDomainName }
selectedSite={ this.props.sites.getSelectedSite() }
context={ this.props.context }>
{ this.props.children }
</StoreConnection>
context={ this.props.context } />
);
}
} );
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ const NameserversData = React.createClass( {
stores={ stores }
getStateFromStores={ getStateFromStores }
selectedDomainName={ this.props.selectedDomainName }
selectedSite={ this.props.sites.getSelectedSite() }>
{ this.props.children }
</StoreConnection>
selectedSite={ this.props.sites.getSelectedSite() } />
);
}
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ export default React.createClass( {
stores={ stores }
getStateFromStores={ getStateFromStores }
selectedDomainName={ this.props.selectedDomainName }
selectedSite={ this.props.sites.getSelectedSite() }>
{ this.props.children }
</StoreConnection>
selectedSite={ this.props.sites.getSelectedSite() } />
);
}
} );
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ module.exports = React.createClass( {
stores={ stores }
getStateFromStores={ getStateFromStores }
selectedDomainName={ this.props.selectedDomainName }
selectedSite={ this.props.sites.getSelectedSite() }>
{ this.props.children }
</StoreConnection>
selectedSite={ this.props.sites.getSelectedSite() } />
);
}
} );
4 changes: 1 addition & 3 deletions client/components/data/domain-management/whois/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ module.exports = React.createClass( {
products={ this.props.productsList.get() }
selectedDomainName={ this.props.selectedDomainName }
selectedSite={ this.props.sites.getSelectedSite() }
context={ this.props.context }>
{ this.props.children }
</StoreConnection>
context={ this.props.context } />
);
}
} );
22 changes: 8 additions & 14 deletions client/my-sites/upgrades/domain-management/controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ module.exports = {

renderPage(
<DomainManagementData
component={ DomainManagement.List }
context={ context }
productsList={ productsList }
sites={ sites }>
<DomainManagement.List />
</DomainManagementData>
sites={ sites } />
);
},

Expand All @@ -77,13 +76,11 @@ module.exports = {

renderPage(
<DomainManagementData
component={ DomainManagement.Edit }
context={ context }
productsList={ productsList }
sites={ sites }>
<DomainManagement.Edit
selectedSite={ sites.getSelectedSite() }
selectedDomainName={ context.params.domain } />
</DomainManagementData>
selectedDomainName={ context.params.domain }
sites={ sites } />
);
},

Expand Down Expand Up @@ -263,14 +260,11 @@ module.exports = {

renderPage(
<DomainManagementData
component={ DomainManagement.AddGoogleApps }
context={ context }
productsList={ productsList }
sites={ sites }>
<DomainManagement.AddGoogleApps
productsList={ productsList }
selectedSite={ sites.getSelectedSite() }
selectedDomainName={ context.params.domain } />
</DomainManagementData>
selectedDomainName={ context.params.domain }
sites={ sites } />
);
},

Expand Down

0 comments on commit 01003ce

Please sign in to comment.