Skip to content

Commit

Permalink
apply codemod: assign-component-to-displayname-variable to client/ fo…
Browse files Browse the repository at this point in the history
…lder (Automattic#18878)

* apply codemod: assign-component-to-displayname-variable to client/ folder

* npm run reformat-files
  • Loading branch information
samouri authored Oct 18, 2017
1 parent 2cea185 commit e4a4423
Show file tree
Hide file tree
Showing 115 changed files with 10,611 additions and 10,647 deletions.
126 changes: 63 additions & 63 deletions client/blocks/author-selector/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,66 +246,66 @@ const SwitcherShell = localize(
} )
);

export default localize(
React.createClass( {
displayName: 'AuthorSelector',
propTypes: {
siteId: PropTypes.number.isRequired,
onSelect: PropTypes.func,
exclude: PropTypes.arrayOf( PropTypes.number ),
allowSingleUser: PropTypes.bool,
popoverPosition: PropTypes.string,
},

getInitialState: function() {
return {
search: '',
};
},

getDefaultProps: function() {
return {
showAuthorMenu: false,
onClose: function() {},
allowSingleUser: false,
popoverPosition: 'bottom left',
};
},

componentDidMount: function() {
debug( 'AuthorSelector mounted' );
},

render: function() {
let searchString = this.state.search || '';
searchString = trim( searchString );

const fetchOptions = {
siteId: this.props.siteId,
order: 'ASC',
order_by: 'display_name',
number: 50,
};

if ( searchString ) {
fetchOptions.number = 20; // make search a little faster
fetchOptions.search = searchString;
fetchOptions.search_columns = [ 'user_login', 'display_name' ];
}

Object.freeze( fetchOptions );
return (
<SiteUsersFetcher fetchOptions={ fetchOptions } exclude={ this.props.exclude }>
<SwitcherShell { ...this.props } updateSearch={ this._updateSearch } />
</SiteUsersFetcher>
);
},

_updateSearch: function( searchTerm ) {
searchTerm = searchTerm ? '*' + searchTerm + '*' : '';
this.setState( {
search: searchTerm,
} );
},
} )
);
const AuthorSelector = React.createClass( {
displayName: 'AuthorSelector',
propTypes: {
siteId: PropTypes.number.isRequired,
onSelect: PropTypes.func,
exclude: PropTypes.arrayOf( PropTypes.number ),
allowSingleUser: PropTypes.bool,
popoverPosition: PropTypes.string,
},

getInitialState: function() {
return {
search: '',
};
},

getDefaultProps: function() {
return {
showAuthorMenu: false,
onClose: function() {},
allowSingleUser: false,
popoverPosition: 'bottom left',
};
},

componentDidMount: function() {
debug( 'AuthorSelector mounted' );
},

render: function() {
let searchString = this.state.search || '';
searchString = trim( searchString );

const fetchOptions = {
siteId: this.props.siteId,
order: 'ASC',
order_by: 'display_name',
number: 50,
};

if ( searchString ) {
fetchOptions.number = 20; // make search a little faster
fetchOptions.search = searchString;
fetchOptions.search_columns = [ 'user_login', 'display_name' ];
}

Object.freeze( fetchOptions );
return (
<SiteUsersFetcher fetchOptions={ fetchOptions } exclude={ this.props.exclude }>
<SwitcherShell { ...this.props } updateSearch={ this._updateSearch } />
</SiteUsersFetcher>
);
},

_updateSearch: function( searchTerm ) {
searchTerm = searchTerm ? '*' + searchTerm + '*' : '';
this.setState( {
search: searchTerm,
} );
},
} );

export default localize( AuthorSelector );
21 changes: 5 additions & 16 deletions client/blocks/post-item/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,14 @@ class PostItem extends React.Component {
}

hasMultipleUsers() {
return (
this.inAllSitesModeWithMultipleUsers() ||
this.inSingleSiteModeWithMultipleUsers()
);
return this.inAllSitesModeWithMultipleUsers() || this.inSingleSiteModeWithMultipleUsers();
}

