Skip to content

Commit 85958e2

Browse files
committed
added links to subscription and license management
1 parent 84d1bbd commit 85958e2

2 files changed

Lines changed: 116 additions & 24 deletions

File tree

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 subscriptionLinks = callout.find('EuiButton');
128+
expect(subscriptionLinks).toHaveLength(2);
129+
130+
const [linkToSubscribePage, linkToManageLicense] = subscriptionLinks.getElements();
131+
132+
expect(linkToSubscribePage.props.href).toMatchInlineSnapshot(
133+
`"https://www.elastic.co/subscriptions"`
134+
);
135+
expect(linkToManageLicense.props.href).toMatchInlineSnapshot(
136+
`"/app/kibana#/management/elasticsearch/license_management/"`
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: 37 additions & 9 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,7 +276,7 @@ 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',
@@ -281,11 +288,32 @@ const upgradeYourLicenseCallOut = (
281288
defaultMessage="With an upgraded license, you have the option to connect to more 3rd party services."
282289
/>
283290
<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>
291+
<EuiFlexGroup gutterSize="s" wrap={true}>
292+
<EuiFlexItem grow={false}>
293+
<EuiButton
294+
href={VIEW_LICENSE_OPTIONS_LINK}
295+
iconType="popout"
296+
iconSide="right"
297+
target="_blank"
298+
>
299+
<FormattedMessage
300+
id="xpack.triggersActionsUI.sections.actionConnectorAdd.upgradeYourPlanBannerLinkTitle"
301+
defaultMessage="Upgrade now"
302+
/>
303+
</EuiButton>
304+
</EuiFlexItem>
305+
<EuiFlexItem grow={false}>
306+
<EuiButton
307+
href={`${http.basePath.get()}/app/kibana#${LICENSE_MANAGEMENT_BASE_PATH}`}
308+
iconType="gear"
309+
target="_blank"
310+
>
311+
<FormattedMessage
312+
id="xpack.triggersActionsUI.sections.actionConnectorAdd.manageLicensePlanBannerLinkTitle"
313+
defaultMessage="Manage license"
314+
/>
315+
</EuiButton>
316+
</EuiFlexItem>
317+
</EuiFlexGroup>
290318
</EuiCallOut>
291319
);

0 commit comments

Comments
 (0)