Skip to content

Commit

Permalink
remove logic that disables SS action in cold if no rollover and alway…
Browse files Browse the repository at this point in the history
…s show replicas field
  • Loading branch information
jloleysens committed Feb 25, 2021
1 parent bb8e505 commit 4f5f554
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,10 @@ export const setup = async (arg?: {
const createSearchableSnapshotActions = (phase: Phases) => {
const fieldSelector = `searchableSnapshotField-${phase}`;
const licenseCalloutSelector = `${fieldSelector}.searchableSnapshotDisabledDueToLicense`;
const rolloverCalloutSelector = `${fieldSelector}.searchableSnapshotFieldsNoRolloverCallout`;
const toggleSelector = `${fieldSelector}.searchableSnapshotToggle`;

const toggleSearchableSnapshot = createFormToggleAction(toggleSelector);
return {
searchableSnapshotDisabledDueToRollover: () => exists(rolloverCalloutSelector),
searchableSnapshotDisabled: () =>
exists(licenseCalloutSelector) && find(licenseCalloutSelector).props().disabled === true,
searchableSnapshotsExists: () => exists(fieldSelector),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,6 @@ describe('<EditPolicy />', () => {
await actions.cold.enable(true);

expect(actions.hot.searchableSnapshotsExists()).toBeFalsy();
expect(actions.cold.searchableSnapshotDisabledDueToRollover()).toBeTruthy();
});

test('hiding rollover tip on minimum age', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
import React, { FunctionComponent } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { get } from 'lodash';

import { EuiTextColor } from '@elastic/eui';

import { useFormData } from '../../../../../../shared_imports';

import { useConfigurationIssues } from '../../../form';

import { LearnMoreLink, ToggleFieldWithDescribedFormRow } from '../../';
Expand All @@ -36,23 +33,12 @@ const i18nTexts = {
},
};

const formFieldPaths = {
enabled: '_meta.cold.enabled',
searchableSnapshot: 'phases.cold.actions.searchable_snapshot.snapshot_repository',
};

export const ColdPhase: FunctionComponent = () => {
const { isUsingSearchableSnapshotInHotPhase } = useConfigurationIssues();

const [formData] = useFormData({
watch: [formFieldPaths.searchableSnapshot],
});

const showReplicasField = get(formData, formFieldPaths.searchableSnapshot) == null;

return (
<Phase phase="cold" topLevelSettings={<SearchableSnapshotField phase="cold" />}>
{showReplicasField && <ReplicasField phase="cold" />}
<ReplicasField phase="cold" />

{/* Freeze section */}
{!isUsingSearchableSnapshotInHotPhase && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
services: { cloud },
} = useKibana();
const { getUrlForApp, policy, license, isNewPolicy } = useEditPolicyContext();
const { isUsingSearchableSnapshotInHotPhase, isUsingRollover } = useConfigurationIssues();
const { isUsingSearchableSnapshotInHotPhase } = useConfigurationIssues();

const searchableSnapshotPath = `phases.${phase}.actions.searchable_snapshot.snapshot_repository`;

Expand All @@ -62,10 +62,8 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
const isColdPhase = phase === 'cold';
const isDisabledDueToLicense = !license.canUseSearchableSnapshot();
const isDisabledInColdDueToHotPhase = isColdPhase && isUsingSearchableSnapshotInHotPhase;
const isDisabledInColdDueToRollover = isColdPhase && !isUsingRollover;

const isDisabled =
isDisabledDueToLicense || isDisabledInColdDueToHotPhase || isDisabledInColdDueToRollover;
const isDisabled = isDisabledDueToLicense || isDisabledInColdDueToHotPhase;

const [isFieldToggleChecked, setIsFieldToggleChecked] = useState(() =>
Boolean(
Expand Down Expand Up @@ -294,20 +292,6 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
)}
/>
);
} else if (isDisabledInColdDueToRollover) {
infoCallout = (
<EuiCallOut
size="s"
data-test-subj="searchableSnapshotFieldsNoRolloverCallout"
title={i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotNoRolloverCalloutBody',
{
defaultMessage:
'Cannot create a searchable snapshot when rollover is disabled in the hot phase.',
}
)}
/>
);
}

return infoCallout ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ export const WarmPhase: FunctionComponent = () => {
const { isUsingSearchableSnapshotInHotPhase } = useConfigurationIssues();

return (
<Phase phase={'warm'}>
<ReplicasField phase={'warm'} />
<Phase phase="warm">
<ReplicasField phase="warm" />

{!isUsingSearchableSnapshotInHotPhase && <ShrinkField phase={'warm'} />}
{!isUsingSearchableSnapshotInHotPhase && <ShrinkField phase="warm" />}

{!isUsingSearchableSnapshotInHotPhase && <ForcemergeField phase={'warm'} />}
{!isUsingSearchableSnapshotInHotPhase && <ForcemergeField phase="warm" />}

<ReadonlyField phase={'warm'} />
<ReadonlyField phase="warm" />

{/* Data tier allocation section */}
<DataTierAllocationField
description={i18nTexts.dataTierAllocation.description}
phase={'warm'}
phase="warm"
/>

<IndexPriorityField phase={'warm'} />
<IndexPriorityField phase="warm" />
</Phase>
);
};
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -9459,7 +9459,6 @@
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldTitle": "検索可能スナップショット",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotLicenseCalloutBody": "検索可能なスナップショットを作成するには、エンタープライズライセンスが必要です。",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotLicenseCalloutTitle": "エンタープライズライセンスが必要です",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotNoRolloverCalloutBody": "ロールオーバーがホットフェーズで無効な時には、検索可能なスナップショットを作成できません。",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotRepoRequiredError": "スナップショットリポジトリ名が必要です。",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotsToggleLabel": "検索可能スナップショットを作成",
"xpack.indexLifecycleMgmt.editPolicy.showPolicyJsonButto": "リクエストを表示",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -9483,7 +9483,6 @@
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldTitle": "可搜索快照",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotLicenseCalloutBody": "要创建可搜索快照,需要企业许可证。",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotLicenseCalloutTitle": "需要企业许可证",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotNoRolloverCalloutBody": "在热阶段禁用滚动更新后,无法创建可搜索快照。",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotRepoRequiredError": "快照存储库名称必填。",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotsToggleLabel": "创建可搜索快照",
"xpack.indexLifecycleMgmt.editPolicy.showPolicyJsonButto": "显示请求",
Expand Down

0 comments on commit 4f5f554

Please sign in to comment.