Skip to content

Commit 43a055f

Browse files
[ILM] Minor copy and link additions to cloud CTA for cold phase (#80512)
* Add CTA for warm phase too - add/updated component integration tests for checking callouts - sharing deployment url from cloud plugin * update comment * fix i18n * scope changes to cold phase only Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent cd19bd3 commit 43a055f

File tree

4 files changed

+53
-22
lines changed

4 files changed

+53
-22
lines changed

x-pack/plugins/cloud/public/plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface CloudSetupDependencies {
2222

2323
export interface CloudSetup {
2424
cloudId?: string;
25+
cloudDeploymentUrl?: string;
2526
isCloudEnabled: boolean;
2627
}
2728

@@ -33,7 +34,7 @@ export class CloudPlugin implements Plugin<CloudSetup> {
3334
}
3435

3536
public async setup(core: CoreSetup, { home }: CloudSetupDependencies) {
36-
const { id, resetPasswordUrl } = this.config;
37+
const { id, resetPasswordUrl, deploymentUrl } = this.config;
3738
const isCloudEnabled = getIsCloudEnabled(id);
3839

3940
if (home) {
@@ -45,6 +46,7 @@ export class CloudPlugin implements Plugin<CloudSetup> {
4546

4647
return {
4748
cloudId: id,
49+
cloudDeploymentUrl: deploymentUrl,
4850
isCloudEnabled,
4951
};
5052
}

x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ describe('edit policy', () => {
792792
httpRequestsMockHelpers.setPoliciesResponse(policies);
793793
});
794794

795-
describe('with legacy data role config', () => {
795+
describe('with deprecated data role config', () => {
796796
test('should hide data tier option on cloud using legacy node role configuration', async () => {
797797
http.setupNodeListResponse({
798798
nodesByAttributes: { test: ['123'] },
@@ -830,6 +830,8 @@ describe('edit policy', () => {
830830
expect(findTestSubject(rendered, 'defaultDataAllocationOption').exists()).toBeTruthy();
831831
expect(findTestSubject(rendered, 'customDataAllocationOption').exists()).toBeTruthy();
832832
expect(findTestSubject(rendered, 'noneDataAllocationOption').exists()).toBeTruthy();
833+
// We should not be showing the call-to-action for users to activate data tiers in cloud
834+
expect(findTestSubject(rendered, 'cloudDataTierCallout').exists()).toBeFalsy();
833835
});
834836

835837
test('should show cloud notice when cold tier nodes do not exist', async () => {

x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/cloud_data_tier_callout.tsx

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,50 @@
55
*/
66

77
import { i18n } from '@kbn/i18n';
8+
import { FormattedMessage } from '@kbn/i18n/react';
89
import React, { FunctionComponent } from 'react';
9-
import { EuiCallOut } from '@elastic/eui';
10+
import { EuiCallOut, EuiLink } from '@elastic/eui';
11+
12+
import { useKibana } from '../../../../../shared_imports';
13+
14+
const deployment = i18n.translate(
15+
'xpack.indexLifecycleMgmt.editPolicy.cloudDataTierCallout.body.elasticDeploymentLink',
16+
{
17+
defaultMessage: 'deployment',
18+
}
19+
);
1020

1121
const i18nTexts = {
12-
title: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.cloudDataTierCallout.title', {
22+
title: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.cloudDataTierCallout.coldTierTitle', {
1323
defaultMessage: 'Create a cold tier',
1424
}),
15-
body: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.cloudDataTierCallout.body', {
16-
defaultMessage: 'Edit your Elastic Cloud deployment to set up a cold tier.',
17-
}),
25+
body: (deploymentUrl?: string) => {
26+
return (
27+
<FormattedMessage
28+
id="xpack.indexLifecycleMgmt.editPolicy.cloudDataTierCallout.coldTierBody"
29+
defaultMessage="No cold nodes are available. Edit your Elastic {deployment} to set up a cold tier."
30+
values={{
31+
deployment: deploymentUrl ? (
32+
<EuiLink external href={deploymentUrl} target="_blank">
33+
{deployment}
34+
</EuiLink>
35+
) : (
36+
deployment
37+
),
38+
}}
39+
/>
40+
);
41+
},
1842
};
1943

2044
export const CloudDataTierCallout: FunctionComponent = () => {
45+
const {
46+
services: { cloud },
47+
} = useKibana();
48+
2149
return (
2250
<EuiCallOut title={i18nTexts.title} data-test-subj="cloudDataTierCallout">
23-
{i18nTexts.body}
51+
{i18nTexts.body(cloud?.cloudDeploymentUrl)}
2452
</EuiCallOut>
2553
);
2654
};

x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared/data_tier_allocation_field.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,19 @@ export const DataTierAllocationField: FunctionComponent<Props> = ({
6161
switch (phaseData.dataTierAllocationType) {
6262
case 'default':
6363
const isCloudEnabled = cloud?.isCloudEnabled ?? false;
64-
const isUsingNodeRoles = !isUsingDeprecatedDataRoleConfig;
65-
if (
66-
isCloudEnabled &&
67-
isUsingNodeRoles &&
68-
phase === 'cold' &&
69-
!nodesByRoles.data_cold?.length
70-
) {
71-
// Tell cloud users they can deploy cold tier nodes.
72-
return (
73-
<>
74-
<EuiSpacer size="s" />
75-
<CloudDataTierCallout />
76-
</>
77-
);
64+
if (isCloudEnabled && phase === 'cold') {
65+
const isUsingNodeRolesAllocation = !isUsingDeprecatedDataRoleConfig;
66+
const hasNoNodesWithNodeRole = !nodesByRoles.data_cold?.length;
67+
68+
if (isUsingNodeRolesAllocation && hasNoNodesWithNodeRole) {
69+
// Tell cloud users they can deploy nodes on cloud.
70+
return (
71+
<>
72+
<EuiSpacer size="s" />
73+
<CloudDataTierCallout />
74+
</>
75+
);
76+
}
7877
}
7978

8079
const allocationNodeRole = getAvailableNodeRoleForPhase(phase, nodesByRoles);

0 commit comments

Comments
 (0)