Skip to content

Commit 12a5889

Browse files
authored
[Alerting] Add "Start trial" button for connectors (#61774)
When Kibana is certain actions (connectors) disabled due to insufficient licensing we now display buttons that lead to both the Subscriptions page and the License Management page (where the user can start a trial).
1 parent a058636 commit 12a5889

File tree

2 files changed

+119
-27
lines changed

2 files changed

+119
-27
lines changed

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx

Lines changed: 79 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,7 @@ describe('connector_add_flyout', () => {
4242
});
4343

4444
it('renders action type menu on flyout open', () => {
45-
const actionType = {
46-
id: 'my-action-type',
47-
iconClass: 'test',
48-
selectMessage: 'test',
49-
validateConnector: (): ValidationResult => {
50-
return { errors: {} };
51-
},
52-
validateParams: (): ValidationResult => {
53-
const validationResult = { errors: {} };
54-
return validationResult;
55-
},
56-
actionConnectorFields: null,
57-
actionParamsFields: null,
58-
};
45+
const actionType = createActionType();
5946
actionTypeRegistry.get.mockReturnValueOnce(actionType);
6047
actionTypeRegistry.has.mockReturnValue(true);
6148

@@ -88,6 +75,83 @@ describe('connector_add_flyout', () => {
8875
</ActionsConnectorsContextProvider>
8976
);
9077
expect(wrapper.find('ActionTypeMenu')).toHaveLength(1);
91-
expect(wrapper.find('[data-test-subj="my-action-type-card"]').exists()).toBeTruthy();
78+
expect(wrapper.find(`[data-test-subj="${actionType.id}-card"]`).exists()).toBeTruthy();
79+
});
80+
81+
it('renders banner with subscription links when features are disbaled due to licensing ', () => {
82+
const actionType = createActionType();
83+
const disabledActionType = createActionType();
84+
85+
actionTypeRegistry.get.mockReturnValueOnce(actionType);
86+
actionTypeRegistry.has.mockReturnValue(true);
87+
88+
const wrapper = mountWithIntl(
89+
<ActionsConnectorsContextProvider
90+
value={{
91+
http: deps!.http,
92+
toastNotifications: deps!.toastNotifications,
93+
actionTypeRegistry: deps!.actionTypeRegistry,
94+
capabilities: deps!.capabilities,
95+
reloadConnectors: () => {
96+
return new Promise<void>(() => {});
97+
},
98+
}}
99+
>
100+
<ConnectorAddFlyout
101+
addFlyoutVisible={true}
102+
setAddFlyoutVisibility={() => {}}
103+
actionTypes={[
104+
{
105+
id: actionType.id,
106+
enabled: true,
107+
name: 'Test',
108+
enabledInConfig: true,
109+
enabledInLicense: true,
110+
minimumLicenseRequired: 'basic',
111+
},
112+
{
113+
id: disabledActionType.id,
114+
enabled: true,
115+
name: 'Test',
116+
enabledInConfig: true,
117+
enabledInLicense: false,
118+
minimumLicenseRequired: 'gold',
119+
},
120+
]}
121+
/>
122+
</ActionsConnectorsContextProvider>
123+
);
124+
const callout = wrapper.find('UpgradeYourLicenseCallOut');
125+
expect(callout).toHaveLength(1);
126+
127+
const manageLink = callout.find('EuiButton');
128+
expect(manageLink).toHaveLength(1);
129+
expect(manageLink.getElements()[0].props.href).toMatchInlineSnapshot(
130+
`"/app/kibana#/management/elasticsearch/license_management/"`
131+
);
132+
133+
const subscriptionLink = callout.find('EuiButtonEmpty');
134+
expect(subscriptionLink).toHaveLength(1);
135+
expect(subscriptionLink.getElements()[0].props.href).toMatchInlineSnapshot(
136+
`"https://www.elastic.co/subscriptions"`
137+
);
92138
});
93139
});
140+
141+
let count = 0;
142+
function createActionType() {
143+
return {
144+
id: `my-action-type-${++count}`,
145+
iconClass: 'test',
146+
selectMessage: 'test',
147+
validateConnector: (): ValidationResult => {
148+
return { errors: {} };
149+
},
150+
validateParams: (): ValidationResult => {
151+
const validationResult = { errors: {} };
152+
return validationResult;
153+
},
154+
actionConnectorFields: null,
155+
actionParamsFields: null,
156+
};
157+
}

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.tsx

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import {
1919
EuiFlyoutBody,
2020
EuiBetaBadge,
2121
EuiCallOut,
22-
EuiLink,
2322
EuiSpacer,
2423
} from '@elastic/eui';
24+
import { HttpSetup } from 'kibana/public';
2525
import { i18n } from '@kbn/i18n';
2626
import { ActionTypeMenu } from './action_type_menu';
2727
import { ActionConnectorForm, validateBaseProperties } from './action_connector_form';
@@ -32,6 +32,7 @@ import { createActionConnector } from '../../lib/action_connector_api';
3232
import { useActionsConnectorsContext } from '../../context/actions_connectors_context';
3333
import { VIEW_LICENSE_OPTIONS_LINK } from '../../../common/constants';
3434
import { PLUGIN } from '../../constants/plugin';
35+
import { BASE_PATH as LICENSE_MANAGEMENT_BASE_PATH } from '../../../../../license_management/common/constants';
3536

3637
export interface ConnectorAddFlyoutProps {
3738
addFlyoutVisible: boolean;
@@ -217,7 +218,13 @@ export const ConnectorAddFlyout = ({
217218
</EuiFlexGroup>
218219
</EuiFlyoutHeader>
219220
<EuiFlyoutBody
220-
banner={!actionType && hasActionsDisabledByLicense && upgradeYourLicenseCallOut}
221+
banner={
222+
!actionType && hasActionsDisabledByLicense ? (
223+
<UpgradeYourLicenseCallOut http={http} />
224+
) : (
225+
<Fragment />
226+
)
227+
}
221228
>
222229
{currentForm}
223230
</EuiFlyoutBody>
@@ -269,23 +276,44 @@ export const ConnectorAddFlyout = ({
269276
);
270277
};
271278

272-
const upgradeYourLicenseCallOut = (
279+
const UpgradeYourLicenseCallOut = ({ http }: { http: HttpSetup }) => (
273280
<EuiCallOut
274281
title={i18n.translate(
275282
'xpack.triggersActionsUI.sections.actionConnectorAdd.upgradeYourPlanBannerTitle',
276-
{ defaultMessage: 'Upgrade your plan to access more connector types' }
283+
{ defaultMessage: 'Upgrade your license to access all connectors' }
277284
)}
278285
>
279286
<FormattedMessage
280287
id="xpack.triggersActionsUI.sections.actionConnectorAdd.upgradeYourPlanBannerMessage"
281-
defaultMessage="With an upgraded license, you have the option to connect to more 3rd party services."
288+
defaultMessage="Upgrade your license or start a 30-day free trial for immediate access to all third-party connectors."
282289
/>
283-
<EuiSpacer size="xs" />
284-
<EuiLink href={VIEW_LICENSE_OPTIONS_LINK} target="_blank">
285-
<FormattedMessage
286-
id="xpack.triggersActionsUI.sections.actionConnectorAdd.upgradeYourPlanBannerLinkTitle"
287-
defaultMessage="Upgrade now"
288-
/>
289-
</EuiLink>
290+
<EuiSpacer size="s" />
291+
<EuiFlexGroup gutterSize="s" wrap={true}>
292+
<EuiFlexItem grow={false}>
293+
<EuiButton
294+
href={`${http.basePath.get()}/app/kibana#${LICENSE_MANAGEMENT_BASE_PATH}`}
295+
iconType="gear"
296+
target="_blank"
297+
>
298+
<FormattedMessage
299+
id="xpack.triggersActionsUI.sections.actionConnectorAdd.manageLicensePlanBannerLinkTitle"
300+
defaultMessage="Manage license"
301+
/>
302+
</EuiButton>
303+
</EuiFlexItem>
304+
<EuiFlexItem grow={false}>
305+
<EuiButtonEmpty
306+
href={VIEW_LICENSE_OPTIONS_LINK}
307+
iconType="popout"
308+
iconSide="right"
309+
target="_blank"
310+
>
311+
<FormattedMessage
312+
id="xpack.triggersActionsUI.sections.actionConnectorAdd.upgradeYourPlanBannerLinkTitle"
313+
defaultMessage="Subscription plans"
314+
/>
315+
</EuiButtonEmpty>
316+
</EuiFlexItem>
317+
</EuiFlexGroup>
290318
</EuiCallOut>
291319
);

0 commit comments

Comments
 (0)