Skip to content

Commit

Permalink
[Upgrade Assistant] Migrate to new page layout (#101691)
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth authored Jun 10, 2021
1 parent 85fa7c8 commit 7dfb086
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ describe('Kibana deprecations', () => {
component.update();

expect(exists('kibanaRequestError')).toBe(true);
expect(find('kibanaRequestError').text()).toContain(
'Could not retrieve Kibana deprecations.'
);
expect(find('kibanaRequestError').text()).toContain('Could not retrieve Kibana deprecations');
});

test('handles deprecation service error', async () => {
Expand Down Expand Up @@ -217,7 +215,7 @@ describe('Kibana deprecations', () => {
// Verify top-level callout renders
expect(exists('kibanaPluginError')).toBe(true);
expect(find('kibanaPluginError').text()).toContain(
'Not all Kibana deprecations were retrieved successfully.'
'Not all Kibana deprecations were retrieved successfully'
);

// Open all deprecations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const ComingSoonPrompt: React.FunctionComponent = () => {
const { ELASTIC_WEBSITE_URL } = docLinks;

return (
<EuiPageContent>
<EuiPageContent verticalPosition="center" horizontalPosition="center" color="subdued">
<EuiEmptyPrompt
iconType="wrench"
data-test-subj="comingSoonPrompt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import { withRouter, RouteComponentProps } from 'react-router-dom';
import {
EuiButton,
EuiButtonEmpty,
EuiPageBody,
EuiPageHeader,
EuiTabbedContent,
EuiTabbedContentTab,
EuiPageContent,
EuiPageContentBody,
EuiToolTip,
EuiNotificationBadge,
EuiSpacer,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';

Expand Down Expand Up @@ -162,51 +160,49 @@ export const EsDeprecationsContent = withRouter(
}, [api, tabName, isLoading]);

return (
<EuiPageBody>
<EuiPageContent>
<EuiPageHeader
pageTitle={i18nTexts.pageTitle}
description={i18nTexts.pageDescription}
rightSideItems={[
<EuiButtonEmpty
href={docLinks.links.upgradeAssistant}
target="_blank"
iconType="help"
data-test-subj="documentationLink"
>
{i18nTexts.docLinkText}
</EuiButtonEmpty>,
]}
>
<EuiToolTip position="bottom" content={i18nTexts.backupDataButton.tooltipText}>
<EuiButton
fill
href={getUrlForApp('management', {
path: 'data/snapshot_restore',
})}
iconType="popout"
iconSide="right"
target="_blank"
>
{i18nTexts.backupDataButton.label}
</EuiButton>
</EuiToolTip>
</EuiPageHeader>

<EuiPageContentBody>
<EuiTabbedContent
data-test-subj={
telemetryState === TelemetryState.Running
? 'upgradeAssistantTelemetryRunning'
: undefined
}
tabs={tabs}
onTabClick={onTabClick}
selectedTab={tabs.find((tab) => tab.id === tabName)}
/>
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
<>
<EuiPageHeader
pageTitle={i18nTexts.pageTitle}
description={i18nTexts.pageDescription}
rightSideItems={[
<EuiButtonEmpty
href={docLinks.links.upgradeAssistant}
target="_blank"
iconType="help"
data-test-subj="documentationLink"
>
{i18nTexts.docLinkText}
</EuiButtonEmpty>,
]}
>
<EuiToolTip position="bottom" content={i18nTexts.backupDataButton.tooltipText}>
<EuiButton
fill
href={getUrlForApp('management', {
path: 'data/snapshot_restore',
})}
iconType="popout"
iconSide="right"
target="_blank"
>
{i18nTexts.backupDataButton.label}
</EuiButton>
</EuiToolTip>
</EuiPageHeader>

<EuiSpacer size="l" />

<EuiTabbedContent
data-test-subj={
telemetryState === TelemetryState.Running
? 'upgradeAssistantTelemetryRunning'
: undefined
}
tabs={tabs}
onTabClick={onTabClick}
selectedTab={tabs.find((tab) => tab.id === tabName)}
/>
</>
);
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,67 @@

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiCallOut } from '@elastic/eui';
import { EuiPageContent, EuiEmptyPrompt } from '@elastic/eui';

interface Props {
errorType: 'pluginError' | 'requestError';
}

const i18nTexts = {
pluginError: i18n.translate('xpack.upgradeAssistant.kibanaDeprecationErrors.pluginErrorMessage', {
defaultMessage:
'Not all Kibana deprecations were retrieved successfully. This list may be incomplete. Check the Kibana server logs for errors.',
}),
loadingError: i18n.translate(
'xpack.upgradeAssistant.kibanaDeprecationErrors.loadingErrorMessage',
{
defaultMessage:
'Could not retrieve Kibana deprecations. Check the Kibana server logs for errors.',
}
),
pluginError: {
title: i18n.translate('xpack.upgradeAssistant.kibanaDeprecationErrors.pluginErrorTitle', {
defaultMessage: 'Not all Kibana deprecations were retrieved successfully',
}),
description: i18n.translate(
'xpack.upgradeAssistant.kibanaDeprecationErrors.pluginErrorDescription',
{
defaultMessage: 'Check the Kibana server logs for errors.',
}
),
},
loadingError: {
title: i18n.translate('xpack.upgradeAssistant.kibanaDeprecationErrors.loadingErrorTitle', {
defaultMessage: 'Could not retrieve Kibana deprecations',
}),
description: i18n.translate(
'xpack.upgradeAssistant.kibanaDeprecationErrors.loadingErrorDescription',
{
defaultMessage: 'Check the Kibana server logs for errors.',
}
),
},
};

export const KibanaDeprecationErrors: React.FunctionComponent<Props> = ({ errorType }) => {
if (errorType === 'pluginError') {
return (
<EuiCallOut
title={i18nTexts.pluginError}
color="warning"
iconType="alert"
<EuiPageContent
verticalPosition="center"
horizontalPosition="center"
color="danger"
data-test-subj="kibanaPluginError"
/>
>
<EuiEmptyPrompt
iconType="alert"
title={<h2>{i18nTexts.pluginError.title}</h2>}
body={<p>{i18nTexts.pluginError.description}</p>}
/>
</EuiPageContent>
);
}

return (
<EuiCallOut
title={i18nTexts.loadingError}
<EuiPageContent
verticalPosition="center"
horizontalPosition="center"
color="danger"
iconType="alert"
data-test-subj="kibanaRequestError"
/>
>
<EuiEmptyPrompt
iconType="alert"
title={<h2>{i18nTexts.loadingError.title}</h2>}
body={<p>{i18nTexts.loadingError.description}</p>}
/>
</EuiPageContent>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@
import React, { useEffect, useState, useCallback } from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';

import {
EuiButtonEmpty,
EuiPageBody,
EuiPageHeader,
EuiPageContent,
EuiPageContentBody,
EuiSpacer,
} from '@elastic/eui';
import { EuiButtonEmpty, EuiPageContent, EuiPageHeader, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import type { DomainDeprecationDetails } from 'kibana/public';
Expand Down Expand Up @@ -135,46 +128,28 @@ export const KibanaDeprecationsContent = withRouter(({ history }: RouteComponent
getAllDeprecations();
}, [deprecations, getAllDeprecations]);

const getPageContent = () => {
if (kibanaDeprecations && kibanaDeprecations.length === 0) {
return (
if (kibanaDeprecations && kibanaDeprecations.length === 0) {
return (
<EuiPageContent verticalPosition="center" horizontalPosition="center" color="subdued">
<NoDeprecationsPrompt
deprecationType={i18nTexts.deprecationLabel}
navigateToOverviewPage={() => history.push('/overview')}
/>
);
}

let content: React.ReactNode;

if (isLoading) {
content = <SectionLoading>{i18nTexts.isLoading}</SectionLoading>;
} else if (kibanaDeprecations?.length) {
content = (
<KibanaDeprecationList
deprecations={kibanaDeprecations}
showStepsModal={toggleStepsModal}
showResolveModal={toggleResolveModal}
reloadDeprecations={getAllDeprecations}
isLoading={isLoading}
/>
);
} else if (error) {
content = <KibanaDeprecationErrors errorType="requestError" />;
}
</EuiPageContent>
);
}

if (isLoading) {
return (
<div data-test-subj="kibanaDeprecationsContent">
<EuiSpacer />
{content}
</div>
<EuiPageContent verticalPosition="center" horizontalPosition="center" color="subdued">
<SectionLoading>{i18nTexts.isLoading}</SectionLoading>
</EuiPageContent>
);
};

return (
<EuiPageBody>
<EuiPageContent>
} else if (kibanaDeprecations?.length) {
return (
<div data-test-subj="kibanaDeprecationsContent">
<EuiPageHeader
bottomBorder
pageTitle={i18nTexts.pageTitle}
description={i18nTexts.pageDescription}
rightSideItems={[
Expand All @@ -189,23 +164,33 @@ export const KibanaDeprecationsContent = withRouter(({ history }: RouteComponent
]}
/>

<EuiPageContentBody>
{getPageContent()}

{stepsModalContent && (
<StepsModal closeModal={() => toggleStepsModal()} modalContent={stepsModalContent} />
)}

{resolveModalContent && (
<ResolveDeprecationModal
closeModal={() => toggleResolveModal()}
resolveDeprecation={resolveDeprecation}
isResolvingDeprecation={isResolvingDeprecation}
deprecation={resolveModalContent}
/>
)}
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
);
<EuiSpacer size="l" />

<KibanaDeprecationList
deprecations={kibanaDeprecations}
showStepsModal={toggleStepsModal}
showResolveModal={toggleResolveModal}
reloadDeprecations={getAllDeprecations}
isLoading={isLoading}
/>

{stepsModalContent && (
<StepsModal closeModal={() => toggleStepsModal()} modalContent={stepsModalContent} />
)}

{resolveModalContent && (
<ResolveDeprecationModal
closeModal={() => toggleResolveModal()}
resolveDeprecation={resolveDeprecation}
isResolvingDeprecation={isResolvingDeprecation}
deprecation={resolveModalContent}
/>
)}
</div>
);
} else if (error) {
return <KibanaDeprecationErrors errorType="requestError" />;
}

return null;
});
Loading

0 comments on commit 7dfb086

Please sign in to comment.