[Alerting] only show trial upgrade when running with basic license (#64865)
resolves https://github.com/elastic/kibana/issues/64245 Prior to this PR, the "Upgrade your license" banner in the connectors list was displayed for gold licenses because the Service Now action requires platinum, and the check only looked for any actions disabled by license. Rather than display a different message for gold users, this PR changes the banner display logic to check for any actions disabled by license that also have a minimum required license of gold. That means gold+ users won't see the message, even for actions with a minimum required license of platinum+. Another perk of the gold license! This will continue to display the banner for basic users, but will no longer display it for gold users. It also continues to not display it for trial, platinum and enterprise users.
This commit is contained in:
parent
fb30a822b3
commit
4788754419
|
@ -16,13 +16,13 @@ import { checkActionTypeEnabled } from '../../lib/check_action_type_enabled';
|
|||
interface Props {
|
||||
onActionTypeChange: (actionType: ActionType) => void;
|
||||
actionTypes?: ActionType[];
|
||||
setHasActionsDisabledByLicense?: (value: boolean) => void;
|
||||
setHasActionsUpgradeableByTrial?: (value: boolean) => void;
|
||||
}
|
||||
|
||||
export const ActionTypeMenu = ({
|
||||
onActionTypeChange,
|
||||
actionTypes,
|
||||
setHasActionsDisabledByLicense,
|
||||
setHasActionsUpgradeableByTrial,
|
||||
}: Props) => {
|
||||
const { http, toastNotifications, actionTypeRegistry } = useActionsConnectorsContext();
|
||||
const [actionTypesIndex, setActionTypesIndex] = useState<ActionTypeIndex | undefined>(undefined);
|
||||
|
@ -36,11 +36,15 @@ export const ActionTypeMenu = ({
|
|||
index[actionTypeItem.id] = actionTypeItem;
|
||||
}
|
||||
setActionTypesIndex(index);
|
||||
if (setHasActionsDisabledByLicense) {
|
||||
const hasActionsDisabledByLicense = availableActionTypes.some(
|
||||
action => !index[action.id].enabledInLicense
|
||||
// determine if there are actions disabled by license that that
|
||||
// would be enabled by upgrading to gold or trial
|
||||
if (setHasActionsUpgradeableByTrial) {
|
||||
const hasActionsUpgradeableByTrial = availableActionTypes.some(
|
||||
action =>
|
||||
!index[action.id].enabledInLicense &&
|
||||
index[action.id].minimumLicenseRequired === 'gold'
|
||||
);
|
||||
setHasActionsDisabledByLicense(hasActionsDisabledByLicense);
|
||||
setHasActionsUpgradeableByTrial(hasActionsUpgradeableByTrial);
|
||||
}
|
||||
} catch (e) {
|
||||
if (toastNotifications) {
|
||||
|
|
|
@ -78,7 +78,7 @@ describe('connector_add_flyout', () => {
|
|||
expect(wrapper.find(`[data-test-subj="${actionType.id}-card"]`).exists()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('renders banner with subscription links when features are disbaled due to licensing ', () => {
|
||||
it('renders banner with subscription links when gold features are disabled due to licensing ', () => {
|
||||
const actionType = createActionType();
|
||||
const disabledActionType = createActionType();
|
||||
|
||||
|
@ -136,6 +136,100 @@ describe('connector_add_flyout', () => {
|
|||
`"https://www.elastic.co/subscriptions"`
|
||||
);
|
||||
});
|
||||
|
||||
it('does not render banner with subscription links when only platinum features are disabled due to licensing ', () => {
|
||||
const actionType = createActionType();
|
||||
const disabledActionType = createActionType();
|
||||
|
||||
actionTypeRegistry.get.mockReturnValueOnce(actionType);
|
||||
actionTypeRegistry.has.mockReturnValue(true);
|
||||
|
||||
const wrapper = mountWithIntl(
|
||||
<ActionsConnectorsContextProvider
|
||||
value={{
|
||||
http: deps!.http,
|
||||
toastNotifications: deps!.toastNotifications,
|
||||
actionTypeRegistry: deps!.actionTypeRegistry,
|
||||
capabilities: deps!.capabilities,
|
||||
reloadConnectors: () => {
|
||||
return new Promise<void>(() => {});
|
||||
},
|
||||
}}
|
||||
>
|
||||
<ConnectorAddFlyout
|
||||
addFlyoutVisible={true}
|
||||
setAddFlyoutVisibility={() => {}}
|
||||
actionTypes={[
|
||||
{
|
||||
id: actionType.id,
|
||||
enabled: true,
|
||||
name: 'Test',
|
||||
enabledInConfig: true,
|
||||
enabledInLicense: true,
|
||||
minimumLicenseRequired: 'basic',
|
||||
},
|
||||
{
|
||||
id: disabledActionType.id,
|
||||
enabled: true,
|
||||
name: 'Test',
|
||||
enabledInConfig: true,
|
||||
enabledInLicense: false,
|
||||
minimumLicenseRequired: 'platinum',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</ActionsConnectorsContextProvider>
|
||||
);
|
||||
const callout = wrapper.find('UpgradeYourLicenseCallOut');
|
||||
expect(callout).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('does not render banner with subscription links when only enterprise features are disabled due to licensing ', () => {
|
||||
const actionType = createActionType();
|
||||
const disabledActionType = createActionType();
|
||||
|
||||
actionTypeRegistry.get.mockReturnValueOnce(actionType);
|
||||
actionTypeRegistry.has.mockReturnValue(true);
|
||||
|
||||
const wrapper = mountWithIntl(
|
||||
<ActionsConnectorsContextProvider
|
||||
value={{
|
||||
http: deps!.http,
|
||||
toastNotifications: deps!.toastNotifications,
|
||||
actionTypeRegistry: deps!.actionTypeRegistry,
|
||||
capabilities: deps!.capabilities,
|
||||
reloadConnectors: () => {
|
||||
return new Promise<void>(() => {});
|
||||
},
|
||||
}}
|
||||
>
|
||||
<ConnectorAddFlyout
|
||||
addFlyoutVisible={true}
|
||||
setAddFlyoutVisibility={() => {}}
|
||||
actionTypes={[
|
||||
{
|
||||
id: actionType.id,
|
||||
enabled: true,
|
||||
name: 'Test',
|
||||
enabledInConfig: true,
|
||||
enabledInLicense: true,
|
||||
minimumLicenseRequired: 'basic',
|
||||
},
|
||||
{
|
||||
id: disabledActionType.id,
|
||||
enabled: true,
|
||||
name: 'Test',
|
||||
enabledInConfig: true,
|
||||
enabledInLicense: false,
|
||||
minimumLicenseRequired: 'enterprise',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</ActionsConnectorsContextProvider>
|
||||
);
|
||||
const callout = wrapper.find('UpgradeYourLicenseCallOut');
|
||||
expect(callout).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
let count = 0;
|
||||
|
|
|
@ -54,7 +54,7 @@ export const ConnectorAddFlyout = ({
|
|||
reloadConnectors,
|
||||
} = useActionsConnectorsContext();
|
||||
const [actionType, setActionType] = useState<ActionType | undefined>(undefined);
|
||||
const [hasActionsDisabledByLicense, setHasActionsDisabledByLicense] = useState<boolean>(false);
|
||||
const [hasActionsUpgradeableByTrial, setHasActionsUpgradeableByTrial] = useState<boolean>(false);
|
||||
|
||||
// hooks
|
||||
const initialConnector = {
|
||||
|
@ -96,7 +96,7 @@ export const ConnectorAddFlyout = ({
|
|||
<ActionTypeMenu
|
||||
onActionTypeChange={onActionTypeChange}
|
||||
actionTypes={actionTypes}
|
||||
setHasActionsDisabledByLicense={setHasActionsDisabledByLicense}
|
||||
setHasActionsUpgradeableByTrial={setHasActionsUpgradeableByTrial}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
|
@ -219,7 +219,7 @@ export const ConnectorAddFlyout = ({
|
|||
</EuiFlyoutHeader>
|
||||
<EuiFlyoutBody
|
||||
banner={
|
||||
!actionType && hasActionsDisabledByLicense ? (
|
||||
!actionType && hasActionsUpgradeableByTrial ? (
|
||||
<UpgradeYourLicenseCallOut http={http} />
|
||||
) : (
|
||||
<Fragment />
|
||||
|
|
Loading…
Reference in a new issue