renderSelectionCheckbox() {
const { multiSelectEnabled, isCurrentPostSelected } = this.props;
return (
multiSelectEnabled && (
<div
className="post-item__select"
onClick={ this.toggleCurrentPostSelection }
>
<div className="post-item__select" onClick={ this.toggleCurrentPostSelection }>
<FormInputCheckbox
checked={ isCurrentPostSelected }
onClick={ this.toggleCurrentPostSelection }
Expand Down Expand Up @@ -125,8 +119,7 @@ class PostItem extends React.Component {
'has-wrapped-title': wrapTitle,
} );

const isSiteInfoVisible =
isEnabled( 'posts/post-type-list' ) && isAllSitesModeSelected;
const isSiteInfoVisible = isEnabled( 'posts/post-type-list' ) && isAllSitesModeSelected;

const isAuthorVisible =
isEnabled( 'posts/post-type-list' ) &&
Expand All @@ -148,12 +141,8 @@ class PostItem extends React.Component {
{ this.renderSelectionCheckbox() }
<div className="post-item__detail">
<div className="post-item__info">
{ isSiteInfoVisible && (
<PostTypeSiteInfo globalId={ globalId } />
) }
{ isAuthorVisible && (
<PostTypePostAuthor globalId={ globalId } />
) }
{ isSiteInfoVisible && <PostTypeSiteInfo globalId={ globalId } /> }
{ isAuthorVisible && <PostTypePostAuthor globalId={ globalId } /> }
</div>
<h1 className="post-item__title">
<a href={ editUrl } className="post-item__title-link">
Expand Down
82 changes: 41 additions & 41 deletions client/blocks/term-tree-selector/no-results.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,44 @@ import { localize } from 'i18n-calypso';
import React from 'react';
import PureRenderMixin from 'react-pure-render/mixin';

export default localize(
React.createClass( {
displayName: 'TermTreeSelectorNoResults',

mixins: [ PureRenderMixin ],

propTypes: {
createLink: PropTypes.string,
},

render() {
const { createLink } = this.props;
let createMessage;

if ( createLink ) {
createMessage = this.props.translate( 'You may want to {{a}}create a new item{{/a}}.', {
context: 'Term Selector: term search/listing results',
comment:
'This is used when no terms match the given search, or if there are no terms at all.',
components: {
a: (
<a
className="create-link"
href={ createLink }
target="_blank"
rel="noopener noreferrer"
/>
),
},
} );
}

return (
<span className="is-empty-content">
{ this.props.translate( 'No results. Please try a different search.' ) }
&nbsp;{ createMessage }
</span>
);
},
} )
);
const TermTreeSelectorNoResults = React.createClass( {
displayName: 'TermTreeSelectorNoResults',

mixins: [ PureRenderMixin ],

propTypes: {
createLink: PropTypes.string,
},

render() {
const { createLink } = this.props;
let createMessage;

if ( createLink ) {
createMessage = this.props.translate( 'You may want to {{a}}create a new item{{/a}}.', {
context: 'Term Selector: term search/listing results',
comment:
'This is used when no terms match the given search, or if there are no terms at all.',
components: {
a: (
<a
className="create-link"
href={ createLink }
target="_blank"
rel="noopener noreferrer"
/>
),
},
} );
}

return (
<span className="is-empty-content">
{ this.props.translate( 'No results. Please try a different search.' ) }
&nbsp;{ createMessage }
</span>
);
},
} );

export default localize( TermTreeSelectorNoResults );
44 changes: 22 additions & 22 deletions client/blocks/term-tree-selector/search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ import { localize } from 'i18n-calypso';
import React from 'react';
import Gridicon from 'gridicons';

export default localize(
React.createClass( {
displayName: 'TermTreeSelectorSearch',
const TermTreeSelectorSearch = React.createClass( {
displayName: 'TermTreeSelectorSearch',

propTypes: {
searchTerm: PropTypes.string,
onSearch: PropTypes.func.isRequired,
},
propTypes: {
searchTerm: PropTypes.string,
onSearch: PropTypes.func.isRequired,
},

render() {
return (
<div className="term-tree-selector__search">
<Gridicon icon="search" size={ 18 } />
<input
type="search"
placeholder={ this.props.translate( 'Search…', { textOnly: true } ) }
value={ this.props.searchTerm }
onChange={ this.props.onSearch }
/>
</div>
);
},
} )
);
render() {
return (
<div className="term-tree-selector__search">
<Gridicon icon="search" size={ 18 } />
<input
type="search"
placeholder={ this.props.translate( 'Search…', { textOnly: true } ) }
value={ this.props.searchTerm }
onChange={ this.props.onSearch }
/>
</div>
);
},
} );

export default localize( TermTreeSelectorSearch );
Loading

0 comments on commit e4a4423

Please sign in to comment.