Skip to content

Commit

Permalink
[Snapshot Restore] Migrate all usages of EuiPage*_Deprecated (#163130)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitstart authored Aug 21, 2023
1 parent dc3b486 commit 0317ace
Show file tree
Hide file tree
Showing 14 changed files with 297 additions and 382 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,13 @@ describe('<SnapshotRestoreHome />', () => {
test('should display an empty prompt', () => {
const { exists } = testBed;

expect(exists('emptyPrompt')).toBe(true);
expect(exists('snapshotListEmpty')).toBe(true);
});

test('should invite the user to first register a repository', () => {
const { find, exists } = testBed;
expect(find('emptyPrompt.title').text()).toBe('Start by registering a repository');
expect(exists('emptyPrompt.registerRepositoryButton')).toBe(true);
expect(find('snapshotListEmpty.title').text()).toBe('Start by registering a repository');
expect(exists('snapshotListEmpty.registerRepositoryButton')).toBe(true);
});
});

Expand Down
41 changes: 19 additions & 22 deletions x-pack/plugins/snapshot_restore/public/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import React from 'react';
import { Redirect } from 'react-router-dom';
import { Routes, Route } from '@kbn/shared-ux-router';
import { EuiPageContent_Deprecated as EuiPageContent } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';

import { APP_WRAPPER_CLASS } from '@kbn/core/public';
Expand Down Expand Up @@ -87,27 +86,25 @@ export const App: React.FunctionComponent = () => {
</Routes>
</div>
) : (
<EuiPageContent verticalPosition="center" horizontalPosition="center" color="subdued">
<NotAuthorizedSection
title={
<FormattedMessage
id="xpack.snapshotRestore.app.deniedPrivilegeTitle"
defaultMessage="You're missing cluster privileges"
/>
}
message={
<FormattedMessage
id="xpack.snapshotRestore.app.deniedPrivilegeDescription"
defaultMessage="To use Snapshot and Restore, you must have {privilegesCount,
plural, one {this cluster privilege} other {these cluster privileges}}: {missingPrivileges}."
values={{
missingPrivileges: privilegesMissing.cluster!.join(', '),
privilegesCount: privilegesMissing.cluster!.length,
}}
/>
}
/>
</EuiPageContent>
<NotAuthorizedSection
title={
<FormattedMessage
id="xpack.snapshotRestore.app.deniedPrivilegeTitle"
defaultMessage="You're missing cluster privileges"
/>
}
message={
<FormattedMessage
id="xpack.snapshotRestore.app.deniedPrivilegeDescription"
defaultMessage="To use Snapshot and Restore, you must have {privilegesCount,
plural, one {this cluster privilege} other {these cluster privileges}}: {missingPrivileges}."
values={{
missingPrivileges: privilegesMissing.cluster!.join(', '),
privilegesCount: privilegesMissing.cluster!.length,
}}
/>
}
/>
)
}
</WithPrivileges>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiTextColor,
EuiPageContent_Deprecated as EuiPageContent,
EuiPageTemplate,
} from '@elastic/eui';

