Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ILM] Minor copy and link additions to cloud CTA for cold phase #80512

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion x-pack/plugins/cloud/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface CloudSetupDependencies {

export interface CloudSetup {
cloudId?: string;
cloudDeploymentUrl?: string;
isCloudEnabled: boolean;
}

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

public async setup(core: CoreSetup, { home }: CloudSetupDependencies) {
const { id, resetPasswordUrl } = this.config;
const { id, resetPasswordUrl, deploymentUrl } = this.config;
const isCloudEnabled = getIsCloudEnabled(id);

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

return {
cloudId: id,
cloudDeploymentUrl: deploymentUrl,
isCloudEnabled,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ describe('edit policy', () => {
httpRequestsMockHelpers.setPoliciesResponse(policies);
});

describe('with legacy data role config', () => {
describe('with deprecated data role config', () => {
test('should hide data tier option on cloud using legacy node role configuration', async () => {
http.setupNodeListResponse({
nodesByAttributes: { test: ['123'] },
Expand Down Expand Up @@ -776,6 +776,25 @@ describe('edit policy', () => {
expect(findTestSubject(rendered, 'defaultDataAllocationOption').exists()).toBeTruthy();
expect(findTestSubject(rendered, 'customDataAllocationOption').exists()).toBeTruthy();
expect(findTestSubject(rendered, 'noneDataAllocationOption').exists()).toBeTruthy();
// We should not be showing the call-to-action for users to activate data tiers in cloud
expect(findTestSubject(rendered, 'cloudDataTierCallout').exists()).toBeFalsy();
});

test('should show cloud notice when warm tier nodes do not exist', async () => {
http.setupNodeListResponse({
nodesByAttributes: {},
nodesByRoles: { data: ['test'], data_hot: ['test'], data_cold: ['test'] },
isUsingDeprecatedDataRoleConfig: false,
});
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
await activatePhase(rendered, 'warm');
expect(rendered.find('.euiLoadingSpinner').exists()).toBeFalsy();
expect(findTestSubject(rendered, 'cloudDataTierCallout').exists()).toBeTruthy();
// Assert that other notices are not showing
expect(findTestSubject(rendered, 'defaultAllocationNotice').exists()).toBeFalsy();
expect(findTestSubject(rendered, 'noNodeAttributesWarning').exists()).toBeFalsy();
});

test('should show cloud notice when cold tier nodes do not exist', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,85 @@
*/

import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import React, { FunctionComponent } from 'react';
import { EuiCallOut } from '@elastic/eui';
import { EuiCallOut, EuiLink } from '@elastic/eui';

import { PhaseWithAllocation } from '../../../../../../common/types';
import { useKibana } from '../../../../../shared_imports';

const deployment = i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.cloudDataTierCallout.body.elasticDeploymentLink',
{
defaultMessage: 'deployment',
}
);

const i18nTexts = {
title: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.cloudDataTierCallout.title', {
defaultMessage: 'Create a cold tier',
}),
body: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.cloudDataTierCallout.body', {
defaultMessage: 'Edit your Elastic Cloud deployment to set up a cold tier.',
}),
warm: {
title: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.cloudDataTierCallout.warmTierTitle',
{
defaultMessage: 'Create a warm tier',
}
),
body: (deploymentUrl?: string) => {
return (
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.cloudDataTierCallout.warmTierBody"
defaultMessage="No warm nodes are available. Edit your Elastic {deployment} to set up a warm tier."
values={{
deployment: deploymentUrl ? (
<EuiLink external href={deploymentUrl} target="_blank">
{deployment}
</EuiLink>
) : (
deployment
),
}}
/>
);
},
},
cold: {
title: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.cloudDataTierCallout.coldTierTitle',
{
defaultMessage: 'Create a cold tier',
}
),
body: (deploymentUrl?: string) => {
return (
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.cloudDataTierCallout.coldTierBody"
defaultMessage="No cold nodes are available. Edit your Elastic {deployment} to set up a cold tier."
values={{
deployment: deploymentUrl ? (
<EuiLink external href={deploymentUrl} target="_blank">
{deployment}
</EuiLink>
) : (
deployment
),
}}
/>
);
},
},
};

export const CloudDataTierCallout: FunctionComponent = () => {
interface Props {
phase: PhaseWithAllocation;
}

export const CloudDataTierCallout: FunctionComponent<Props> = ({ phase }) => {
const {
services: { cloud },
} = useKibana();

return (
<EuiCallOut title={i18nTexts.title} data-test-subj="cloudDataTierCallout">
{i18nTexts.body}
<EuiCallOut title={i18nTexts[phase].title} data-test-subj="cloudDataTierCallout">
{i18nTexts[phase].body(cloud?.cloudDeploymentUrl)}
</EuiCallOut>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,22 @@ export const DataTierAllocationField: FunctionComponent<Props> = ({
switch (phaseData.dataTierAllocationType) {
case 'default':
const isCloudEnabled = cloud?.isCloudEnabled ?? false;
const isUsingNodeRoles = !isUsingDeprecatedDataRoleConfig;
if (
isCloudEnabled &&
isUsingNodeRoles &&
phase === 'cold' &&
!nodesByRoles.data_cold?.length
) {
// Tell cloud users they can deploy cold tier nodes.
return (
<>
<EuiSpacer size="s" />
<CloudDataTierCallout />
</>
);
if (isCloudEnabled && (phase === 'warm' || phase === 'cold')) {
const isUsingNodeRolesAllocation = !isUsingDeprecatedDataRoleConfig;
const hasNoNodesWithNodeRole =
phase === 'warm'
? !nodesByRoles.data_warm?.length
: !nodesByRoles.data_cold?.length;

if (isUsingNodeRolesAllocation && hasNoNodesWithNodeRole) {
// Tell cloud users they can deploy nodes on cloud.
return (
<>
<EuiSpacer size="s" />
<CloudDataTierCallout phase={phase} />
</>
);
}
}

const allocationNodeRole = getAvailableNodeRoleForPhase(phase, nodesByRoles);
Expand Down