From 71bfe79f3be55980737ff3152f197c750073b585 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Tue, 21 Sep 2021 14:49:32 -0700 Subject: [PATCH] Improve error states for Upgrade Assistant deprecation issues (#112457) * Simplify error state for deprecation issues panels. Remove . * Rename components from stats -> panel. * Create common error-reporting component for use in both Kibana and ES deprecations pages. * Align order of loading, error, and success states between these pages. * Change references to 'deprecations' -> 'deprecation issues'. * Fix tests for panels. * Add API integration test for handling auth error. * Fix TS errors. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../es_deprecations/error_handling.test.ts | 34 ++--- .../error_handling.test.ts | 7 +- .../elasticsearch_deprecation_issues.test.tsx | 22 ++-- .../kibana_deprecation_issues.test.tsx | 6 +- .../plugins/upgrade_assistant/common/types.ts | 2 + .../es_deprecations/es_deprecation_errors.tsx | 50 -------- .../es_deprecations/es_deprecations.tsx | 11 +- .../kibana_deprecations.tsx | 118 +++++++----------- .../components/_es_stats_error.scss | 7 -- .../components/deprecation_issues_panel.tsx | 17 ++- ...ts.tsx => es_deprecation_issues_panel.tsx} | 6 +- .../components/es_stats_error.tsx | 84 ------------- .../fix_issues_step/components/index.ts | 4 +- ...sx => kibana_deprecation_issues_panel.tsx} | 22 +--- .../components/loading_issues_error.tsx | 21 ++++ .../fix_issues_step/fix_issues_step.tsx | 6 +- .../deprecations_page_loading_error.tsx | 42 +++++++ .../application/components/shared/index.ts | 1 + .../lib/get_es_deprecation_error.ts | 4 +- .../apis/upgrade_assistant/es_deprecations.ts | 41 ++++++ .../apis/upgrade_assistant/index.ts | 1 + 21 files changed, 219 insertions(+), 287 deletions(-) delete mode 100644 x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecation_errors.tsx delete mode 100644 x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/_es_stats_error.scss rename x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/{es_stats.tsx => es_deprecation_issues_panel.tsx} (84%) delete mode 100644 x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/es_stats_error.tsx rename x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/{kibana_stats.tsx => kibana_deprecation_issues_panel.tsx} (77%) create mode 100644 x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/loading_issues_error.tsx create mode 100644 x-pack/plugins/upgrade_assistant/public/application/components/shared/deprecations_page_loading_error.tsx create mode 100644 x-pack/test/api_integration/apis/upgrade_assistant/es_deprecations.ts diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecations/error_handling.test.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecations/error_handling.test.ts index 6314b4630f8503..2f0c8f0597ec3c 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecations/error_handling.test.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecations/error_handling.test.ts @@ -31,13 +31,10 @@ describe('Error handling', () => { testBed = await setupElasticsearchPage({ isReadOnlyMode: false }); }); - const { component, exists, find } = testBed; - + const { component, find } = testBed; component.update(); - - expect(exists('permissionsError')).toBe(true); - expect(find('permissionsError').text()).toContain( - 'You are not authorized to view Elasticsearch deprecations.' + expect(find('deprecationsPageLoadingError').text()).toContain( + 'You are not authorized to view Elasticsearch deprecation issues.' ); }); @@ -59,12 +56,11 @@ describe('Error handling', () => { testBed = await setupElasticsearchPage({ isReadOnlyMode: false }); }); - const { component, exists, find } = testBed; - + const { component, find } = testBed; component.update(); - - expect(exists('upgradedCallout')).toBe(true); - expect(find('upgradedCallout').text()).toContain('All Elasticsearch nodes have been upgraded.'); + expect(find('deprecationsPageLoadingError').text()).toContain( + 'All Elasticsearch nodes have been upgraded.' + ); }); it('shows partially upgrade error when nodes are running different versions', async () => { @@ -83,12 +79,9 @@ describe('Error handling', () => { testBed = await setupElasticsearchPage({ isReadOnlyMode: false }); }); - const { component, exists, find } = testBed; - + const { component, find } = testBed; component.update(); - - expect(exists('partiallyUpgradedWarning')).toBe(true); - expect(find('partiallyUpgradedWarning').text()).toContain( + expect(find('deprecationsPageLoadingError').text()).toContain( 'Upgrade Kibana to the same version as your Elasticsearch cluster. One or more nodes in the cluster is running a different version than Kibana.' ); }); @@ -106,11 +99,10 @@ describe('Error handling', () => { testBed = await setupElasticsearchPage({ isReadOnlyMode: false }); }); - const { component, exists, find } = testBed; - + const { component, find } = testBed; component.update(); - - expect(exists('requestError')).toBe(true); - expect(find('requestError').text()).toContain('Could not retrieve Elasticsearch deprecations.'); + expect(find('deprecationsPageLoadingError').text()).toContain( + 'Could not retrieve Elasticsearch deprecation issues.' + ); }); }); diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/error_handling.test.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/error_handling.test.ts index 83e0a884a31198..650af2025ee2bf 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/error_handling.test.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/error_handling.test.ts @@ -91,12 +91,9 @@ describe('Error handling', () => { }); }); - const { component, exists, find } = testBed; - + const { component, find } = testBed; component.update(); - - expect(exists('kibanaRequestError')).toBe(true); - expect(find('kibanaRequestError').text()).toContain( + expect(find('deprecationsPageLoadingError').text()).toContain( 'Could not retrieve Kibana deprecation issues' ); }); 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 index d3c92625c7a346..bbb8b049ec2b84 100644 --- 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 @@ -118,9 +118,11 @@ describe('Overview - Fix deprecation issues step - Elasticsearch deprecations', testBed = await setupOverviewPage(); }); - const { component, exists } = testBed; + const { component, find } = testBed; component.update(); - expect(exists('esRequestErrorIconTip')).toBe(true); + expect(find('loadingIssuesError').text()).toBe( + 'Could not retrieve Elasticsearch deprecation issues.' + ); }); test('handles unauthorized error', async () => { @@ -136,9 +138,11 @@ describe('Overview - Fix deprecation issues step - Elasticsearch deprecations', testBed = await setupOverviewPage(); }); - const { component, exists } = testBed; + const { component, find } = testBed; component.update(); - expect(exists('unauthorizedErrorIconTip')).toBe(true); + expect(find('loadingIssuesError').text()).toBe( + 'You are not authorized to view Elasticsearch deprecation issues.' + ); }); test('handles partially upgraded error', async () => { @@ -157,9 +161,11 @@ describe('Overview - Fix deprecation issues step - Elasticsearch deprecations', testBed = await setupOverviewPage({ isReadOnlyMode: false }); }); - const { component, exists } = testBed; + const { component, find } = testBed; component.update(); - expect(exists('partiallyUpgradedErrorIconTip')).toBe(true); + expect(find('loadingIssuesError').text()).toBe( + 'Upgrade Kibana to the same version as your Elasticsearch cluster. One or more nodes in the cluster is running a different version than Kibana.' + ); }); test('handles upgrade error', async () => { @@ -178,9 +184,9 @@ describe('Overview - Fix deprecation issues step - Elasticsearch deprecations', testBed = await setupOverviewPage({ isReadOnlyMode: false }); }); - const { component, exists } = testBed; + const { component, find } = testBed; component.update(); - expect(exists('upgradedErrorIconTip')).toBe(true); + expect(find('loadingIssuesError').text()).toBe('All Elasticsearch nodes have been upgraded.'); }); }); }); 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 index a6d4e012047818..65d413d5ec433c 100644 --- 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 @@ -122,9 +122,11 @@ describe('Overview - Fix deprecation issues step - Kibana deprecations', () => { }); }); - const { component, exists } = testBed; + const { component, find } = testBed; component.update(); - expect(exists('kibanaRequestErrorIconTip')).toBe(true); + expect(find('loadingIssuesError').text()).toBe( + 'Could not retrieve Kibana deprecation issues.' + ); }); }); }); diff --git a/x-pack/plugins/upgrade_assistant/common/types.ts b/x-pack/plugins/upgrade_assistant/common/types.ts index 6fd298dc9e003c..7f2d675cb1b1f7 100644 --- a/x-pack/plugins/upgrade_assistant/common/types.ts +++ b/x-pack/plugins/upgrade_assistant/common/types.ts @@ -11,6 +11,8 @@ import { } from '@elastic/elasticsearch/api/types'; import { SavedObject, SavedObjectAttributes } from 'src/core/public'; +export type DeprecationSource = 'Kibana' | 'Elasticsearch'; + export enum ReindexStep { // Enum values are spaced out by 10 to give us room to insert steps in between. created = 0, diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecation_errors.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecation_errors.tsx deleted file mode 100644 index 5e3c7a5fe6cef9..00000000000000 --- a/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecation_errors.tsx +++ /dev/null @@ -1,50 +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 from 'react'; - -import { EuiCallOut } from '@elastic/eui'; - -import { ResponseError } from '../../lib/api'; -import { getEsDeprecationError } from '../../lib/get_es_deprecation_error'; -interface Props { - error: ResponseError; -} - -export const EsDeprecationErrors: React.FunctionComponent = ({ error }) => { - const { code: errorType, message } = getEsDeprecationError(error); - - switch (errorType) { - case 'unauthorized_error': - return ( - - ); - case 'partially_upgraded_error': - return ( - - ); - case 'upgraded_error': - return ; - case 'request_error': - default: - return ( - - {error.message} - - ); - } -}; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations.tsx index 27908bd07b9513..4e1494fab1b0e2 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations.tsx @@ -14,9 +14,9 @@ import { i18n } from '@kbn/i18n'; import { EnrichedDeprecationInfo } from '../../../../common/types'; import { SectionLoading } from '../../../shared_imports'; import { useAppContext } from '../../app_context'; +import { getEsDeprecationError } from '../../lib/get_es_deprecation_error'; +import { DeprecationsPageLoadingError, NoDeprecationsPrompt, DeprecationCount } from '../shared'; import { EsDeprecationsTable } from './es_deprecations_table'; -import { EsDeprecationErrors } from './es_deprecation_errors'; -import { NoDeprecationsPrompt, DeprecationCount } from '../shared'; const getDeprecationCountByLevel = (deprecations: EnrichedDeprecationInfo[]) => { const criticalDeprecations: EnrichedDeprecationInfo[] = []; @@ -87,7 +87,12 @@ export const EsDeprecations = withRouter(({ history }: RouteComponentProps) => { }, [api, isLoading, isInitialRequest]); if (error) { - return ; + return ( + + ); } if (isLoading) { diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecations.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecations.tsx index 35fc7127dfe0a5..23697b00923c89 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecations.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecations.tsx @@ -8,14 +8,14 @@ import React, { useEffect, useState, useCallback, useMemo } from 'react'; import uuid from 'uuid'; import { withRouter, RouteComponentProps } from 'react-router-dom'; -import { EuiPageContent, EuiPageHeader, EuiSpacer, EuiCallOut, EuiEmptyPrompt } from '@elastic/eui'; +import { EuiPageContent, EuiPageHeader, EuiSpacer, EuiCallOut } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import type { DomainDeprecationDetails } from 'kibana/public'; import { SectionLoading, GlobalFlyout } from '../../../shared_imports'; import { useAppContext } from '../../app_context'; -import { NoDeprecationsPrompt, DeprecationCount } from '../shared'; +import { DeprecationsPageLoadingError, NoDeprecationsPrompt, DeprecationCount } from '../shared'; import { KibanaDeprecationsTable } from './kibana_deprecations_table'; import { DeprecationDetailsFlyout, @@ -67,15 +67,6 @@ const i18nTexts = { pluginIds: pluginIds.join(', '), }, }), - requestErrorTitle: i18n.translate('xpack.upgradeAssistant.kibanaDeprecations.requestErrorTitle', { - defaultMessage: 'Could not retrieve Kibana deprecation issues', - }), - requestErrorDescription: i18n.translate( - 'xpack.upgradeAssistant.kibanaDeprecationErrors.requestErrorDescription', - { - defaultMessage: 'Check the Kibana server logs for errors.', - } - ), }; export interface DeprecationResolutionState { @@ -251,15 +242,8 @@ export const KibanaDeprecations = withRouter(({ history }: RouteComponentProps) getAllDeprecations(); }, [deprecations, getAllDeprecations]); - if (kibanaDeprecations && kibanaDeprecations.length === 0) { - return ( - - history.push('/overview')} - /> - - ); + if (error) { + return ; } if (isLoading) { @@ -270,63 +254,53 @@ export const KibanaDeprecations = withRouter(({ history }: RouteComponentProps) ); } - if (kibanaDeprecations?.length) { + if (kibanaDeprecations?.length === 0) { return ( -
- - - - - - - {kibanaDeprecationErrors.length > 0 && ( - <> - -

{i18nTexts.getKibanaDeprecationErrorDescription(kibanaDeprecationErrors)}

-
- - - - )} - - + history.push('/overview')} /> -
+ ); } - if (error) { - return ( - + - {i18nTexts.requestErrorTitle}} - body={

{i18nTexts.requestErrorDescription}

} + -
- ); - } - - return null; + + + + + {kibanaDeprecationErrors.length > 0 && ( + <> + +

{i18nTexts.getKibanaDeprecationErrorDescription(kibanaDeprecationErrors)}

+
+ + + + )} + + + + ); }); 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 deleted file mode 100644 index 92c92d96c31a26..00000000000000 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/_es_stats_error.scss +++ /dev/null @@ -1,7 +0,0 @@ -/* - * 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 index d5b94b89f54439..084e4528694dd3 100644 --- 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 @@ -11,7 +11,9 @@ import { EuiCard, EuiStat, EuiSpacer, EuiFlexGroup, EuiFlexItem } from '@elastic import { i18n } from '@kbn/i18n'; import { reactRouterNavigate } from '../../../../../shared_imports'; +import { DeprecationSource } from '../../../../../../common/types'; import { getDeprecationsUpperLimit } from '../../../../lib/utils'; +import { LoadingIssuesError } from './loading_issues_error'; import { NoDeprecationIssues } from './no_deprecation_issues'; import './_deprecation_issues_panel.scss'; @@ -33,12 +35,12 @@ const i18nTexts = { interface Props { 'data-test-subj': string; - deprecationSource: string; + deprecationSource: DeprecationSource; linkUrl: string; criticalDeprecationsCount: number; warningDeprecationsCount: number; isLoading: boolean; - errorMessage?: JSX.Element | null; + errorMessage?: JSX.Element | string | null; setIsFixed: (isFixed: boolean) => void; } @@ -70,17 +72,14 @@ export const DeprecationIssuesPanel = (props: Props) => { data-test-subj={props['data-test-subj']} className="upgDeprecationIssuesPanel" layout="horizontal" - title={ - <> - {deprecationSource} - {hasError && errorMessage} - - } + title={deprecationSource} {...(!hasNoIssues && reactRouterNavigate(history, linkUrl))} > - {hasNoIssues ? ( + {hasError ? ( + {errorMessage} + ) : hasNoIssues ? ( ) : ( 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_deprecation_issues_panel.tsx similarity index 84% rename from x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/es_stats.tsx rename to x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/es_deprecation_issues_panel.tsx index 89860d5b58be48..b4258ababc92e9 100644 --- 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_deprecation_issues_panel.tsx @@ -8,14 +8,14 @@ import React, { FunctionComponent } from 'react'; import { useAppContext } from '../../../../app_context'; -import { EsStatsErrors } from './es_stats_error'; +import { getEsDeprecationError } from '../../../../lib/get_es_deprecation_error'; import { DeprecationIssuesPanel } from './deprecation_issues_panel'; interface Props { setIsFixed: (isFixed: boolean) => void; } -export const ElasticsearchDeprecationStats: FunctionComponent = ({ setIsFixed }) => { +export const EsDeprecationIssuesPanel: FunctionComponent = ({ setIsFixed }) => { const { services: { api }, } = useAppContext(); @@ -29,7 +29,7 @@ export const ElasticsearchDeprecationStats: FunctionComponent = ({ setIsF esDeprecations?.deprecations?.filter((deprecation) => deprecation.isCritical === false) ?.length ?? 0; - const errorMessage = error && ; + const errorMessage = error && getEsDeprecationError(error).message; return ( = ({ error }) => { - let iconContent: React.ReactNode; - - const { code: errorType, message } = getEsDeprecationError(error); - - switch (errorType) { - case 'unauthorized_error': - iconContent = ( - - ); - break; - - case 'partially_upgraded_error': - iconContent = ( - - ); - break; - - case 'upgraded_error': - iconContent = ( - - ); - break; - - case 'request_error': - default: - iconContent = ( - - ); - } - - return {iconContent}; -}; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/index.ts b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/index.ts index fe3a0dd2ceaff4..a2a3219002719f 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/index.ts +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/index.ts @@ -5,5 +5,5 @@ * 2.0. */ -export { ElasticsearchDeprecationStats } from './es_stats'; -export { KibanaDeprecationStats } from './kibana_stats'; +export { EsDeprecationIssuesPanel } from './es_deprecation_issues_panel'; +export { KibanaDeprecationIssuesPanel } from './kibana_deprecation_issues_panel'; 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_deprecation_issues_panel.tsx similarity index 77% rename from x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/kibana_stats.tsx rename to x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/components/kibana_deprecation_issues_panel.tsx index 891ccc01dcd40c..b0aa7b592e3a15 100644 --- 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_deprecation_issues_panel.tsx @@ -6,7 +6,6 @@ */ import React, { FunctionComponent, useEffect, useState } from 'react'; -import { EuiIconTip } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import type { DomainDeprecationDetails } from 'kibana/public'; @@ -17,7 +16,7 @@ interface Props { setIsFixed: (isFixed: boolean) => void; } -export const KibanaDeprecationStats: FunctionComponent = ({ setIsFixed }) => { +export const KibanaDeprecationIssuesPanel: FunctionComponent = ({ setIsFixed }) => { const { services: { core: { deprecations }, @@ -53,20 +52,11 @@ export const KibanaDeprecationStats: FunctionComponent = ({ setIsFixed }) const warningDeprecationsCount = kibanaDeprecations?.filter((deprecation) => deprecation.level === 'warning')?.length ?? 0; - const errorMessage = error && ( - - ); + const errorMessage = + error && + i18n.translate('xpack.upgradeAssistant.deprecationStats.loadingErrorMessage', { + defaultMessage: 'Could not retrieve Kibana deprecation issues.', + }); return ( ( + + + + + + + {children} + + +); 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 d4ecccdd5dc15c..b061ab5ea2d4d3 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 @@ -13,7 +13,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import type { EuiStepProps } from '@elastic/eui/src/components/steps/step'; import type { OverviewStepProps } from '../../types'; -import { ElasticsearchDeprecationStats, KibanaDeprecationStats } from './components'; +import { EsDeprecationIssuesPanel, KibanaDeprecationIssuesPanel } from './components'; const i18nTexts = { reviewStepTitle: i18n.translate('xpack.upgradeAssistant.overview.fixIssuesStepTitle', { @@ -43,11 +43,11 @@ const FixIssuesStep: FunctionComponent = ({ setIsComplete }) => { return ( - + - + ); diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/shared/deprecations_page_loading_error.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/shared/deprecations_page_loading_error.tsx new file mode 100644 index 00000000000000..01cf950abbc31c --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/public/application/components/shared/deprecations_page_loading_error.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 { EuiPageContent, EuiEmptyPrompt } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; + +import { DeprecationSource } from '../../../../common/types'; + +interface Props { + deprecationSource: DeprecationSource; + message?: string; +} + +export const DeprecationsPageLoadingError: FunctionComponent = ({ + deprecationSource, + message, +}) => ( + + + {i18n.translate('xpack.upgradeAssistant.deprecationsPageLoadingError.title', { + defaultMessage: 'Could not retrieve {deprecationSource} deprecation issues', + values: { deprecationSource }, + })} + + } + body={message} + /> + +); diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/shared/index.ts b/x-pack/plugins/upgrade_assistant/public/application/components/shared/index.ts index 9464b5ecb98ca5..ef7916f6e8d17b 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/shared/index.ts +++ b/x-pack/plugins/upgrade_assistant/public/application/components/shared/index.ts @@ -8,3 +8,4 @@ export { NoDeprecationsPrompt } from './no_deprecations'; export { DeprecationCount } from './deprecation_count'; export { DeprecationBadge } from './deprecation_badge'; +export { DeprecationsPageLoadingError } from './deprecations_page_loading_error'; diff --git a/x-pack/plugins/upgrade_assistant/public/application/lib/get_es_deprecation_error.ts b/x-pack/plugins/upgrade_assistant/public/application/lib/get_es_deprecation_error.ts index 85cfd2a3fd16c4..889568fb7a412b 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/lib/get_es_deprecation_error.ts +++ b/x-pack/plugins/upgrade_assistant/public/application/lib/get_es_deprecation_error.ts @@ -12,7 +12,7 @@ const i18nTexts = { permissionsError: i18n.translate( 'xpack.upgradeAssistant.esDeprecationErrors.permissionsErrorMessage', { - defaultMessage: 'You are not authorized to view Elasticsearch deprecations.', + defaultMessage: 'You are not authorized to view Elasticsearch deprecation issues.', } ), partiallyUpgradedWarning: i18n.translate( @@ -29,7 +29,7 @@ const i18nTexts = { } ), loadingError: i18n.translate('xpack.upgradeAssistant.esDeprecationErrors.loadingErrorMessage', { - defaultMessage: 'Could not retrieve Elasticsearch deprecations.', + defaultMessage: 'Could not retrieve Elasticsearch deprecation issues.', }), }; diff --git a/x-pack/test/api_integration/apis/upgrade_assistant/es_deprecations.ts b/x-pack/test/api_integration/apis/upgrade_assistant/es_deprecations.ts new file mode 100644 index 00000000000000..aea003a317963c --- /dev/null +++ b/x-pack/test/api_integration/apis/upgrade_assistant/es_deprecations.ts @@ -0,0 +1,41 @@ +/* + * 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 { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const supertestWithoutAuth = getService('supertestWithoutAuth'); + const security = getService('security'); + + describe('Elasticsearch deprecations', () => { + describe('GET /api/upgrade_assistant/es_deprecations', () => { + it('handles auth error', async () => { + const ROLE_NAME = 'authErrorRole'; + const USER_NAME = 'authErrorUser'; + const USER_PASSWORD = 'password'; + + try { + await security.role.create(ROLE_NAME, {}); + await security.user.create(USER_NAME, { + password: USER_PASSWORD, + roles: [ROLE_NAME], + }); + + await supertestWithoutAuth + .get('/api/upgrade_assistant/es_deprecations') + .auth(USER_NAME, USER_PASSWORD) + .set('kbn-xsrf', 'kibana') + .send() + .expect(403); + } finally { + await security.role.delete(ROLE_NAME); + await security.user.delete(USER_NAME); + } + }); + }); + }); +} diff --git a/x-pack/test/api_integration/apis/upgrade_assistant/index.ts b/x-pack/test/api_integration/apis/upgrade_assistant/index.ts index ddb71c59423bad..8d753dd661f5f7 100644 --- a/x-pack/test/api_integration/apis/upgrade_assistant/index.ts +++ b/x-pack/test/api_integration/apis/upgrade_assistant/index.ts @@ -11,5 +11,6 @@ export default function ({ loadTestFile }: FtrProviderContext) { describe('Upgrade Assistant', () => { loadTestFile(require.resolve('./upgrade_assistant')); loadTestFile(require.resolve('./cloud_backup_status')); + loadTestFile(require.resolve('./es_deprecations')); }); }