-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enterprise Search] Error on version mismatches (#119101)
- Loading branch information
1 parent
3f83f7a
commit 7546174
Showing
17 changed files
with
292 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/enterprise_search/common/is_version_mismatch/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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 { isVersionMismatch } from './index'; | ||
|
||
describe('isVersionMismatch', () => { | ||
it('no mismatch if major and minor are the same', () => { | ||
expect(isVersionMismatch('8.0.0', '8.0.1')).toBe(false); | ||
}); | ||
|
||
it('mismatch if kibana minor is different than enterprise search minor', () => { | ||
expect(isVersionMismatch('8.0.0', '8.1.0')).toBe(true); | ||
}); | ||
|
||
it('mismatch if major is different', () => { | ||
expect(isVersionMismatch('7.0.0', '8.0.0')).toBe(true); | ||
}); | ||
|
||
it('no mismatch if versions are not available to analyze', () => { | ||
expect(isVersionMismatch()).toBe(false); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
x-pack/plugins/enterprise_search/common/is_version_mismatch/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
*/ | ||
|
||
export const isVersionMismatch = (enterpriseSearchVersion?: string, kibanaVersion?: string) => { | ||
// Don't consider it a mismatch unless we know for certain it is | ||
if (!enterpriseSearchVersion || !kibanaVersion) return false; | ||
const [enterpriseSearchMajor, enterpriseSearchMinor] = enterpriseSearchVersion.split('.'); | ||
const [kibanaMajor, kibanaMinor] = kibanaVersion.split('.'); | ||
if (enterpriseSearchMajor !== kibanaMajor || enterpriseSearchMinor !== kibanaMinor) return true; | ||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
x-pack/plugins/enterprise_search/public/applications/shared/version_mismatch/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { VersionMismatchPage } from './version_mismatch_page'; | ||
export { VersionMismatchError } from './version_mismatch_error'; |
23 changes: 23 additions & 0 deletions
23
...rprise_search/public/applications/shared/version_mismatch/version_mismatch_error.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* 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 { mount } from 'enzyme'; | ||
|
||
import { VersionMismatchError } from './version_mismatch_error'; | ||
|
||
describe('VersionMismatchError', () => { | ||
it('renders', () => { | ||
const wrapper = mount( | ||
<VersionMismatchError kibanaVersion="8.1.0" enterpriseSearchVersion="8.0.0" /> | ||
); | ||
|
||
expect(wrapper.find('EuiEmptyPrompt').text()).toContain('Enterprise Search version: 8.0.0'); | ||
expect(wrapper.find('EuiEmptyPrompt').text()).toContain('Kibana version: 8.1.0'); | ||
}); | ||
}); |
57 changes: 57 additions & 0 deletions
57
.../enterprise_search/public/applications/shared/version_mismatch/version_mismatch_error.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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 { EuiEmptyPrompt, EuiSpacer } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
interface Props { | ||
enterpriseSearchVersion?: string; | ||
kibanaVersion?: string; | ||
} | ||
|
||
export const VersionMismatchError: React.FC<Props> = ({ | ||
enterpriseSearchVersion, | ||
kibanaVersion, | ||
}) => { | ||
return ( | ||
<EuiEmptyPrompt | ||
iconType="alert" | ||
iconColor="danger" | ||
title={ | ||
<h2> | ||
{i18n.translate('xpack.enterpriseSearch.versionMismatch.title', { | ||
defaultMessage: 'Incompatible version error', | ||
})} | ||
</h2> | ||
} | ||
titleSize="l" | ||
body={ | ||
<> | ||
{i18n.translate('xpack.enterpriseSearch.versionMismatch.body', { | ||
defaultMessage: | ||
'Your Kibana and Enterprise Search versions do not match. To access Enterprise Search, use the same major and minor version for each service.', | ||
})} | ||
<EuiSpacer /> | ||
<div> | ||
{i18n.translate('xpack.enterpriseSearch.versionMismatch.enterpriseSearchVersionText', { | ||
defaultMessage: 'Enterprise Search version: {enterpriseSearchVersion}', | ||
values: { enterpriseSearchVersion }, | ||
})} | ||
</div> | ||
<div> | ||
{i18n.translate('xpack.enterpriseSearch.versionMismatch.kibanaVersionText', { | ||
defaultMessage: 'Kibana version: {kibanaVersion}', | ||
values: { kibanaVersion }, | ||
})} | ||
</div> | ||
</> | ||
} | ||
/> | ||
); | ||
}; |
26 changes: 26 additions & 0 deletions
26
...erprise_search/public/applications/shared/version_mismatch/version_mismatch_page.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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 { shallow } from 'enzyme'; | ||
|
||
import { VersionMismatchError } from './version_mismatch_error'; | ||
import { VersionMismatchPage } from './version_mismatch_page'; | ||
|
||
describe('VersionMismatchPage', () => { | ||
it('renders', () => { | ||
const wrapper = shallow( | ||
<VersionMismatchPage kibanaVersion="8.1.0" enterpriseSearchVersion="8.0.0" /> | ||
); | ||
expect(wrapper.find(VersionMismatchError).exists()).toBe(true); | ||
expect(wrapper.find(VersionMismatchError).props()).toEqual({ | ||
kibanaVersion: '8.1.0', | ||
enterpriseSearchVersion: '8.0.0', | ||
}); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
...s/enterprise_search/public/applications/shared/version_mismatch/version_mismatch_page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* 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 { KibanaPageTemplate } from '../../../../../../../src/plugins/kibana_react/public'; | ||
|
||
import { VersionMismatchError } from './version_mismatch_error'; | ||
|
||
interface Props { | ||
enterpriseSearchVersion?: string; | ||
kibanaVersion?: string; | ||
} | ||
|
||
export const VersionMismatchPage: React.FC<Props> = (props) => ( | ||
<KibanaPageTemplate isEmptyState> | ||
<VersionMismatchError {...props} /> | ||
</KibanaPageTemplate> | ||
); |
Oops, something went wrong.