mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Upgrade Assistant] Clean up i18n (#89661)
This commit is contained in:
parent
8780a2de6e
commit
d6227fbb30
4 changed files with 77 additions and 70 deletions
|
@ -5,9 +5,9 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { shallowWithIntl } from '@kbn/test/jest';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import { IndexDeprecationTableProps, IndexDeprecationTableUI } from './index_table';
|
||||
import { IndexDeprecationTableProps, IndexDeprecationTable } from './index_table';
|
||||
|
||||
describe('IndexDeprecationTable', () => {
|
||||
const defaultProps = {
|
||||
|
@ -22,7 +22,7 @@ describe('IndexDeprecationTable', () => {
|
|||
// This test simply verifies that the props passed to EuiBaseTable are the ones
|
||||
// expected.
|
||||
test('render', () => {
|
||||
expect(shallowWithIntl(<IndexDeprecationTableUI {...defaultProps} />)).toMatchInlineSnapshot(`
|
||||
expect(shallow(<IndexDeprecationTable {...defaultProps} />)).toMatchInlineSnapshot(`
|
||||
<EuiBasicTable
|
||||
columns={
|
||||
Array [
|
||||
|
|
|
@ -8,7 +8,7 @@ import { sortBy } from 'lodash';
|
|||
import React from 'react';
|
||||
|
||||
import { EuiBasicTable } from '@elastic/eui';
|
||||
import { injectI18n } from '@kbn/i18n/react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { ReindexButton } from './reindex';
|
||||
import { AppContext } from '../../../../app_context';
|
||||
import { EnrichedDeprecationInfo } from '../../../../../../common/types';
|
||||
|
@ -22,7 +22,7 @@ export interface IndexDeprecationDetails {
|
|||
details?: string;
|
||||
}
|
||||
|
||||
export interface IndexDeprecationTableProps extends ReactIntl.InjectedIntlProps {
|
||||
export interface IndexDeprecationTableProps {
|
||||
indices: IndexDeprecationDetails[];
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ interface IndexDeprecationTableState {
|
|||
pageSize: number;
|
||||
}
|
||||
|
||||
export class IndexDeprecationTableUI extends React.Component<
|
||||
export class IndexDeprecationTable extends React.Component<
|
||||
IndexDeprecationTableProps,
|
||||
IndexDeprecationTableState
|
||||
> {
|
||||
|
@ -49,24 +49,27 @@ export class IndexDeprecationTableUI extends React.Component<
|
|||
}
|
||||
|
||||
public render() {
|
||||
const { intl } = this.props;
|
||||
const { pageIndex, pageSize, sortField, sortDirection } = this.state;
|
||||
|
||||
const columns = [
|
||||
{
|
||||
field: 'index',
|
||||
name: intl.formatMessage({
|
||||
id: 'xpack.upgradeAssistant.checkupTab.deprecations.indexTable.indexColumnLabel',
|
||||
defaultMessage: 'Index',
|
||||
}),
|
||||
name: i18n.translate(
|
||||
'xpack.upgradeAssistant.checkupTab.deprecations.indexTable.indexColumnLabel',
|
||||
{
|
||||
defaultMessage: 'Index',
|
||||
}
|
||||
),
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
field: 'details',
|
||||
name: intl.formatMessage({
|
||||
id: 'xpack.upgradeAssistant.checkupTab.deprecations.indexTable.detailsColumnLabel',
|
||||
defaultMessage: 'Details',
|
||||
}),
|
||||
name: i18n.translate(
|
||||
'xpack.upgradeAssistant.checkupTab.deprecations.indexTable.detailsColumnLabel',
|
||||
{
|
||||
defaultMessage: 'Details',
|
||||
}
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -169,5 +172,3 @@ export class IndexDeprecationTableUI extends React.Component<
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
export const IndexDeprecationTable = injectI18n(IndexDeprecationTableUI);
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
import React from 'react';
|
||||
|
||||
import { EuiLoadingSpinner, EuiSwitch } from '@elastic/eui';
|
||||
import { injectI18n } from '@kbn/i18n/react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { HttpSetup } from 'src/core/public';
|
||||
|
||||
import { LoadingState } from '../../types';
|
||||
|
||||
interface DeprecationLoggingTabProps extends ReactIntl.InjectedIntlProps {
|
||||
interface DeprecationLoggingTabProps {
|
||||
http: HttpSetup;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ interface DeprecationLoggingTabState {
|
|||
loggingEnabled?: boolean;
|
||||
}
|
||||
|
||||
export class DeprecationLoggingToggleUI extends React.Component<
|
||||
export class DeprecationLoggingToggle extends React.Component<
|
||||
DeprecationLoggingTabProps,
|
||||
DeprecationLoggingTabState
|
||||
> {
|
||||
|
@ -59,27 +59,29 @@ export class DeprecationLoggingToggleUI extends React.Component<
|
|||
}
|
||||
|
||||
private renderLoggingState() {
|
||||
const { intl } = this.props;
|
||||
const { loggingEnabled, loadingState } = this.state;
|
||||
|
||||
if (loadingState === LoadingState.Error) {
|
||||
return intl.formatMessage({
|
||||
id:
|
||||
'xpack.upgradeAssistant.overviewTab.steps.deprecationLogsStep.enableDeprecationLoggingToggleSwitch.errorLabel',
|
||||
defaultMessage: 'Could not load logging state',
|
||||
});
|
||||
return i18n.translate(
|
||||
'xpack.upgradeAssistant.overviewTab.steps.deprecationLogsStep.enableDeprecationLoggingToggleSwitch.errorLabel',
|
||||
{
|
||||
defaultMessage: 'Could not load logging state',
|
||||
}
|
||||
);
|
||||
} else if (loggingEnabled) {
|
||||
return intl.formatMessage({
|
||||
id:
|
||||
'xpack.upgradeAssistant.overviewTab.steps.deprecationLogsStep.enableDeprecationLoggingToggleSwitch.enabledLabel',
|
||||
defaultMessage: 'On',
|
||||
});
|
||||
return i18n.translate(
|
||||
'xpack.upgradeAssistant.overviewTab.steps.deprecationLogsStep.enableDeprecationLoggingToggleSwitch.enabledLabel',
|
||||
{
|
||||
defaultMessage: 'On',
|
||||
}
|
||||
);
|
||||
} else {
|
||||
return intl.formatMessage({
|
||||
id:
|
||||
'xpack.upgradeAssistant.overviewTab.steps.deprecationLogsStep.enableDeprecationLoggingToggleSwitch.disabledLabel',
|
||||
defaultMessage: 'Off',
|
||||
});
|
||||
return i18n.translate(
|
||||
'xpack.upgradeAssistant.overviewTab.steps.deprecationLogsStep.enableDeprecationLoggingToggleSwitch.disabledLabel',
|
||||
{
|
||||
defaultMessage: 'Off',
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,5 +119,3 @@ export class DeprecationLoggingToggleUI extends React.Component<
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const DeprecationLoggingToggle = injectI18n(DeprecationLoggingToggleUI);
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
EuiText,
|
||||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
||||
import { CURRENT_MAJOR_VERSION, NEXT_MAJOR_VERSION } from '../../../../../common/version';
|
||||
import { UpgradeAssistantTabProps } from '../../types';
|
||||
|
@ -89,10 +89,9 @@ const START_UPGRADE_STEP = (isCloudEnabled: boolean, esDocBasePath: string) => (
|
|||
),
|
||||
});
|
||||
|
||||
export const StepsUI: FunctionComponent<UpgradeAssistantTabProps & ReactIntl.InjectedIntlProps> = ({
|
||||
export const Steps: FunctionComponent<UpgradeAssistantTabProps> = ({
|
||||
checkupData,
|
||||
setSelectedTabIndex,
|
||||
intl,
|
||||
}) => {
|
||||
const checkupDataTyped = (checkupData! as unknown) as { [checkupType: string]: any[] };
|
||||
const countByType = Object.keys(checkupDataTyped).reduce((counts, checkupType) => {
|
||||
|
@ -113,15 +112,18 @@ export const StepsUI: FunctionComponent<UpgradeAssistantTabProps & ReactIntl.Inj
|
|||
steps={[
|
||||
{
|
||||
title: countByType.cluster
|
||||
? intl.formatMessage({
|
||||
id: 'xpack.upgradeAssistant.overviewTab.steps.clusterStep.issuesRemainingStepTitle',
|
||||
defaultMessage: 'Check for issues with your cluster',
|
||||
})
|
||||
: intl.formatMessage({
|
||||
id:
|
||||
'xpack.upgradeAssistant.overviewTab.steps.clusterStep.noIssuesRemainingStepTitle',
|
||||
defaultMessage: 'Your cluster settings are ready',
|
||||
}),
|
||||
? i18n.translate(
|
||||
'xpack.upgradeAssistant.overviewTab.steps.clusterStep.issuesRemainingStepTitle',
|
||||
{
|
||||
defaultMessage: 'Check for issues with your cluster',
|
||||
}
|
||||
)
|
||||
: i18n.translate(
|
||||
'xpack.upgradeAssistant.overviewTab.steps.clusterStep.noIssuesRemainingStepTitle',
|
||||
{
|
||||
defaultMessage: 'Your cluster settings are ready',
|
||||
}
|
||||
),
|
||||
status: countByType.cluster ? 'warning' : 'complete',
|
||||
children: (
|
||||
<EuiText>
|
||||
|
@ -168,15 +170,18 @@ export const StepsUI: FunctionComponent<UpgradeAssistantTabProps & ReactIntl.Inj
|
|||
},
|
||||
{
|
||||
title: countByType.indices
|
||||
? intl.formatMessage({
|
||||
id: 'xpack.upgradeAssistant.overviewTab.steps.indicesStep.issuesRemainingStepTitle',
|
||||
defaultMessage: 'Check for issues with your indices',
|
||||
})
|
||||
: intl.formatMessage({
|
||||
id:
|
||||
'xpack.upgradeAssistant.overviewTab.steps.indicesStep.noIssuesRemainingStepTitle',
|
||||
defaultMessage: 'Your index settings are ready',
|
||||
}),
|
||||
? i18n.translate(
|
||||
'xpack.upgradeAssistant.overviewTab.steps.indicesStep.issuesRemainingStepTitle',
|
||||
{
|
||||
defaultMessage: 'Check for issues with your indices',
|
||||
}
|
||||
)
|
||||
: i18n.translate(
|
||||
'xpack.upgradeAssistant.overviewTab.steps.indicesStep.noIssuesRemainingStepTitle',
|
||||
{
|
||||
defaultMessage: 'Your index settings are ready',
|
||||
}
|
||||
),
|
||||
status: countByType.indices ? 'warning' : 'complete',
|
||||
children: (
|
||||
<EuiText>
|
||||
|
@ -222,10 +227,12 @@ export const StepsUI: FunctionComponent<UpgradeAssistantTabProps & ReactIntl.Inj
|
|||
),
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({
|
||||
id: 'xpack.upgradeAssistant.overviewTab.steps.deprecationLogsStep.stepTitle',
|
||||
defaultMessage: 'Review the Elasticsearch deprecation logs',
|
||||
}),
|
||||
title: i18n.translate(
|
||||
'xpack.upgradeAssistant.overviewTab.steps.deprecationLogsStep.stepTitle',
|
||||
{
|
||||
defaultMessage: 'Review the Elasticsearch deprecation logs',
|
||||
}
|
||||
),
|
||||
children: (
|
||||
<Fragment>
|
||||
<EuiText grow={false}>
|
||||
|
@ -256,11 +263,12 @@ export const StepsUI: FunctionComponent<UpgradeAssistantTabProps & ReactIntl.Inj
|
|||
<EuiSpacer />
|
||||
|
||||
<EuiFormRow
|
||||
label={intl.formatMessage({
|
||||
id:
|
||||
'xpack.upgradeAssistant.overviewTab.steps.deprecationLogsStep.enableDeprecationLoggingLabel',
|
||||
defaultMessage: 'Enable deprecation logging?',
|
||||
})}
|
||||
label={i18n.translate(
|
||||
'xpack.upgradeAssistant.overviewTab.steps.deprecationLogsStep.enableDeprecationLoggingLabel',
|
||||
{
|
||||
defaultMessage: 'Enable deprecation logging?',
|
||||
}
|
||||
)}
|
||||
describedByIds={['deprecation-logging']}
|
||||
>
|
||||
<DeprecationLoggingToggle http={http} />
|
||||
|
@ -276,5 +284,3 @@ export const StepsUI: FunctionComponent<UpgradeAssistantTabProps & ReactIntl.Inj
|
|||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export const Steps = injectI18n(StepsUI);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue