Skip to content

Commit

Permalink
feat: disabled options and empty subscribers info in select
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek committed Apr 17, 2020
1 parent d8f8802 commit 44cc68f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/editor/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ class Sidebar extends Component {
apiFetch( params ).then( result => this.setStateFromAPIResponse( result ) );
};
setInterest = interestId => {
if ( ! interestId || 'interest_group' === interestId ) {
return;
}
this.setState( { inFlight: true } );
const { postId } = this.props;
const params = {
Expand Down Expand Up @@ -135,13 +132,18 @@ class Sidebar extends Component {
const { title, interests, id } = item;
accumulator.push( {
label: title,
value: 'interest_group',
disabled: true,
} );
if ( interests && interests.interests && interests.interests.length ) {
interests.interests.forEach( interest => {
const isDisabled = parseInt( interest.subscriber_count ) === 0;
accumulator.push( {
label: '- ' + interest.name,
label:
'- ' +
interest.name +
( isDisabled ? __( ' (no subscribers)', 'newspack-newsletters' ) : '' ),
value: 'interests-' + id + ':' + interest.id,
disabled: isDisabled,
} );
} );
}
Expand Down

0 comments on commit 44cc68f

Please sign in to comment.