diff --git a/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/components/index_lifecycle_summary.js b/x-pack/plugins/index_lifecycle_management/public/extend_index_management/components/index_lifecycle_summary.js similarity index 100% rename from x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/components/index_lifecycle_summary.js rename to x-pack/plugins/index_lifecycle_management/public/extend_index_management/components/index_lifecycle_summary.js diff --git a/x-pack/plugins/index_lifecycle_management/public/extend_index_management/index.js b/x-pack/plugins/index_lifecycle_management/public/extend_index_management/index.js new file mode 100644 index 000000000000..962afa0fbf61 --- /dev/null +++ b/x-pack/plugins/index_lifecycle_management/public/extend_index_management/index.js @@ -0,0 +1,64 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import React from 'react'; +import { IndexLifecycleSummary } from './components/index_lifecycle_summary'; +import chrome from 'ui/chrome'; +import { get, every } from 'lodash'; +import { i18n } from '@kbn/i18n'; +import { addSummaryExtension, addBannerExtension, addActionExtension } from '../../../index_management/public/index_management_extensions'; +import { retryLifecycleForIndex } from '../services/api'; + +const stepPath = 'ilm.step'; + +if (chrome.getInjected('indexLifecycleManagementUiEnabled')) { + addActionExtension((indices) => { + const allHaveErrors = every(indices, (index) => { + return (index.ilm && index.ilm.failed_step); + }); + if (!allHaveErrors) { + return null; + } + const indexNames = indices.map(({ name }) => name); + return { + requestMethod: retryLifecycleForIndex, + icon: 'play', + indexNames: [indexNames], + buttonLabel: i18n.translate('xpack.idxMgmt.retryIndexLifecycleActionButtonLabel', { + defaultMessage: 'Retry lifecycle', + }), + successMessage: i18n.translate('xpack.idxMgmt.retryIndexLifecycleAction.successfullyRetriedLifecycleMessage', { + defaultMessage: 'Successfully called retry lifecycle for: [{indexNames}]', + values: { indexNames: indexNames.join(', ') } + }), + }; + }); + addBannerExtension((indices) =>{ + if (!indices.length) { + return null; + } + const indicesWithLifecycleErrors = indices.filter((index) => { + return get(index, stepPath) === 'ERROR'; + }); + const numIndicesWithLifecycleErrors = indicesWithLifecycleErrors.length; + if (!numIndicesWithLifecycleErrors) { + return null; + } + return { + type: 'warning', + filter: `${stepPath}:ERROR`, + message: i18n.translate('xpack.indexLifecycleMgmt.indexMgmtBanner.errorMessage', { + defaultMessage: `{ numIndicesWithLifecycleErrors, number} + {numIndicesWithLifecycleErrors, plural, one {index has} other {indices have} } + lifecycle errors`, + values: { numIndicesWithLifecycleErrors } + }), + }; + }); + addSummaryExtension((index, urlService) => { + return ; + }); +} + diff --git a/x-pack/plugins/index_lifecycle_management/public/index.js b/x-pack/plugins/index_lifecycle_management/public/index.js index 3747d4e89a7b..58ba3054db00 100644 --- a/x-pack/plugins/index_lifecycle_management/public/index.js +++ b/x-pack/plugins/index_lifecycle_management/public/index.js @@ -6,4 +6,4 @@ import './register_management_section'; import './register_routes'; -import './register_index_management_extensions'; +import './extend_index_management'; diff --git a/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/index.js b/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/index.js deleted file mode 100644 index 706894c14eac..000000000000 --- a/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/index.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import chrome from 'ui/chrome'; -if (chrome.getInjected('indexLifecycleManagementUiEnabled')) { - require('./register_index_lifecycle_actions'); - require('./register_index_lifecycle_banner'); - require('./register_index_lifecycle_summary'); -} \ No newline at end of file diff --git a/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/register_index_lifecycle_actions.js b/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/register_index_lifecycle_actions.js deleted file mode 100644 index 58d9afbfc53f..000000000000 --- a/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/register_index_lifecycle_actions.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { every } from 'lodash'; -import { i18n } from '@kbn/i18n'; -import { addActionExtension } from '../../../index_management/public/index_management_extensions'; -import { retryLifecycleForIndex } from '../services/api'; -addActionExtension((indices) => { - const allHaveErrors = every(indices, (index) => { - return (index.ilm && index.ilm.failed_step); - }); - if (!allHaveErrors) { - return null; - } - const indexNames = indices.map(({ name }) => name); - return { - requestMethod: retryLifecycleForIndex, - icon: 'play', - indexNames: [indexNames], - buttonLabel: i18n.translate('xpack.idxMgmt.retryIndexLifecycleActionButtonLabel', { - defaultMessage: 'Retry lifecycle', - }), - successMessage: i18n.translate('xpack.idxMgmt.retryIndexLifecycleAction.successfullyRetriedLifecycleMessage', { - defaultMessage: 'Successfully called retry lifecycle for: [{indexNames}]', - values: { indexNames: indexNames.join(', ') } - }), - }; -}); - diff --git a/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/register_index_lifecycle_banner.js b/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/register_index_lifecycle_banner.js deleted file mode 100644 index 519c9b78518b..000000000000 --- a/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/register_index_lifecycle_banner.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -import { get } from 'lodash'; -import { addBannerExtension } from '../../../index_management/public/index_management_extensions'; -const stepPath = 'ilm.step'; -import { i18n } from '@kbn/i18n'; - -addBannerExtension((indices) =>{ - if (!indices.length) { - return null; - } - const indicesWithLifecycleErrors = indices.filter((index) => { - return get(index, stepPath) === 'ERROR'; - }); - const numIndicesWithLifecycleErrors = indicesWithLifecycleErrors.length; - if (!numIndicesWithLifecycleErrors) { - return null; - } - return { - type: 'warning', - filter: `${stepPath}:ERROR`, - message: i18n.translate('xpack.indexLifecycleMgmt.indexMgmtBanner.errorMessage', { - defaultMessage: `{ numIndicesWithLifecycleErrors, number} - {numIndicesWithLifecycleErrors, plural, one {index has} other {indices have} } - lifecycle errors`, - values: { numIndicesWithLifecycleErrors } - }), - }; -}); \ No newline at end of file diff --git a/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/register_index_lifecycle_summary.js b/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/register_index_lifecycle_summary.js deleted file mode 100644 index e1e99540ba73..000000000000 --- a/x-pack/plugins/index_lifecycle_management/public/register_index_management_extensions/register_index_lifecycle_summary.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React from 'react'; -import { addSummaryExtension } from '../../../index_management/public/index_management_extensions'; -import { IndexLifecycleSummary } from './components/index_lifecycle_summary'; -addSummaryExtension((index, urlService) => { - return ; -}); -