Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Upgrade Assistant] Align code between branches #91862

Merged
merged 9 commits into from
Feb 24, 2021
Merged
2 changes: 0 additions & 2 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -21579,8 +21579,6 @@
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutDetails.reindexingTakesLongerEmphasis": "再インデックスには通常よりも時間がかかることがあります",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutTitle": "インデックスが閉じました",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.openAndCloseDocumentation": "ドキュメンテーション",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.apmReindexWarningDetail": "バージョン 7.0.0 以降、APM データは Elastic Common Schema で表示されます。過去の APM データは再インデックスされるまで表示されません。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.apmReindexWarningTitle": "このインデックスは ECS 形式に変換されます",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.destructiveCallout.calloutDetail": "インデックスをバックアップして、互換性を破るそれぞれの変更に同意することで再インデックスしてください。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.destructiveCallout.calloutTitle": "このインデックスには元に戻すことのできない破壊的な変更が含まれています",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.documentationLinkLabel": "ドキュメント",
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -21629,8 +21629,6 @@
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutDetails.reindexingTakesLongerEmphasis": "重新索引可能比通常花费更多的时间",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutTitle": "索引已关闭",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.openAndCloseDocumentation": "文档",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.apmReindexWarningDetail": "从版本 7.0.0 开始,将以 Elastic Common Schema 格式表示 APM 数据。只有重新索引历史 APM 数据后,其才可见。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.apmReindexWarningTitle": "此索引将转换成 ECS 格式",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.destructiveCallout.calloutDetail": "备份您的索引,然后通过接受每个重大更改来继续重新索引。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.destructiveCallout.calloutTitle": "此索引需要无法撤消的破坏性更改",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.documentationLinkLabel": "文档",
Expand Down
15 changes: 15 additions & 0 deletions x-pack/plugins/upgrade_assistant/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 SemVer from 'semver/classes/semver';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this help with bundle size? Just curious ☺️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! I think I copied this from elsewhere in Kibana 😅 . I'd have to go back and compare to see how it affects the bundle size.


