Skip to content

Commit

Permalink
scope changes to cold phase only
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Oct 20, 2020
1 parent b281379 commit f82a1d8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -834,23 +834,6 @@ describe('edit policy', () => {
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 () => {
http.setupNodeListResponse({
nodesByAttributes: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { FormattedMessage } from '@kbn/i18n/react';
import React, { FunctionComponent } from 'react';
import { EuiCallOut, EuiLink } from '@elastic/eui';

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

const deployment = i18n.translate(
Expand All @@ -20,70 +19,36 @@ const deployment = i18n.translate(
);

const i18nTexts = {
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
),
}}
/>
);
},
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
),
}}
/>
);
},
};

interface Props {
phase: PhaseWithAllocation;
}

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

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

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

0 comments on commit f82a1d8

Please sign in to comment.