diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 241bb838d7a01..cf09756727abd 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -26094,17 +26094,10 @@ "xpack.upgradeAssistant.esDeprecations.mlSnapshots.flyout.upgradeSnapshotErrorTitle": "スナップショットのアップグレードエラー", "xpack.upgradeAssistant.esDeprecations.pageDescription": "廃止予定のクラスターとインデックス設定をレビューします。アップグレード前に重要な問題を解決する必要があります。", "xpack.upgradeAssistant.esDeprecations.pageTitle": "Elasticsearch", - "xpack.upgradeAssistant.esDeprecationStats.criticalDeprecationsTitle": "重大", - "xpack.upgradeAssistant.esDeprecationStats.statsTitle": "Elasticsearch", - "xpack.upgradeAssistant.esDeprecationStats.warningDeprecationsTitle": "警告", "xpack.upgradeAssistant.kibanaDeprecations.deprecationLabel": "Kibana", "xpack.upgradeAssistant.kibanaDeprecations.docLinkText": "ドキュメント", "xpack.upgradeAssistant.kibanaDeprecations.loadingText": "廃止予定を読み込んでいます...", "xpack.upgradeAssistant.kibanaDeprecations.pageTitle": "Kibana", - "xpack.upgradeAssistant.kibanaDeprecationStats.criticalDeprecationsTitle": "重大", - "xpack.upgradeAssistant.kibanaDeprecationStats.loadingErrorMessage": "Kibana廃止予定の取得中にエラーが発生しました。", - "xpack.upgradeAssistant.kibanaDeprecationStats.statsTitle": "Kibana", - "xpack.upgradeAssistant.kibanaDeprecationStats.warningDeprecationsTitle": "警告", "xpack.upgradeAssistant.noDeprecationsPrompt.nextStepsDescription": "他のスタック廃止予定については、{overviewButton}を確認してください。", "xpack.upgradeAssistant.noDeprecationsPrompt.overviewLinkText": "概要ページ", "xpack.upgradeAssistant.overview.analyzeTitle": "廃止予定ログを分析", @@ -27182,4 +27175,4 @@ "xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "フィールドを選択してください。", "xpack.watcher.watcherDescription": "アラートの作成、管理、監視によりデータへの変更を検知します。" } -} \ No newline at end of file +} diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 54ed2e3764418..5dfe3a6d557a7 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -26529,17 +26529,10 @@ "xpack.upgradeAssistant.esDeprecations.mlSnapshots.flyout.upgradeSnapshotErrorTitle": "升级快照时出错", "xpack.upgradeAssistant.esDeprecations.pageDescription": "查看已弃用的群集和索引设置。在升级之前必须解决任何紧急问题。", "xpack.upgradeAssistant.esDeprecations.pageTitle": "Elasticsearch", - "xpack.upgradeAssistant.esDeprecationStats.criticalDeprecationsTitle": "紧急", - "xpack.upgradeAssistant.esDeprecationStats.statsTitle": "Elasticsearch", - "xpack.upgradeAssistant.esDeprecationStats.warningDeprecationsTitle": "警告", "xpack.upgradeAssistant.kibanaDeprecations.deprecationLabel": "Kibana", "xpack.upgradeAssistant.kibanaDeprecations.docLinkText": "文档", "xpack.upgradeAssistant.kibanaDeprecations.loadingText": "正在加载弃用……", "xpack.upgradeAssistant.kibanaDeprecations.pageTitle": "Kibana", - "xpack.upgradeAssistant.kibanaDeprecationStats.criticalDeprecationsTitle": "紧急", - "xpack.upgradeAssistant.kibanaDeprecationStats.loadingErrorMessage": "检索 Kibana 弃用时发生错误。", - "xpack.upgradeAssistant.kibanaDeprecationStats.statsTitle": "Kibana", - "xpack.upgradeAssistant.kibanaDeprecationStats.warningDeprecationsTitle": "警告", "xpack.upgradeAssistant.noDeprecationsPrompt.nextStepsDescription": "查看{overviewButton}以了解其他 Stack 弃用。", "xpack.upgradeAssistant.noDeprecationsPrompt.overviewLinkText": "“概览”页面", "xpack.upgradeAssistant.overview.analyzeTitle": "分析弃用日志", @@ -27627,4 +27620,4 @@ "xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "此字段必填。", "xpack.watcher.watcherDescription": "通过创建、管理和监测警报来检测数据中的更改。" } -} \ No newline at end of file +} diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/kibana_deprecations_service.mock.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/kibana_deprecations_service.mock.ts index 761f950bd7daf..74f2c5d18ad74 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/kibana_deprecations_service.mock.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/kibana_deprecations_service.mock.ts @@ -4,6 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ + import type { DeprecationsServiceStart, DomainDeprecationDetails } from 'kibana/public'; const kibanaDeprecations: DomainDeprecationDetails[] = [ @@ -33,6 +34,23 @@ const kibanaDeprecations: DomainDeprecationDetails[] = [ }, ]; +const mockedKibanaCriticalOnlyDeprecations: DomainDeprecationDetails[] = [ + { + correctiveActions: { + manualSteps: ['Step 1', 'Step 2', 'Step 3'], + api: { + method: 'POST', + path: '/test', + }, + }, + domainId: 'test_domain_1', + level: 'critical', + title: 'Test deprecation title 1', + message: 'Test deprecation message 1', + deprecationType: 'config', + }, +]; + const setLoadDeprecations = ({ deprecationService, response, @@ -90,5 +108,6 @@ export const kibanaDeprecationsServiceHelpers = { mockedConfigKibanaDeprecations: kibanaDeprecations.filter( (deprecation) => deprecation.deprecationType === 'config' ), + mockedKibanaCriticalOnlyDeprecations, }, }; diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/elasticsearch_deprecation_issues.test.tsx b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/elasticsearch_deprecation_issues.test.tsx new file mode 100644 index 0000000000000..d3c92625c7a34 --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/elasticsearch_deprecation_issues.test.tsx @@ -0,0 +1,186 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { act } from 'react-dom/test-utils'; +import { deprecationsServiceMock } from 'src/core/public/mocks'; + +import { setupEnvironment, kibanaDeprecationsServiceHelpers } from '../../helpers'; +import { OverviewTestBed, setupOverviewPage } from '../overview.helpers'; +import { + esCriticalAndWarningDeprecations, + esCriticalOnlyDeprecations, + esNoDeprecations, +} from './mock_es_issues'; + +describe('Overview - Fix deprecation issues step - Elasticsearch deprecations', () => { + let testBed: OverviewTestBed; + const { server, httpRequestsMockHelpers } = setupEnvironment(); + + afterAll(() => { + server.restore(); + }); + + describe('When load succeeds', () => { + const setup = async () => { + // Set up with no Kibana deprecations. + await act(async () => { + const deprecationService = deprecationsServiceMock.createStartContract(); + kibanaDeprecationsServiceHelpers.setLoadDeprecations({ deprecationService, response: [] }); + + testBed = await setupOverviewPage({ + services: { + core: { + deprecations: deprecationService, + }, + }, + }); + }); + + const { component } = testBed; + component.update(); + }; + + describe('when there are critical and warning issues', () => { + beforeEach(async () => { + httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esCriticalAndWarningDeprecations); + await setup(); + }); + + test('renders counts for both', () => { + const { exists, find } = testBed; + expect(exists('esStatsPanel')).toBe(true); + expect(find('esStatsPanel.warningDeprecations').text()).toContain('1'); + expect(find('esStatsPanel.criticalDeprecations').text()).toContain('1'); + }); + + test('panel links to ES deprecations page', () => { + const { component, find } = testBed; + component.update(); + expect(find('esStatsPanel').find('a').props().href).toBe('/es_deprecations'); + }); + }); + + describe('when there are critical but no warning issues', () => { + beforeEach(async () => { + httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esCriticalOnlyDeprecations); + await setup(); + }); + + test('renders a count for critical issues and success state for warning issues', () => { + const { exists, find } = testBed; + expect(exists('esStatsPanel')).toBe(true); + expect(find('esStatsPanel.criticalDeprecations').text()).toContain('1'); + expect(exists('esStatsPanel.noWarningDeprecationIssues')).toBe(true); + }); + + test('panel links to ES deprecations page', () => { + const { component, find } = testBed; + component.update(); + expect(find('esStatsPanel').find('a').props().href).toBe('/es_deprecations'); + }); + }); + + describe('when there no critical or warning issues', () => { + beforeEach(async () => { + httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esNoDeprecations); + await setup(); + }); + + test('renders a count for critical issues and success state for warning issues', () => { + const { exists } = testBed; + expect(exists('esStatsPanel')).toBe(true); + expect(exists('esStatsPanel.noDeprecationIssues')).toBe(true); + }); + + test(`panel doesn't link to ES deprecations page`, () => { + const { component, find } = testBed; + component.update(); + expect(find('esStatsPanel').find('a').length).toBe(0); + }); + }); + }); + + describe(`When there's a load error`, () => { + test('handles network failure', async () => { + const error = { + statusCode: 500, + error: 'Internal server error', + message: 'Internal server error', + }; + + httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, error); + + await act(async () => { + testBed = await setupOverviewPage(); + }); + + const { component, exists } = testBed; + component.update(); + expect(exists('esRequestErrorIconTip')).toBe(true); + }); + + test('handles unauthorized error', async () => { + const error = { + statusCode: 403, + error: 'Forbidden', + message: 'Forbidden', + }; + + httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, error); + + await act(async () => { + testBed = await setupOverviewPage(); + }); + + const { component, exists } = testBed; + component.update(); + expect(exists('unauthorizedErrorIconTip')).toBe(true); + }); + + test('handles partially upgraded error', async () => { + const error = { + statusCode: 426, + error: 'Upgrade required', + message: 'There are some nodes running a different version of Elasticsearch', + attributes: { + allNodesUpgraded: false, + }, + }; + + httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, error); + + await act(async () => { + testBed = await setupOverviewPage({ isReadOnlyMode: false }); + }); + + const { component, exists } = testBed; + component.update(); + expect(exists('partiallyUpgradedErrorIconTip')).toBe(true); + }); + + test('handles upgrade error', async () => { + const error = { + statusCode: 426, + error: 'Upgrade required', + message: 'There are some nodes running a different version of Elasticsearch', + attributes: { + allNodesUpgraded: true, + }, + }; + + httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, error); + + await act(async () => { + testBed = await setupOverviewPage({ isReadOnlyMode: false }); + }); + + const { component, exists } = testBed; + component.update(); + expect(exists('upgradedErrorIconTip')).toBe(true); + }); + }); +}); diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/fix_issues_step.test.tsx b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/fix_issues_step.test.tsx index 0b572ab41deaa..e9fa57b54ae0e 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/fix_issues_step.test.tsx +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/fix_issues_step.test.tsx @@ -10,47 +10,23 @@ import { deprecationsServiceMock } from 'src/core/public/mocks'; import { setupEnvironment, kibanaDeprecationsServiceHelpers } from '../../helpers'; import { OverviewTestBed, setupOverviewPage } from '../overview.helpers'; -import { esDeprecations, esDeprecationsEmpty } from './mocked_responses'; +import { esCriticalAndWarningDeprecations, esNoDeprecations } from './mock_es_issues'; describe('Overview - Fix deprecation issues step', () => { let testBed: OverviewTestBed; const { server, httpRequestsMockHelpers } = setupEnvironment(); - const { - mockedCriticalKibanaDeprecations, - mockedWarningKibanaDeprecations, - } = kibanaDeprecationsServiceHelpers.defaultMockedResponses; - - beforeEach(async () => { - httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esDeprecations); - - await act(async () => { - const deprecationService = deprecationsServiceMock.createStartContract(); - kibanaDeprecationsServiceHelpers.setLoadDeprecations({ deprecationService }); - - testBed = await setupOverviewPage({ - services: { - core: { - deprecations: deprecationService, - }, - }, - }); - }); - - const { component } = testBed; - component.update(); - }); afterAll(() => { server.restore(); }); - describe('Step status', () => { - test(`It's complete when there are no critical deprecations`, async () => { - httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esDeprecationsEmpty); + describe('when there are critical issues in one panel', () => { + beforeEach(async () => { + httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esCriticalAndWarningDeprecations); await act(async () => { const deprecationService = deprecationsServiceMock.createStartContract(); - deprecationService.getAllDeprecations = jest.fn().mockRejectedValue([]); + kibanaDeprecationsServiceHelpers.setLoadDeprecations({ deprecationService, response: [] }); testBed = await setupOverviewPage({ services: { @@ -61,153 +37,19 @@ describe('Overview - Fix deprecation issues step', () => { }); }); - const { exists, component } = testBed; - - component.update(); - - expect(exists(`fixIssuesStep-complete`)).toBe(true); + testBed.component.update(); }); - test(`It's incomplete when there are critical deprecations`, async () => { + test('renders step as incomplete', async () => { const { exists } = testBed; - expect(exists(`fixIssuesStep-incomplete`)).toBe(true); }); }); - describe('ES deprecations', () => { - test('Shows deprecation warning and critical counts', () => { - const { exists, find } = testBed; - - expect(exists('esStatsPanel')).toBe(true); - expect(find('esStatsPanel.warningDeprecations').text()).toContain('1'); - expect(find('esStatsPanel.criticalDeprecations').text()).toContain('1'); - }); - - test(`Hides deprecation counts if it doesn't have any`, async () => { - httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esDeprecationsEmpty); + describe('when there are no critical issues for either panel', () => { + beforeEach(async () => { + httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esNoDeprecations); - await act(async () => { - testBed = await setupOverviewPage(); - }); - - const { exists } = testBed; - - expect(exists('noDeprecationsLabel')).toBe(true); - }); - - test('Stats panel contains link to ES deprecations page', () => { - const { component, exists, find } = testBed; - - component.update(); - - expect(exists('esStatsPanel')).toBe(true); - expect(find('esStatsPanel').find('a').props().href).toBe('/es_deprecations'); - }); - - describe('Renders errors', () => { - test('handles network failure', async () => { - const error = { - statusCode: 500, - error: 'Internal server error', - message: 'Internal server error', - }; - - httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, error); - - await act(async () => { - testBed = await setupOverviewPage(); - }); - - const { component, exists } = testBed; - - component.update(); - - expect(exists('esRequestErrorIconTip')).toBe(true); - }); - - test('handles unauthorized error', async () => { - const error = { - statusCode: 403, - error: 'Forbidden', - message: 'Forbidden', - }; - - httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, error); - - await act(async () => { - testBed = await setupOverviewPage(); - }); - - const { component, exists } = testBed; - - component.update(); - - expect(exists('unauthorizedErrorIconTip')).toBe(true); - }); - - test('handles partially upgraded error', async () => { - const error = { - statusCode: 426, - error: 'Upgrade required', - message: 'There are some nodes running a different version of Elasticsearch', - attributes: { - allNodesUpgraded: false, - }, - }; - - httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, error); - - await act(async () => { - testBed = await setupOverviewPage({ isReadOnlyMode: false }); - }); - - const { component, exists } = testBed; - - component.update(); - - expect(exists('partiallyUpgradedErrorIconTip')).toBe(true); - }); - - test('handles upgrade error', async () => { - const error = { - statusCode: 426, - error: 'Upgrade required', - message: 'There are some nodes running a different version of Elasticsearch', - attributes: { - allNodesUpgraded: true, - }, - }; - - httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, error); - - await act(async () => { - testBed = await setupOverviewPage({ isReadOnlyMode: false }); - }); - - const { component, exists } = testBed; - - component.update(); - - expect(exists('upgradedErrorIconTip')).toBe(true); - }); - }); - }); - - describe('Kibana deprecations', () => { - test('Shows deprecation warning and critical counts', () => { - const { exists, find } = testBed; - - expect(exists('kibanaStatsPanel')).toBe(true); - expect(find('kibanaStatsPanel.warningDeprecations').text()).toContain( - mockedWarningKibanaDeprecations.length - ); - expect(find('kibanaStatsPanel.criticalDeprecations').text()).toContain( - mockedCriticalKibanaDeprecations.length - ); - }); - - test(`Hides deprecation count if it doesn't have any`, async () => { await act(async () => { const deprecationService = deprecationsServiceMock.createStartContract(); kibanaDeprecationsServiceHelpers.setLoadDeprecations({ deprecationService, response: [] }); @@ -221,48 +63,12 @@ describe('Overview - Fix deprecation issues step', () => { }); }); - const { exists, component } = testBed; - - component.update(); - - expect(exists('noDeprecationsLabel')).toBe(true); - expect(exists('kibanaStatsPanel.warningDeprecations')).toBe(false); - expect(exists('kibanaStatsPanel.criticalDeprecations')).toBe(false); - }); - - test('Stats panel contains link to Kibana deprecations page', () => { - const { component, exists, find } = testBed; - - component.update(); - - expect(exists('kibanaStatsPanel')).toBe(true); - expect(find('kibanaStatsPanel').find('a').props().href).toBe('/kibana_deprecations'); + testBed.component.update(); }); - describe('Renders errors', () => { - test('Handles network failure', async () => { - await act(async () => { - const deprecationService = deprecationsServiceMock.createStartContract(); - kibanaDeprecationsServiceHelpers.setLoadDeprecations({ - deprecationService, - mockRequestErrorMessage: 'Internal Server Error', - }); - - testBed = await setupOverviewPage({ - services: { - core: { - deprecations: deprecationService, - }, - }, - }); - }); - - const { component, exists } = testBed; - - component.update(); - - expect(exists('kibanaRequestErrorIconTip')).toBe(true); - }); + test('renders step as complete', async () => { + const { exists } = testBed; + expect(exists(`fixIssuesStep-complete`)).toBe(true); }); }); }); diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/kibana_deprecation_issues.test.tsx b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/kibana_deprecation_issues.test.tsx new file mode 100644 index 0000000000000..9c0a6b9723072 --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/kibana_deprecation_issues.test.tsx @@ -0,0 +1,132 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { act } from 'react-dom/test-utils'; +import { deprecationsServiceMock } from 'src/core/public/mocks'; +import type { DomainDeprecationDetails } from 'kibana/public'; + +import { setupEnvironment, kibanaDeprecationsServiceHelpers } from '../../helpers'; +import { OverviewTestBed, setupOverviewPage } from '../overview.helpers'; +import { esNoDeprecations } from './mock_es_issues'; + +describe('Overview - Fix deprecation issues step - Kibana deprecations', () => { + let testBed: OverviewTestBed; + const { server, httpRequestsMockHelpers } = setupEnvironment(); + const { + mockedKibanaDeprecations, + mockedKibanaCriticalOnlyDeprecations, + } = kibanaDeprecationsServiceHelpers.defaultMockedResponses; + + afterAll(() => { + server.restore(); + }); + + describe('When load succeeds', () => { + const setup = async (response: DomainDeprecationDetails[]) => { + // Set up with no ES deprecations. + httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esNoDeprecations); + + await act(async () => { + const deprecationService = deprecationsServiceMock.createStartContract(); + kibanaDeprecationsServiceHelpers.setLoadDeprecations({ deprecationService, response }); + + testBed = await setupOverviewPage({ + services: { + core: { + deprecations: deprecationService, + }, + }, + }); + }); + + const { component } = testBed; + component.update(); + }; + + describe('when there are critical and warning issues', () => { + beforeEach(async () => { + await setup(mockedKibanaDeprecations); + }); + + test('renders counts for both', () => { + const { exists, find } = testBed; + + expect(exists('kibanaStatsPanel')).toBe(true); + expect(find('kibanaStatsPanel.criticalDeprecations').text()).toContain(1); + expect(find('kibanaStatsPanel.warningDeprecations').text()).toContain(1); + }); + + test('panel links to Kibana deprecations page', () => { + const { component, find } = testBed; + component.update(); + expect(find('kibanaStatsPanel').find('a').props().href).toBe('/kibana_deprecations'); + }); + }); + + describe('when there are critical but no warning issues', () => { + beforeEach(async () => { + await setup(mockedKibanaCriticalOnlyDeprecations); + }); + + test('renders a count for critical issues and success state for warning issues', () => { + const { exists, find } = testBed; + + expect(exists('kibanaStatsPanel')).toBe(true); + expect(find('kibanaStatsPanel.criticalDeprecations').text()).toContain(1); + expect(exists('kibanaStatsPanel.noWarningDeprecationIssues')).toBe(true); + }); + + test('panel links to Kibana deprecations page', () => { + const { component, find } = testBed; + component.update(); + expect(find('kibanaStatsPanel').find('a').props().href).toBe('/kibana_deprecations'); + }); + }); + + describe('when there no critical or warning issues', () => { + beforeEach(async () => { + await setup([]); + }); + + test('renders a success state for the panel', () => { + const { exists } = testBed; + expect(exists('kibanaStatsPanel')).toBe(true); + expect(exists('kibanaStatsPanel.noDeprecationIssues')).toBe(true); + }); + + test(`panel doesn't link to Kibana deprecations page`, () => { + const { component, find } = testBed; + component.update(); + expect(find('kibanaStatsPanel').find('a').length).toBe(0); + }); + }); + }); + + describe(`When there's a load error`, () => { + test('Handles network failure', async () => { + await act(async () => { + const deprecationService = deprecationsServiceMock.createStartContract(); + kibanaDeprecationsServiceHelpers.setLoadDeprecations({ + deprecationService, + mockRequestErrorMessage: 'Internal Server Error', + }); + + testBed = await setupOverviewPage({ + services: { + core: { + deprecations: deprecationService, + }, + }, + }); + }); + + const { component, exists } = testBed; + component.update(); + expect(exists('kibanaRequestErrorIconTip')).toBe(true); + }); + }); +}); diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/mocked_responses.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/mock_es_issues.ts similarity index 66% rename from x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/mocked_responses.ts rename to x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/mock_es_issues.ts index 1ead28a48a131..086264bcab8e2 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/mocked_responses.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_issues_step/mock_es_issues.ts @@ -7,7 +7,7 @@ import { ESUpgradeStatus } from '../../../../common/types'; -export const esDeprecations: ESUpgradeStatus = { +export const esCriticalAndWarningDeprecations: ESUpgradeStatus = { totalCriticalDeprecations: 1, deprecations: [ { @@ -34,7 +34,23 @@ export const esDeprecations: ESUpgradeStatus = { ], }; -export const esDeprecationsEmpty: ESUpgradeStatus = { +export const esCriticalOnlyDeprecations: ESUpgradeStatus = { + totalCriticalDeprecations: 1, + deprecations: [ + { + isCritical: true, + type: 'cluster_settings', + resolveDuringUpgrade: false, + message: 'Index Lifecycle Management poll interval is set too low', + url: + 'https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-8.0.html#ilm-poll-interval-limit', + details: + 'The Index Lifecycle Management poll interval setting [indices.lifecycle.poll_interval] is currently set to [500ms], but must be 1s or greater', + }, + ], +}; + +export const esNoDeprecations: ESUpgradeStatus = { totalCriticalDeprecations: 0, deprecations: [], }; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/_fix_issues_step.scss b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/_fix_issues_step.scss deleted file mode 100644 index b32f3eb9ddbdf..0000000000000 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/_fix_issues_step.scss +++ /dev/null @@ -1,6 +0,0 @@ -// Used by both es_stats and kibana_stats panel for having the EuiPopover Icon -// for errors shown next to the title without having to resort to wrapping everything -// with EuiFlexGroups. -.upgWarningIcon { - margin-left: $euiSizeS; -} diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/_deprecation_issues_panel.scss b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/_deprecation_issues_panel.scss new file mode 100644 index 0000000000000..37079275b1859 --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/_deprecation_issues_panel.scss @@ -0,0 +1,24 @@ +/** + * Push success state to the bottom + * of the card, so it aligns with , + * which is inside EuiStat. + */ +.upgDeprecationIssuesPanel .euiCard__content { + display: flex; + flex-direction: column; + justify-content: space-between; +} + +/** + * Ensure the stat is a consistent height, even when it contains + * , which is shorter than the + * standard number value. We also push it to the bottom of the its + * container, to base-align it with the number value. + */ +.upgDeprecationIssuesPanel__stat { + height: 60px; // Derived from font measurements, not sizing vars + justify-content: space-between; + flex-grow: 1; + flex-direction: column; + display: flex; +} \ No newline at end of file diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/_es_stats_error.scss b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/_es_stats_error.scss new file mode 100644 index 0000000000000..92c92d96c31a2 --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/_es_stats_error.scss @@ -0,0 +1,7 @@ +/* + * Used for having the EuiPopover Icon for errors shown next to the title without + * having to resort to wrapping everything with EuiFlexGroups. + */ +.upgWarningIcon { + margin-left: $euiSizeS; +} diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/deprecation_issues_panel.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/deprecation_issues_panel.tsx new file mode 100644 index 0000000000000..1d54760119b8b --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/deprecation_issues_panel.tsx @@ -0,0 +1,193 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useEffect } from 'react'; +import { useHistory } from 'react-router-dom'; +import { + EuiCard, + EuiStat, + EuiSpacer, + EuiFlexGroup, + EuiFlexItem, + EuiScreenReaderOnly, +} from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; + +import { reactRouterNavigate } from '../../../../../../../../../src/plugins/kibana_react/public'; +import { getDeprecationsUpperLimit } from '../../../../lib/utils'; +import { NoDeprecationIssues } from './no_deprecation_issues'; + +import './_deprecation_issues_panel.scss'; + +const i18nTexts = { + warningDeprecationsTitle: i18n.translate( + 'xpack.upgradeAssistant.deprecationStats.warningDeprecationsTitle', + { + defaultMessage: 'Warning', + } + ), + criticalDeprecationsTitle: i18n.translate( + 'xpack.upgradeAssistant.deprecationStats.criticalDeprecationsTitle', + { + defaultMessage: 'Critical', + } + ), + getLoadingMessage: (deprecationSource: string) => + i18n.translate('xpack.upgradeAssistant.deprecationStats.loadingText', { + defaultMessage: 'Loading {deprecationSource} deprecation stats…', + values: { + deprecationSource, + }, + }), + getCriticalDeprecationsMessage: (deprecationSource: string, criticalDeprecations: number) => + i18n.translate('xpack.upgradeAssistant.deprecationStats.criticalDeprecationsLabel', { + defaultMessage: + '{deprecationSource} has {criticalDeprecations} critical {criticalDeprecations, plural, one {deprecation} other {deprecations}}', + values: { + deprecationSource, + criticalDeprecations, + }, + }), + getWarningDeprecationsMessage: (deprecationSource: string, warningDeprecations: number) => + i18n.translate('xpack.upgradeAssistant.deprecationStats.getWarningDeprecationsMessage', { + defaultMessage: + '{deprecationSource} has {warningDeprecations} warning {warningDeprecations, plural, one {deprecation} other {deprecations}}', + values: { + deprecationSource, + warningDeprecations, + }, + }), +}; + +interface Props { + 'data-test-subj': string; + deprecationSource: string; + linkUrl: string; + criticalDeprecationsCount: number; + warningDeprecationsCount: number; + isLoading: boolean; + errorMessage?: JSX.Element | null; + setIsFixed: (isFixed: boolean) => void; +} + +export const DeprecationIssuesPanel = (props: Props) => { + const { + deprecationSource, + linkUrl, + criticalDeprecationsCount, + warningDeprecationsCount, + isLoading, + errorMessage, + setIsFixed, + } = props; + const history = useHistory(); + + const hasError = !!errorMessage; + const hasCriticalIssues = criticalDeprecationsCount > 0; + const hasWarningIssues = warningDeprecationsCount > 0; + const hasNoIssues = !isLoading && !hasError && !hasWarningIssues && !hasCriticalIssues; + + useEffect(() => { + if (!isLoading && !errorMessage) { + setIsFixed(criticalDeprecationsCount === 0); + } + }, [setIsFixed, criticalDeprecationsCount, isLoading, errorMessage]); + + return ( + + {deprecationSource} + {hasError && errorMessage} + + } + {...(!hasNoIssues && reactRouterNavigate(history, linkUrl))} + > + + + {hasNoIssues ? ( + + ) : ( + + + + ) + } + titleElement="span" + description={i18nTexts.criticalDeprecationsTitle} + titleColor="danger" + isLoading={isLoading} + > + {!hasError && ( + +

+ {isLoading + ? i18nTexts.getLoadingMessage(deprecationSource) + : i18nTexts.getCriticalDeprecationsMessage( + deprecationSource, + criticalDeprecationsCount + )} +

+
+ )} +
+
+ + + + ) + } + titleElement="span" + description={i18nTexts.warningDeprecationsTitle} + isLoading={isLoading} + > + {!hasError && ( + +

+ {isLoading + ? i18nTexts.getLoadingMessage(deprecationSource) + : i18nTexts.getWarningDeprecationsMessage( + deprecationSource, + warningDeprecationsCount + )} +

+
+ )} +
+
+
+ )} +
+ ); +}; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/es_stats.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/es_stats.tsx new file mode 100644 index 0000000000000..89860d5b58be4 --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/es_stats.tsx @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { FunctionComponent } from 'react'; + +import { useAppContext } from '../../../../app_context'; +import { EsStatsErrors } from './es_stats_error'; +import { DeprecationIssuesPanel } from './deprecation_issues_panel'; + +interface Props { + setIsFixed: (isFixed: boolean) => void; +} + +export const ElasticsearchDeprecationStats: FunctionComponent = ({ setIsFixed }) => { + const { + services: { api }, + } = useAppContext(); + + const { data: esDeprecations, isLoading, error } = api.useLoadEsDeprecations(); + + const criticalDeprecationsCount = + esDeprecations?.deprecations?.filter((deprecation) => deprecation.isCritical)?.length ?? 0; + + const warningDeprecationsCount = + esDeprecations?.deprecations?.filter((deprecation) => deprecation.isCritical === false) + ?.length ?? 0; + + const errorMessage = error && ; + + return ( + + ); +}; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/es_stats/es_stats_error.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/es_stats_error.tsx similarity index 98% rename from x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/es_stats/es_stats_error.tsx rename to x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/es_stats_error.tsx index c717a8a2e12e8..7246d73db038c 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/es_stats/es_stats_error.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/es_stats_error.tsx @@ -6,11 +6,13 @@ */ import React from 'react'; - import { EuiIconTip } from '@elastic/eui'; + import { ResponseError } from '../../../../lib/api'; import { getEsDeprecationError } from '../../../../lib/get_es_deprecation_error'; +import './_es_stats_error.scss'; + interface Props { error: ResponseError; } @@ -34,6 +36,7 @@ export const EsStatsErrors: React.FunctionComponent = ({ error }) => { /> ); break; + case 'partially_upgraded_error': iconContent = ( = ({ error }) => { /> ); break; + case 'upgraded_error': iconContent = ( = ({ error }) => { /> ); break; + case 'request_error': default: iconContent = ( diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/kibana_stats/index.ts b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/index.ts similarity index 83% rename from x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/kibana_stats/index.ts rename to x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/index.ts index 185ec5f2540c4..fe3a0dd2ceaff 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/kibana_stats/index.ts +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/index.ts @@ -5,4 +5,5 @@ * 2.0. */ +export { ElasticsearchDeprecationStats } from './es_stats'; export { KibanaDeprecationStats } from './kibana_stats'; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/kibana_stats.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/kibana_stats.tsx new file mode 100644 index 0000000000000..891ccc01dcd40 --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/kibana_stats.tsx @@ -0,0 +1,83 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { FunctionComponent, useEffect, useState } from 'react'; +import { EuiIconTip } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import type { DomainDeprecationDetails } from 'kibana/public'; + +import { useAppContext } from '../../../../app_context'; +import { DeprecationIssuesPanel } from './deprecation_issues_panel'; + +interface Props { + setIsFixed: (isFixed: boolean) => void; +} + +export const KibanaDeprecationStats: FunctionComponent = ({ setIsFixed }) => { + const { + services: { + core: { deprecations }, + }, + } = useAppContext(); + + const [kibanaDeprecations, setKibanaDeprecations] = useState< + DomainDeprecationDetails[] | undefined + >(undefined); + const [isLoading, setIsLoading] = useState(false); + const [error, setError] = useState(undefined); + + useEffect(() => { + async function getAllDeprecations() { + setIsLoading(true); + + try { + const response = await deprecations.getAllDeprecations(); + setKibanaDeprecations(response); + } catch (e) { + setError(e); + } + + setIsLoading(false); + } + + getAllDeprecations(); + }, [deprecations]); + + const criticalDeprecationsCount = + kibanaDeprecations?.filter((deprecation) => deprecation.level === 'critical')?.length ?? 0; + + const warningDeprecationsCount = + kibanaDeprecations?.filter((deprecation) => deprecation.level === 'warning')?.length ?? 0; + + const errorMessage = error && ( + + ); + + return ( + + ); +}; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/no_deprecation_issues.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/no_deprecation_issues.tsx new file mode 100644 index 0000000000000..16d4385fad7bb --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/no_deprecation_issues.tsx @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { FunctionComponent } from 'react'; +import { EuiFlexGroup, EuiFlexItem, EuiText, EuiIcon } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; + +const i18nTexts = { + noPartialDeprecationIssuesText: i18n.translate('xpack.upgradeAssistant.noDeprecationsMessage', { + defaultMessage: 'None', + }), + noDeprecationIssuesText: i18n.translate('xpack.upgradeAssistant.noDeprecationsMessage', { + defaultMessage: 'No issues', + }), +}; + +interface Props { + isPartial?: boolean; + 'data-test-subj'?: string; +} + +export const NoDeprecationIssues: FunctionComponent = (props) => { + const { isPartial = false } = props; + + return ( + + + + + + + + {isPartial ? i18nTexts.noPartialDeprecationIssuesText : i18nTexts.noDeprecationIssuesText} + + + + ); +}; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/es_stats/es_stats.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/es_stats/es_stats.tsx deleted file mode 100644 index 7d0dcacfaa207..0000000000000 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/es_stats/es_stats.tsx +++ /dev/null @@ -1,118 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React, { FunctionComponent, useEffect, useMemo } from 'react'; -import { useHistory } from 'react-router-dom'; - -import { EuiStat, EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiCard } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; - -import { reactRouterNavigate } from '../../../../../../../../../src/plugins/kibana_react/public'; -import { getDeprecationsUpperLimit } from '../../../../lib/utils'; -import { useAppContext } from '../../../../app_context'; -import { EsStatsErrors } from './es_stats_error'; -import { NoDeprecations } from '../no_deprecations'; - -const i18nTexts = { - statsTitle: i18n.translate('xpack.upgradeAssistant.esDeprecationStats.statsTitle', { - defaultMessage: 'Elasticsearch', - }), - warningDeprecationsTitle: i18n.translate( - 'xpack.upgradeAssistant.esDeprecationStats.warningDeprecationsTitle', - { - defaultMessage: 'Warning', - } - ), - criticalDeprecationsTitle: i18n.translate( - 'xpack.upgradeAssistant.esDeprecationStats.criticalDeprecationsTitle', - { - defaultMessage: 'Critical', - } - ), -}; - -interface Props { - setIsFixed: (isFixed: boolean) => void; -} - -export const ESDeprecationStats: FunctionComponent = ({ setIsFixed }) => { - const history = useHistory(); - const { - services: { api }, - } = useAppContext(); - - const { data: esDeprecations, isLoading, error } = api.useLoadEsDeprecations(); - - const warningDeprecations = useMemo( - () => - esDeprecations?.deprecations?.filter((deprecation) => deprecation.isCritical === false) || [], - [esDeprecations] - ); - const criticalDeprecations = useMemo( - () => esDeprecations?.deprecations?.filter((deprecation) => deprecation.isCritical) || [], - [esDeprecations] - ); - - useEffect(() => { - if (!isLoading && !error) { - setIsFixed(criticalDeprecations.length === 0); - } - }, [setIsFixed, criticalDeprecations, isLoading, error]); - - const hasWarnings = warningDeprecations.length > 0; - const hasCritical = criticalDeprecations.length > 0; - const hasNoDeprecations = !isLoading && !error && !hasWarnings && !hasCritical; - const shouldRenderStat = (forSection: boolean) => error || isLoading || forSection; - - return ( - - {i18nTexts.statsTitle} - {error && } - - } - {...(!hasNoDeprecations && reactRouterNavigate(history, '/es_deprecations'))} - > - - - {hasNoDeprecations && ( - - - - )} - - {shouldRenderStat(hasCritical) && ( - - - - )} - - {shouldRenderStat(hasWarnings) && ( - - - - )} - - - ); -}; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/es_stats/index.ts b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/es_stats/index.ts deleted file mode 100644 index daf2644c2477b..0000000000000 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/es_stats/index.ts +++ /dev/null @@ -1,8 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export { ESDeprecationStats } from './es_stats'; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/fix_issues_step.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/fix_issues_step.tsx index df9bf58198d9d..d4ecccdd5dc15 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/fix_issues_step.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/fix_issues_step.tsx @@ -11,11 +11,9 @@ import { EuiText, EuiFlexItem, EuiFlexGroup, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import type { EuiStepProps } from '@elastic/eui/src/components/steps/step'; -import { ESDeprecationStats } from './es_stats'; -import { KibanaDeprecationStats } from './kibana_stats'; -import type { OverviewStepProps } from '../../types'; -import './_fix_issues_step.scss'; +import type { OverviewStepProps } from '../../types'; +import { ElasticsearchDeprecationStats, KibanaDeprecationStats } from './components'; const i18nTexts = { reviewStepTitle: i18n.translate('xpack.upgradeAssistant.overview.fixIssuesStepTitle', { @@ -45,7 +43,7 @@ const FixIssuesStep: FunctionComponent = ({ setIsComplete }) => { return ( - + diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/kibana_stats/kibana_stats.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/kibana_stats/kibana_stats.tsx deleted file mode 100644 index 2cfc555116ba6..0000000000000 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/kibana_stats/kibana_stats.tsx +++ /dev/null @@ -1,155 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React, { FunctionComponent, useEffect, useState } from 'react'; -import { useHistory } from 'react-router-dom'; - -import { EuiCard, EuiStat, EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiIconTip } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; - -import type { DomainDeprecationDetails } from 'kibana/public'; -import { reactRouterNavigate } from '../../../../../../../../../src/plugins/kibana_react/public'; -import { getDeprecationsUpperLimit } from '../../../../lib/utils'; -import { useAppContext } from '../../../../app_context'; -import { NoDeprecations } from '../no_deprecations'; - -const i18nTexts = { - statsTitle: i18n.translate('xpack.upgradeAssistant.kibanaDeprecationStats.statsTitle', { - defaultMessage: 'Kibana', - }), - warningDeprecationsTitle: i18n.translate( - 'xpack.upgradeAssistant.kibanaDeprecationStats.warningDeprecationsTitle', - { - defaultMessage: 'Warning', - } - ), - criticalDeprecationsTitle: i18n.translate( - 'xpack.upgradeAssistant.kibanaDeprecationStats.criticalDeprecationsTitle', - { - defaultMessage: 'Critical', - } - ), - loadingError: i18n.translate( - 'xpack.upgradeAssistant.kibanaDeprecationStats.loadingErrorMessage', - { - defaultMessage: 'An error occurred while retrieving Kibana deprecations.', - } - ), -}; - -interface Props { - setIsFixed: (isFixed: boolean) => void; -} - -export const KibanaDeprecationStats: FunctionComponent = ({ setIsFixed }) => { - const history = useHistory(); - const { - services: { - core: { deprecations }, - }, - } = useAppContext(); - - const [kibanaDeprecations, setKibanaDeprecations] = useState< - DomainDeprecationDetails[] | undefined - >(undefined); - const [isLoading, setIsLoading] = useState(false); - const [error, setError] = useState(undefined); - - useEffect(() => { - async function getAllDeprecations() { - setIsLoading(true); - - try { - const response = await deprecations.getAllDeprecations(); - setKibanaDeprecations(response); - } catch (e) { - setError(e); - } - - setIsLoading(false); - } - - getAllDeprecations(); - }, [deprecations]); - - const warningDeprecationsCount = - kibanaDeprecations?.filter((deprecation) => deprecation.level === 'warning')?.length ?? 0; - const criticalDeprecationsCount = - kibanaDeprecations?.filter((deprecation) => deprecation.level === 'critical')?.length ?? 0; - - useEffect(() => { - if (!isLoading && !error) { - setIsFixed(criticalDeprecationsCount === 0); - } - }, [setIsFixed, criticalDeprecationsCount, isLoading, error]); - - const hasCritical = criticalDeprecationsCount > 0; - const hasWarnings = warningDeprecationsCount > 0; - const hasNoDeprecations = !isLoading && !error && !hasWarnings && !hasCritical; - const shouldRenderStat = (forSection: boolean) => error || isLoading || forSection; - - return ( - - {i18nTexts.statsTitle} - {error && ( - - )} - - } - {...(!hasNoDeprecations && reactRouterNavigate(history, '/kibana_deprecations'))} - > - - - {hasNoDeprecations && ( - - - - )} - - {shouldRenderStat(hasCritical) && ( - - - - )} - - {shouldRenderStat(hasWarnings) && ( - - - - )} - - - ); -}; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/no_deprecations/index.ts b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/no_deprecations/index.ts deleted file mode 100644 index a2684505eb9c6..0000000000000 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/no_deprecations/index.ts +++ /dev/null @@ -1,8 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export { NoDeprecations } from './no_deprecations'; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/no_deprecations/no_deprecations.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/no_deprecations/no_deprecations.tsx deleted file mode 100644 index bed92d3b92ccf..0000000000000 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/no_deprecations/no_deprecations.tsx +++ /dev/null @@ -1,35 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React, { FunctionComponent } from 'react'; - -import { EuiFlexGroup, EuiFlexItem, EuiText, EuiIcon, EuiSpacer } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; - -const i18nTexts = { - noDeprecationsText: i18n.translate('xpack.upgradeAssistant.noDeprecationsText', { - defaultMessage: 'No warnings. Good to go!', - }), -}; - -export const NoDeprecations: FunctionComponent = () => { - return ( - <> - - - - - - - - {i18nTexts.noDeprecationsText} - - - - - ); -};