diff --git a/assets/js/src/listing/listing.jsx b/assets/js/src/listing/listing.jsx index 1576e67d37..d1c565f6a4 100644 --- a/assets/js/src/listing/listing.jsx +++ b/assets/js/src/listing/listing.jsx @@ -72,14 +72,11 @@ const ListingItem = React.createClass({ if (action.name === 'trash') { customAction = ( - + {(!isFirst) ? ' | ' : ''} this.handleTrashItem(this.props.item.id)} > {MailPoet.I18n.t('moveToTrash')} @@ -89,7 +86,8 @@ const ListingItem = React.createClass({ customAction = ( @@ -100,7 +98,8 @@ const ListingItem = React.createClass({ } else if (action.link) { customAction = ( {(!isFirst) ? ' | ' : ''} { action.link(this.props.item) } @@ -109,17 +108,17 @@ const ListingItem = React.createClass({ } else { customAction = ( {(!isFirst) ? ' | ' : ''} - action.onClick(this.props.item, this.props.onRefreshItems) + : false + } >{ action.label } ); @@ -148,10 +147,7 @@ const ListingItem = React.createClass({ this.handleRestoreItem(this.props.item.id)} >{MailPoet.I18n.t('restore')} { ' | ' } @@ -159,16 +155,14 @@ const ListingItem = React.createClass({ this.handleDeleteItem(this.props.item.id)} >{MailPoet.I18n.t('deletePermanently')} @@ -181,8 +175,9 @@ const ListingItem = React.createClass({ { itemActions } @@ -269,7 +264,7 @@ const ListingItems = React.createClass({ - {this.props.items.map((item, index) => { + {this.props.items.map((item) => { const renderItem = item; renderItem.id = parseInt(item.id, 10); renderItem.selected = (this.props.selected_ids.indexOf(renderItem.id) !== -1); @@ -287,7 +282,7 @@ const ListingItems = React.createClass({ is_selectable={this.props.is_selectable} item_actions={this.props.item_actions} group={this.props.group} - key={`item-${renderItem.id}-${index}`} + key={`item-${renderItem.id}-${item.id}`} item={renderItem} /> ); @@ -439,23 +434,25 @@ const Listing = React.createClass({ return ret; }, componentDidMount: function componentDidMount() { - if (this.isMounted()) { - const params = this.props.params || {}; - this.initWithParams(params); + this.isComponentMounted = true; + const params = this.props.params || {}; + this.initWithParams(params); - if (this.props.auto_refresh) { - jQuery(document).on('heartbeat-tick.mailpoet', () => { - this.getItems(); - }); - } + if (this.props.auto_refresh) { + jQuery(document).on('heartbeat-tick.mailpoet', () => { + this.getItems(); + }); } }, + componentWillUnmount: function componentWillUnmount() { + this.isComponentMounted = false; + }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { const params = nextProps.params || {}; this.initWithParams(params); }, getItems: function getItems() { - if (this.isMounted()) { + if (this.isComponentMounted) { this.setState({ loading: true }); this.clearSelection();