2021-06-25 13:28:54 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { openDialog } from '../base/dialog';
|
|
|
|
|
|
|
|
import { PremiumFeatureDialog } from './components';
|
2021-08-20 08:36:09 +00:00
|
|
|
import { isFeatureDisabled } from './functions';
|
2021-06-25 13:28:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows a dialog prompting users to upgrade, if requested feature is disabled.
|
|
|
|
*
|
|
|
|
* @param {string} feature - The feature to check availability for.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function maybeShowPremiumFeatureDialog(feature: string) {
|
|
|
|
return function(dispatch: Function, getState: Function) {
|
|
|
|
if (isFeatureDisabled(getState(), feature)) {
|
|
|
|
dispatch(openDialog(PremiumFeatureDialog));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}
|