Skip to content

Commit

Permalink
Merge pull request #1254 from Automattic/fix/store-and-module-getters
Browse files Browse the repository at this point in the history
Domains: Standardize store and module getters
  • Loading branch information
gziolo committed Dec 8, 2015
2 parents 9b29602 + c088ca9 commit 723cb42
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion client/components/data/domain-management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ The child component should receive processed props defined during the render:
As well as:

* `cart` - products added to the cart, it's the result of a call to `CartStore.get`
* `domains` - a list of domains, it's the result of a call to `DomainsStore.getForSite` for the current site
* `domains` - a list of domains, it's the result of a call to `DomainsStore.getBySite` for the current site

It's updated whenever CartStore`, `DomainStore`, `productsList` or `sites` changes.
2 changes: 1 addition & 1 deletion client/components/data/domain-management/dns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The child component should receive processed props defined during the render:

As well as:

* `domains` - a list of domains, it's the result of a call to `DomainsStore.getForSite` for the current site
* `domains` - a list of domains, it's the result of a call to `DomainsStore.getBySite` for the current site
* `dns` - DNS records, it's the result of a call to `DnsStore.getByDomainName` for the current domain

It's updated whenever `DomainsStore`, `DnsStore` or `sites` changes.
2 changes: 1 addition & 1 deletion client/components/data/domain-management/dns/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getStateFromStores( props ) {
let domains;

if ( props.selectedSite ) {
domains = DomainsStore.getForSite( props.selectedSite.ID );
domains = DomainsStore.getBySite( props.selectedSite.ID );
}

return {
Expand Down
2 changes: 1 addition & 1 deletion client/components/data/domain-management/email/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The child component should receive processed props defined during the render:
As well as:

* `cart` - products added to the cart, it's the result of a call to `CartStore.get`
* `domains` - a list of domains, it's the result of a call to `DomainsStore.getForSite` for the current site
* `domains` - a list of domains, it's the result of a call to `DomainsStore.getBySite` for the current site
* `googleAppsUsers` - Google Apps users, it's the result of a call to `GoogleAppsUsersStore.getByDomainName` for the current domain

It's updated whenever `CartStore`, `DomainsStore`, `GoogleAppsUsersStore`, `productsList` or `sites` changes.
2 changes: 1 addition & 1 deletion client/components/data/domain-management/email/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getStateFromStores( props ) {
let domains;

if ( props.selectedSite ) {
domains = DomainsStore.getForSite( props.selectedSite.ID );
domains = DomainsStore.getBySite( props.selectedSite.ID );
}

return {
Expand Down
2 changes: 1 addition & 1 deletion client/components/data/domain-management/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getStateFromStores( props ) {
return {
cart: CartStore.get(),
context: props.context,
domains: ( props.selectedSite ? DomainsStore.getForSite( props.selectedSite.ID ) : null ),
domains: ( props.selectedSite ? DomainsStore.getBySite( props.selectedSite.ID ) : null ),
products: props.products,
selectedSite: props.selectedSite
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The child component should receive processed props defined during the render:

As well as:

* `domains` - a list of domains, it's the result of a call to `DomainsStore.getForSite` for the current site
* `domains` - a list of domains, it's the result of a call to `DomainsStore.getBySite` for the current site
* `nameservers` - nameservers data, it's the result of a call to `NameserversStore.getByDomainName` for the current domain

It's updated whenever `DomainsStore`, `NameserversStore` or `sites` changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getStateFromStores( props ) {
let domains;

if ( props.selectedSite ) {
domains = DomainsStore.getForSite( props.selectedSite.ID );
domains = DomainsStore.getBySite( props.selectedSite.ID );
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ The child component should receive processed props defined during the render:

As well as:

* `domains` - a list of domains, it's the result of a call to `DomainsStore.getForSite` for the current site
* `domains` - a list of domains, it's the result of a call to `DomainsStore.getBySite` for the current site

It's updated whenever `DomainsStore` or `sites` changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function getStateFromStores( props ) {
let domains;

if ( props.selectedSite ) {
domains = DomainsStore.getForSite( props.selectedSite.ID );
domains = DomainsStore.getBySite( props.selectedSite.ID );
}

return {
Expand Down
4 changes: 2 additions & 2 deletions client/components/data/domain-management/transfer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The child component should receive processed props defined during the render:

As well as:

* `domains` - a list of domains, it's the result of a call to `DomainsStore.getForSite` for the current site
* `wapiDomainInfo` - Wapi domain info, it's the result of a call to `WapiDomainInfoStore.getForSite` for the current site
* `domains` - a list of domains, it's the result of a call to `DomainsStore.getBySite` for the current site
* `wapiDomainInfo` - Wapi domain info, it's the result of a call to `WapiDomainInfoStore.getByDomainName` for the current domain

It's updated whenever `DomainsStore`, `WapiDomainInfoStore` or `sites` changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function getStateFromStores( props ) {
let domains;

if ( props.selectedSite ) {
domains = DomainsStore.getForSite( props.selectedSite.ID );
domains = DomainsStore.getBySite( props.selectedSite.ID );
}

return {
Expand Down
2 changes: 1 addition & 1 deletion client/components/data/domain-management/whois/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The child component should receive processed props defined during the render:

As well as:

* `domains` - a list of domains, it's the result of a call to `DomainsStore.getForSite` for the current site
* `domains` - a list of domains, it's the result of a call to `DomainsStore.getBySite` for the current site
* `whois` - WHOIS contact information, it's the result of a call to `WhoisStore.getByDomainName` for the current domain

It's updated whenever `DomainsStore`, `WhoisStore`, `productsList` or `sites` changes.
2 changes: 1 addition & 1 deletion client/components/data/domain-management/whois/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getStateFromStores( props ) {
let domains;

if ( props.selectedSite ) {
domains = DomainsStore.getForSite( props.selectedSite.ID );
domains = DomainsStore.getBySite( props.selectedSite.ID );
}

return {
Expand Down
4 changes: 2 additions & 2 deletions client/lib/domains/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ It is modelled as a [Flux](https://facebook.github.io/flux/docs/overview.html) s

## Usage

The store is a singleton object which offers `get` and `getForSite` methods to retrieve data:
The store is a singleton object which offers `get` and `getBySite` methods to retrieve data:

```js
import DomainsStore from 'lib/domains/store';

DomainsStore.get()
DomainsStore.getForSite( 'example.wordpress.com' )
DomainsStore.getBySite( 'example.wordpress.com' )
```

To interact with the store, use the actions made available in [`domain-management.js`](../../upgrades/actions/domain-management.js):
Expand Down
6 changes: 3 additions & 3 deletions client/lib/domains/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function reducer( state, payload ) {

case UpgradesActionTypes.DOMAIN_TRANSFER_CODE_REQUEST_COMPLETED:
domainData = getSelectedDomain( {
domains: getForSite( state, action.siteId ),
domains: getBySite( state, action.siteId ),
selectedDomainName: action.domainName
} );
privateDomain = ( ! action.disablePrivacy ) && domainData.privateDomain;
Expand All @@ -108,12 +108,12 @@ function reducer( state, payload ) {
}
}

function getForSite( state, siteId ) {
function getBySite( state, siteId ) {
return state[ siteId ];
}

export {
getForSite,
getBySite,
initialState,
reducer
};
4 changes: 2 additions & 2 deletions client/lib/domains/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* Internal dependencies
*/
import { createReducerStore } from 'lib/store';
import { getForSite, initialState, reducer } from './reducer';
import { getBySite, initialState, reducer } from './reducer';

const DomainsStore = createReducerStore( reducer, initialState );

DomainsStore.getForSite = siteId => getForSite( DomainsStore.get(), siteId );
DomainsStore.getBySite = siteId => getBySite( DomainsStore.get(), siteId );

export default DomainsStore;
2 changes: 1 addition & 1 deletion client/lib/domains/wapi-domain-info/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function reducer( state, payload ) {
case UpgradesActionTypes.DOMAIN_TRANSFER_CODE_REQUEST_COMPLETED:
const { data } = state[ action.domainName ],
domainData = getSelectedDomain( {
domains: DomainsStore.getForSite( action.siteId ),
domains: DomainsStore.getBySite( action.siteId ),
selectedDomainName: action.domainName
} ),
locked = ( ! action.unlock ) && data.locked,
Expand Down
2 changes: 1 addition & 1 deletion client/lib/states-list/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The following public methods are available:

This fetches the corresponding list of states from the server. The list is cached in the store upon retrieval.

### `getForCountry( countryCode )`
### `getByCountry( countryCode )`

This retrieves the list of states as a set of key and value pairs. The list is loaded from the store and then fetched once from the server to update any stale data.

Expand Down
2 changes: 1 addition & 1 deletion client/lib/states-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ StatesList.prototype.fetchForCountry = function( countryCode ) {
* @param {string} countryCode - country code
* @returns {object} the list of states
*/
StatesList.prototype.getForCountry = function( countryCode ) {
StatesList.prototype.getByCountry = function( countryCode ) {
var data;

if ( ! this.data ) {
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/current-site/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module.exports = React.createClass( {
},

getDomainExpirationNotices: function() {
let domainStore = this.state.domainsStore.getForSite( this.getSelectedSite().ID ),
let domainStore = this.state.domainsStore.getBySite( this.getSelectedSite().ID ),
domains = domainStore && domainStore.list || [];
return (
<DomainWarnings
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/upgrades/components/form/state-select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = React.createClass( {
focus: this.state.focus,
invalid: this.props.invalid
} ),
statesList = this.props.statesList.getForCountry( this.props.countryCode ),
statesList = this.props.statesList.getByCountry( this.props.countryCode ),
options = [];

if ( isEmpty( statesList ) ) {
Expand Down

0 comments on commit 723cb42

Please sign in to comment.