interface Props {
Expand Down Expand Up @@ -55,12 +55,10 @@ export const SectionLoading: React.FunctionComponent<Props> = ({ children }) =>
*/
export const PageLoading: React.FunctionComponent<Props> = ({ children }) => {
return (
<EuiPageContent verticalPosition="center" horizontalPosition="center" color="subdued">
<EuiEmptyPrompt
title={<EuiLoadingSpinner size="xl" />}
body={<EuiText color="subdued">{children}</EuiText>}
data-test-subj="sectionLoading"
/>
</EuiPageContent>
<EuiPageTemplate.EmptyPrompt
title={<EuiLoadingSpinner size="xl" />}
body={<EuiText color="subdued">{children}</EuiText>}
data-test-subj="sectionLoading"
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@
import React, { Fragment, useEffect } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { RouteComponentProps } from 'react-router-dom';
import {
EuiPageContent_Deprecated as EuiPageContent,
EuiEmptyPrompt,
EuiButton,
EuiCallOut,
EuiSpacer,
} from '@elastic/eui';
import { EuiButton, EuiCallOut, EuiSpacer, EuiPageTemplate } from '@elastic/eui';

import { reactRouterNavigate } from '@kbn/kibana-react-plugin/public';

Expand Down Expand Up @@ -123,48 +117,41 @@ export const PolicyList: React.FunctionComponent<RouteComponentProps<MatchParams
);
} else if (policies && policies.length === 0) {
content = (
<EuiPageContent
hasShadow={false}
paddingSize="none"
verticalPosition="center"
horizontalPosition="center"
>
<EuiEmptyPrompt
iconType="managementApp"
title={
<h1>
<FormattedMessage
id="xpack.snapshotRestore.policyList.emptyPromptTitle"
defaultMessage="Create your first snapshot policy"
/>
</h1>
}
body={
<Fragment>
<p>
<FormattedMessage
id="xpack.snapshotRestore.policyList.emptyPromptDescription"
defaultMessage="A policy automates the creation and deletion of snapshots."
/>
</p>
</Fragment>
}
actions={
<EuiButton
{...reactRouterNavigate(history, linkToAddPolicy())}
fill
iconType="plusInCircle"
data-test-subj="createPolicyButton"
>
<EuiPageTemplate.EmptyPrompt
iconType="managementApp"
title={
<h1>
<FormattedMessage
id="xpack.snapshotRestore.policyList.emptyPromptTitle"
defaultMessage="Create your first snapshot policy"
/>
</h1>
}
body={
<Fragment>
<p>
<FormattedMessage
id="xpack.snapshotRestore.createPolicyButton"
defaultMessage="Create a policy"
id="xpack.snapshotRestore.policyList.emptyPromptDescription"
defaultMessage="A policy automates the creation and deletion of snapshots."
/>
</EuiButton>
}
data-test-subj="emptyPrompt"
/>
</EuiPageContent>
</p>
</Fragment>
}
actions={
<EuiButton
{...reactRouterNavigate(history, linkToAddPolicy())}
fill
iconType="plusInCircle"
data-test-subj="createPolicyButton"
>
<FormattedMessage
id="xpack.snapshotRestore.createPolicyButton"
defaultMessage="Create a policy"
/>
</EuiButton>
}
data-test-subj="emptyPrompt"
/>
);
} else {
const policySchedules = policies.map((policy: SlmPolicy) => policy.schedule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
import React, { Fragment, useEffect } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { RouteComponentProps } from 'react-router-dom';
import {
EuiPageContent_Deprecated as EuiPageContent,
EuiButton,
EuiEmptyPrompt,
} from '@elastic/eui';
import { EuiButton, EuiPageTemplate } from '@elastic/eui';

import { reactRouterNavigate } from '@kbn/kibana-react-plugin/public';

Expand Down Expand Up @@ -102,48 +98,41 @@ export const RepositoryList: React.FunctionComponent<RouteComponentProps<MatchPa
);
} else if (repositories && repositories.length === 0) {
content = (
<EuiPageContent
hasShadow={false}
paddingSize="none"
verticalPosition="center"
horizontalPosition="center"
>
<EuiEmptyPrompt
iconType="managementApp"
title={
<h1>
<FormattedMessage
id="xpack.snapshotRestore.repositoryList.emptyPromptTitle"
defaultMessage="Register your first repository"
/>
</h1>
}
body={
<Fragment>
<p>
<FormattedMessage
id="xpack.snapshotRestore.repositoryList.emptyPromptDescription"
defaultMessage="Create a place where your snapshots will live."
/>
</p>
</Fragment>
}
actions={
<EuiButton
{...reactRouterNavigate(history, linkToAddRepository())}
fill
iconType="plusInCircle"
data-test-subj="registerRepositoryButton"
>
<EuiPageTemplate.EmptyPrompt
iconType="managementApp"
title={
<h1>
<FormattedMessage
id="xpack.snapshotRestore.repositoryList.emptyPromptTitle"
defaultMessage="Register your first repository"
/>
</h1>
}
body={
<Fragment>
<p>
<FormattedMessage
id="xpack.snapshotRestore.addRepositoryButtonLabel"
defaultMessage="Register a repository"
id="xpack.snapshotRestore.repositoryList.emptyPromptDescription"
defaultMessage="Create a place where your snapshots will live."
/>
</EuiButton>
}
data-test-subj="emptyPrompt"
/>
</EuiPageContent>
</p>
</Fragment>
}
actions={
<EuiButton
{...reactRouterNavigate(history, linkToAddRepository())}
fill
iconType="plusInCircle"
data-test-subj="registerRepositoryButton"
>
<FormattedMessage
id="xpack.snapshotRestore.addRepositoryButtonLabel"
defaultMessage="Register a repository"
/>
</EuiButton>
}
data-test-subj="emptyPrompt"
/>
);
} else {
content = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import React, { useEffect, useState, Fragment } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import {
EuiPageContent_Deprecated as EuiPageContent,
EuiEmptyPrompt,
EuiPopover,
EuiButtonEmpty,
EuiContextMenuPanel,
Expand All @@ -19,6 +17,7 @@ import {
EuiSpacer,
EuiLoadingSpinner,
EuiLink,
EuiPageTemplate,
} from '@elastic/eui';
import { reactRouterNavigate } from '@kbn/kibana-react-plugin/public';
import { APP_RESTORE_INDEX_PRIVILEGES } from '../../../../../common';
Expand Down Expand Up @@ -106,45 +105,38 @@ export const RestoreList: React.FunctionComponent = () => {
} else {
if (restores && restores.length === 0) {
content = (
<EuiPageContent
hasShadow={false}
paddingSize="none"
verticalPosition="center"
horizontalPosition="center"
>
<EuiEmptyPrompt
iconType="managementApp"
title={
<h1 data-test-subj="noRestoredSnapshotsHeader">
<EuiPageTemplate.EmptyPrompt
iconType="managementApp"
title={
<h1 data-test-subj="noRestoredSnapshotsHeader">
<FormattedMessage
id="xpack.snapshotRestore.restoreList.emptyPromptTitle"
defaultMessage="No restored snapshots"
/>
</h1>
}
body={
<Fragment>
<p>
<FormattedMessage
id="xpack.snapshotRestore.restoreList.emptyPromptTitle"
defaultMessage="No restored snapshots"
id="xpack.snapshotRestore.restoreList.emptyPromptDescription"
defaultMessage="Go to {snapshotsLink} to start a restore."
values={{
snapshotsLink: (
<EuiLink {...reactRouterNavigate(history, linkToSnapshots())}>
<FormattedMessage
id="xpack.snapshotRestore.restoreList.emptyPromptDescriptionLink"
defaultMessage="Snapshots"
/>
</EuiLink>
),
}}
/>
</h1>
}
body={
<Fragment>
<p>
<FormattedMessage
id="xpack.snapshotRestore.restoreList.emptyPromptDescription"
defaultMessage="Go to {snapshotsLink} to start a restore."
values={{
snapshotsLink: (
<EuiLink {...reactRouterNavigate(history, linkToSnapshots())}>
<FormattedMessage
id="xpack.snapshotRestore.restoreList.emptyPromptDescriptionLink"
defaultMessage="Snapshots"
/>
</EuiLink>
),
}}
/>
</p>
</Fragment>
}
data-test-subj="emptyPrompt"
/>
</EuiPageContent>
</p>
</Fragment>
}
data-test-subj="emptyPrompt"
/>
);
} else {
content = (
Expand Down
Loading

0 comments on commit 0317ace

Please sign in to comment.