Fixed callouts (#115631)

This commit is contained in:
Jason Stoltzfus 2021-10-20 13:55:43 -04:00 committed by GitHub
parent fe471cea57
commit 1da11dfdc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -26,6 +26,8 @@ const MOCK_VALUES = {
},
},
},
// LicensingLogic
hasPlatinumLicense: true,
};
describe('SuggestedCurationsCallout', () => {
@ -56,4 +58,14 @@ describe('SuggestedCurationsCallout', () => {
expect(wrapper.isEmptyRender()).toBe(true);
});
it('is empty when the user has no platinum license', () => {
// This would happen if the user *had* suggestions and then downgraded from platinum to gold or something
const values = set('hasPlatinumLicense', false, MOCK_VALUES);
setMockValues(values);
const wrapper = shallow(<SuggestedCurationsCallout />);
expect(wrapper.isEmptyRender()).toBe(true);
});
});

View file

@ -10,6 +10,7 @@ import { useValues } from 'kea';
import { i18n } from '@kbn/i18n';
import { LicensingLogic } from '../../../../shared/licensing';
import { ENGINE_CURATIONS_PATH } from '../../../routes';
import { SuggestionsCallout } from '../../curations/components/suggestions_callout';
import { EngineLogic, generateEnginePath } from '../../engine';
@ -18,10 +19,15 @@ export const SuggestedCurationsCallout: React.FC = () => {
const {
engine: { search_relevance_suggestions: searchRelevanceSuggestions },
} = useValues(EngineLogic);
const { hasPlatinumLicense } = useValues(LicensingLogic);
const pendingCount = searchRelevanceSuggestions?.curation.pending;
if (typeof searchRelevanceSuggestions === 'undefined' || pendingCount === 0) {
if (
typeof searchRelevanceSuggestions === 'undefined' ||
pendingCount === 0 ||
hasPlatinumLicense === false
) {
return null;
}