From 064e3b53025bf94b3d7af68692e4425c058322b8 Mon Sep 17 00:00:00 2001
From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Date: Fri, 5 Nov 2021 12:51:16 -0400
Subject: [PATCH] [App Search] ILM is always enabled from 8.0 (#117291)
 (#117669)

Co-authored-by: Orhan Toy <toyorhan@gmail.com>
---
 .../common/__mocks__/initial_app_data.ts      |  1 -
 .../enterprise_search/common/types/index.ts   |  1 -
 .../applications/app_search/app_logic.test.ts |  1 -
 .../applications/app_search/app_logic.ts      |  2 --
 .../log_retention/messaging/constants.tsx     |  8 -------
 .../messaging/log_retention_message.test.tsx  | 21 +------------------
 .../messaging/log_retention_message.tsx       |  8 +------
 .../lib/enterprise_search_config_api.test.ts  |  2 --
 .../lib/enterprise_search_config_api.ts       |  1 -
 .../translations/translations/ja-JP.json      |  1 -
 .../translations/translations/zh-CN.json      |  1 -
 11 files changed, 2 insertions(+), 45 deletions(-)

diff --git a/x-pack/plugins/enterprise_search/common/__mocks__/initial_app_data.ts b/x-pack/plugins/enterprise_search/common/__mocks__/initial_app_data.ts
index 5d4844c3296d7..aa3020a9577f9 100644
--- a/x-pack/plugins/enterprise_search/common/__mocks__/initial_app_data.ts
+++ b/x-pack/plugins/enterprise_search/common/__mocks__/initial_app_data.ts
@@ -7,7 +7,6 @@
 
 export const DEFAULT_INITIAL_APP_DATA = {
   readOnlyMode: false,
-  ilmEnabled: true,
   searchOAuth: {
     clientId: 'someUID',
     redirectUrl: 'http://localhost:3002/ws/search_callback',
diff --git a/x-pack/plugins/enterprise_search/common/types/index.ts b/x-pack/plugins/enterprise_search/common/types/index.ts
index b0b9eb6274875..8addf17f97476 100644
--- a/x-pack/plugins/enterprise_search/common/types/index.ts
+++ b/x-pack/plugins/enterprise_search/common/types/index.ts
@@ -16,7 +16,6 @@ import {
 
 export interface InitialAppData {
   readOnlyMode?: boolean;
-  ilmEnabled?: boolean;
   searchOAuth?: SearchOAuth;
   configuredLimits?: ConfiguredLimits;
   access?: ProductAccess;
diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.test.ts
index f69e3492d26eb..09b4292a29008 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.test.ts
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.test.ts
@@ -25,7 +25,6 @@ describe('AppLogic', () => {
     mount({}, DEFAULT_INITIAL_APP_DATA);
 
     expect(AppLogic.values).toEqual({
-      ilmEnabled: true,
       configuredLimits: {
         engine: {
           maxDocumentByteSize: 102400,
diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.ts
index 90b37e6a4d4ee..96bf4c062dbaf 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.ts
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.ts
@@ -16,7 +16,6 @@ import { ConfiguredLimits, Account, Role } from './types';
 import { getRoleAbilities } from './utils/role';
 
 interface AppValues {
-  ilmEnabled: boolean;
   configuredLimits: ConfiguredLimits;
   account: Account;
   myRole: Role;
@@ -41,7 +40,6 @@ export const AppLogic = kea<MakeLogicType<AppValues, AppActions, Required<Initia
       },
     ],
     configuredLimits: [props.configuredLimits.appSearch, {}],
-    ilmEnabled: [props.ilmEnabled, {}],
   }),
   selectors: {
     myRole: [
diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/constants.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/constants.tsx
index e1e6820204d94..e30b6cec34d18 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/constants.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/constants.tsx
@@ -83,14 +83,6 @@ export const NoLogging: React.FC<Props> = ({ type, disabledAt }) => {
   );
 };
 
-export const ILMDisabled: React.FC<Props> = ({ type }) => (
-  <FormattedMessage
-    id="xpack.enterpriseSearch.appSearch.logRetention.ilmDisabled"
-    defaultMessage="App Search isn't managing {logsType} log retention."
-    values={{ logsType: CAPITALIZATION_MAP[type].lowercase }}
-  />
-);
-
 export const CustomPolicy: React.FC<Props> = ({ type }) => (
   <FormattedMessage
     id="xpack.enterpriseSearch.appSearch.logRetention.customPolicy"
diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/log_retention_message.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/log_retention_message.test.tsx
index ab221879367b3..9ae85e65eea99 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/log_retention_message.test.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/log_retention_message.test.tsx
@@ -21,7 +21,7 @@ describe('LogRetentionMessage', () => {
   const analytics = LogRetentionOptions.Analytics;
   const api = LogRetentionOptions.API;
 
-  const setLogRetention = (logRetention: object, ilmEnabled: boolean = true) => {
+  const setLogRetention = (logRetention: object) => {
     const logRetentionSettings = {
       disabledAt: null,
       enabled: true,
@@ -30,7 +30,6 @@ describe('LogRetentionMessage', () => {
     };
 
     setMockValues({
-      ilmEnabled,
       logRetention: {
         [LogRetentionOptions.API]: logRetentionSettings,
         [LogRetentionOptions.Analytics]: logRetentionSettings,
@@ -155,22 +154,4 @@ describe('LogRetentionMessage', () => {
       });
     });
   });
-
-  describe('when ILM is disabled entirely', () => {
-    describe('an ILM disabled message renders', () => {
-      beforeEach(() => {
-        setLogRetention({}, false);
-      });
-
-      it('for analytics', () => {
-        const wrapper = mountWithIntl(<LogRetentionMessage type={analytics} />);
-        expect(wrapper.text()).toEqual("App Search isn't managing analytics log retention.");
-      });
-
-      it('for api', () => {
-        const wrapper = mountWithIntl(<LogRetentionMessage type={api} />);
-        expect(wrapper.text()).toEqual("App Search isn't managing API log retention.");
-      });
-    });
-  });
 });
diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/log_retention_message.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/log_retention_message.tsx
index 7d34a2567ba14..c461de72edb88 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/log_retention_message.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/log_retention_message.tsx
@@ -9,18 +9,15 @@ import React from 'react';
 
 import { useValues } from 'kea';
 
-import { AppLogic } from '../../../app_logic';
 import { LogRetentionLogic } from '../log_retention_logic';
 import { LogRetentionOptions } from '../types';
 
-import { NoLogging, ILMDisabled, CustomPolicy, DefaultPolicy } from './constants';
+import { NoLogging, CustomPolicy, DefaultPolicy } from './constants';
 
 interface Props {
   type: LogRetentionOptions;
 }
 export const LogRetentionMessage: React.FC<Props> = ({ type }) => {
-  const { ilmEnabled } = useValues(AppLogic);
-
   const { logRetention } = useValues(LogRetentionLogic);
   if (!logRetention) return null;
 
@@ -30,9 +27,6 @@ export const LogRetentionMessage: React.FC<Props> = ({ type }) => {
   if (!logRetentionSettings.enabled) {
     return <NoLogging type={type} disabledAt={logRetentionSettings.disabledAt} />;
   }
-  if (!ilmEnabled) {
-    return <ILMDisabled type={type} />;
-  }
   if (!logRetentionSettings.retentionPolicy?.isDefault) {
     return <CustomPolicy type={type} />;
   } else {
diff --git a/x-pack/plugins/enterprise_search/server/lib/enterprise_search_config_api.test.ts b/x-pack/plugins/enterprise_search/server/lib/enterprise_search_config_api.test.ts
index 3f2a038d8bff3..ba600de298976 100644
--- a/x-pack/plugins/enterprise_search/server/lib/enterprise_search_config_api.test.ts
+++ b/x-pack/plugins/enterprise_search/server/lib/enterprise_search_config_api.test.ts
@@ -46,7 +46,6 @@ describe('callEnterpriseSearchConfigAPI', () => {
     settings: {
       external_url: 'http://some.vanity.url/',
       read_only_mode: false,
-      ilm_enabled: true,
       is_federated_auth: false,
       search_oauth: {
         client_id: 'someUID',
@@ -139,7 +138,6 @@ describe('callEnterpriseSearchConfigAPI', () => {
       },
       publicUrl: undefined,
       readOnlyMode: false,
-      ilmEnabled: false,
       searchOAuth: {
         clientId: undefined,
         redirectUrl: undefined,
diff --git a/x-pack/plugins/enterprise_search/server/lib/enterprise_search_config_api.ts b/x-pack/plugins/enterprise_search/server/lib/enterprise_search_config_api.ts
index 146b06e4d9a4c..d652d56c28efe 100644
--- a/x-pack/plugins/enterprise_search/server/lib/enterprise_search_config_api.ts
+++ b/x-pack/plugins/enterprise_search/server/lib/enterprise_search_config_api.ts
@@ -74,7 +74,6 @@ export const callEnterpriseSearchConfigAPI = async ({
       },
       publicUrl: stripTrailingSlash(data?.settings?.external_url),
       readOnlyMode: !!data?.settings?.read_only_mode,
-      ilmEnabled: !!data?.settings?.ilm_enabled,
       searchOAuth: {
         clientId: data?.settings?.search_oauth?.client_id,
         redirectUrl: data?.settings?.search_oauth?.redirect_url,
diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json
index 47876265894ec..48a2c32188e01 100644
--- a/x-pack/plugins/translations/translations/ja-JP.json
+++ b/x-pack/plugins/translations/translations/ja-JP.json
@@ -9744,7 +9744,6 @@
     "xpack.enterpriseSearch.appSearch.logRetention.callout.disabledSinceTitle": "{logsTitle}は、{disabledDate}以降に無効にされました。",
     "xpack.enterpriseSearch.appSearch.logRetention.callout.disabledTitle": "{logsTitle}は無効です。",
     "xpack.enterpriseSearch.appSearch.logRetention.customPolicy": "カスタム{logsType}ログ保持ポリシーがあります。",
-    "xpack.enterpriseSearch.appSearch.logRetention.ilmDisabled": "App Search は{logsType}ログ保持を管理していません。",
     "xpack.enterpriseSearch.appSearch.logRetention.noLogging": "すべてのエンジンの{logsType}ログが無効です。",
     "xpack.enterpriseSearch.appSearch.logRetention.noLogging.collected": "前回の{logsType}ログは{disabledAtDate}に収集されました。",
     "xpack.enterpriseSearch.appSearch.logRetention.noLogging.notCollected": "収集された{logsType}ログはありません。",
diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json
index 0fd4fea956a11..a5a54ae6bc550 100644
--- a/x-pack/plugins/translations/translations/zh-CN.json
+++ b/x-pack/plugins/translations/translations/zh-CN.json
@@ -9842,7 +9842,6 @@
     "xpack.enterpriseSearch.appSearch.logRetention.callout.disabledTitle": "{logsTitle} 已禁用。",
     "xpack.enterpriseSearch.appSearch.logRetention.customPolicy": "您有定制 {logsType} 日志保留策略。",
     "xpack.enterpriseSearch.appSearch.logRetention.defaultPolicy": "您的 {logsType} 日志将存储至少 {minAgeDays, plural, other {# 天}}。",
-    "xpack.enterpriseSearch.appSearch.logRetention.ilmDisabled": "App Search 未管理 {logsType} 日志保留。",
     "xpack.enterpriseSearch.appSearch.logRetention.noLogging": "所有引擎的 {logsType} 日志记录均已禁用。",
     "xpack.enterpriseSearch.appSearch.logRetention.noLogging.collected": "{logsType} 日志的最后收集日期为 {disabledAtDate}。",
     "xpack.enterpriseSearch.appSearch.logRetention.noLogging.notCollected": "未收集任何 {logsType} 日志。",