/*
* These constants are used only in tests to add conditional logic based on Kibana version
* On master, the version should represent the next major version (e.g., master --> 8.0.0)
* The release branch should match the release version (e.g., 7.x --> 7.0.0)
*/
export const mockKibanaVersion = '8.0.0';
export const mockKibanaSemverVersion = new SemVer(mockKibanaVersion);
6 changes: 1 addition & 5 deletions x-pack/plugins/upgrade_assistant/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,8 @@ export interface ReindexOperation extends SavedObjectAttributes {
export type ReindexSavedObject = SavedObject<ReindexOperation>;

export enum ReindexWarning {
// 6.0 -> 7.0 warnings, now unused
allField = 0,
booleanFields = 1,

// 7.0 -> 8.0 warnings
apmReindex,
customTypeName,

// 8.0 -> 9.0 warnings
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

import React from 'react';
import SemVer from 'semver/classes/semver';
import { mountWithIntl } from '@kbn/test/jest';
import { httpServiceMock } from 'src/core/public/mocks';
import { mockKibanaSemverVersion } from '../../../common/constants';
import { UpgradeAssistantTabs } from './tabs';
import { LoadingState } from './types';

Expand All @@ -18,7 +18,6 @@ import { OverviewTab } from './tabs/overview';
const promisesToResolve = () => new Promise((resolve) => setTimeout(resolve, 0));

const mockHttp = httpServiceMock.createSetupContract();
const mockKibanaVersion = new SemVer('8.0.0');

jest.mock('../app_context', () => {
return {
Expand All @@ -29,9 +28,9 @@ jest.mock('../app_context', () => {
ELASTIC_WEBSITE_URL: 'https://www.elastic.co/',
},
kibanaVersionInfo: {
currentMajor: mockKibanaVersion.major,
prevMajor: mockKibanaVersion.major - 1,
nextMajor: mockKibanaVersion.major + 1,
currentMajor: mockKibanaSemverVersion.major,
prevMajor: mockKibanaSemverVersion.major - 1,
nextMajor: mockKibanaSemverVersion.major + 1,
},
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { shallow } from 'enzyme';
import React from 'react';
import SemVer from 'semver/classes/semver';
import { mockKibanaSemverVersion } from '../../../../../common/constants';

import { LoadingState } from '../../types';
import AssistanceData from '../__fixtures__/checkup_api_response.json';
Expand All @@ -22,8 +22,6 @@ const defaultProps = {
setSelectedTabIndex: jest.fn(),
};

const mockKibanaVersion = new SemVer('8.0.0');

jest.mock('../../../app_context', () => {
return {
useAppContext: () => {
Expand All @@ -33,9 +31,9 @@ jest.mock('../../../app_context', () => {
ELASTIC_WEBSITE_URL: 'https://www.elastic.co/',
},
kibanaVersionInfo: {
currentMajor: mockKibanaVersion.major,
prevMajor: mockKibanaVersion.major - 1,
nextMajor: mockKibanaVersion.major + 1,
currentMajor: mockKibanaSemverVersion.major,
prevMajor: mockKibanaSemverVersion.major - 1,
nextMajor: mockKibanaSemverVersion.major + 1,
},
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,11 @@ export class IndexDeprecationTable extends React.Component<

private generateActionsColumn() {
// NOTE: this naive implementation assumes all indices in the table are
// should show the reindex button. This should work for known usecases.
// should show the reindex button. This should work for known use cases.
const { indices } = this.props;
if (!indices.find((i) => i.reindex === true)) {
const hasActionsColumn = Boolean(indices.find((i) => i.reindex === true));

if (hasActionsColumn === false) {
return null;
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('ChecklistFlyout', () => {
status: undefined,
reindexTaskPercComplete: null,
errorMessage: null,
reindexWarnings: [ReindexWarning.allField],
reindexWarnings: [ReindexWarning.customTypeName],
hasRequiredPrivileges: true,
} as ReindexState,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { I18nProvider } from '@kbn/i18n/react';
import { mount, shallow } from 'enzyme';
import React from 'react';
import { mockKibanaSemverVersion } from '../../../../../../../../common/constants';

import { ReindexWarning } from '../../../../../../../../common/types';
import { idForWarning, WarningsFlyoutStep } from './warnings_step';
Expand All @@ -20,6 +21,11 @@ jest.mock('../../../../../../app_context', () => {
DOC_LINK_VERSION: 'current',
ELASTIC_WEBSITE_URL: 'https://www.elastic.co/',
},
kibanaVersionInfo: {
currentMajor: mockKibanaSemverVersion.major,
prevMajor: mockKibanaSemverVersion.major - 1,
nextMajor: mockKibanaSemverVersion.major + 1,
},
};
},
};
Expand All @@ -28,7 +34,7 @@ jest.mock('../../../../../../app_context', () => {
describe('WarningsFlyoutStep', () => {
const defaultProps = {
advanceNextStep: jest.fn(),
warnings: [ReindexWarning.allField, ReindexWarning.booleanFields],
warnings: [ReindexWarning.customTypeName],
closeFlyout: jest.fn(),
renderGlobalCallouts: jest.fn(),
};
Expand All @@ -37,23 +43,21 @@ describe('WarningsFlyoutStep', () => {
expect(shallow(<WarningsFlyoutStep {...defaultProps} />)).toMatchSnapshot();
});

it('does not allow proceeding until all are checked', () => {
const wrapper = mount(
<I18nProvider>
<WarningsFlyoutStep {...defaultProps} />
</I18nProvider>
);
const button = wrapper.find('EuiButton');

button.simulate('click');
expect(defaultProps.advanceNextStep).not.toHaveBeenCalled();

wrapper.find(`input#${idForWarning(ReindexWarning.allField)}`).simulate('change');
button.simulate('click');
expect(defaultProps.advanceNextStep).not.toHaveBeenCalled();

wrapper.find(`input#${idForWarning(ReindexWarning.booleanFields)}`).simulate('change');
button.simulate('click');
expect(defaultProps.advanceNextStep).toHaveBeenCalled();
});
if (mockKibanaSemverVersion.major === 7) {
it('does not allow proceeding until all are checked', () => {
const wrapper = mount(
<I18nProvider>
<WarningsFlyoutStep {...defaultProps} />
</I18nProvider>
);
const button = wrapper.find('EuiButton');

button.simulate('click');
expect(defaultProps.advanceNextStep).not.toHaveBeenCalled();

wrapper.find(`input#${idForWarning(ReindexWarning.customTypeName)}`).simulate('change');
button.simulate('click');
expect(defaultProps.advanceNextStep).toHaveBeenCalled();
});
}
});
Loading