From 44cc68f8bb7da02e266515462bbd27ff3d6642a4 Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Fri, 17 Apr 2020 13:46:46 +0200 Subject: [PATCH] feat: disabled options and empty subscribers info in select --- src/editor/sidebar/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/editor/sidebar/index.js b/src/editor/sidebar/index.js index 3a47d519b..7fb75fb83 100644 --- a/src/editor/sidebar/index.js +++ b/src/editor/sidebar/index.js @@ -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 = { @@ -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, } ); } ); }