forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Upgrade Assistant] Disable UA and add prompt (elastic#92834)
- Loading branch information
1 parent
6e059b0
commit 65ac9b0
Showing
12 changed files
with
263 additions
and
35 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
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
65 changes: 65 additions & 0 deletions
65
x-pack/plugins/upgrade_assistant/public/application/components/coming_soon_prompt.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,65 @@ | ||
/* | ||
* 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, EuiPageContent, EuiLink } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { useAppContext } from '../app_context'; | ||
|
||
export const ComingSoonPrompt: React.FunctionComponent = () => { | ||
const { kibanaVersionInfo, docLinks } = useAppContext(); | ||
const { nextMajor, currentMajor } = kibanaVersionInfo; | ||
const { ELASTIC_WEBSITE_URL } = docLinks; | ||
|
||
return ( | ||
<EuiPageContent> | ||
<EuiEmptyPrompt | ||
iconType="wrench" | ||
data-test-subj="comingSoonPrompt" | ||
title={ | ||
<h2> | ||
<FormattedMessage | ||
id="xpack.upgradeAssistant.emptyPrompt.title" | ||
defaultMessage="{uaVersion} Upgrade Assistant" | ||
values={{ uaVersion: `${nextMajor}.0` }} | ||
/> | ||
</h2> | ||
} | ||
body={ | ||
<> | ||
<p> | ||
<FormattedMessage | ||
id="xpack.upgradeAssistant.emptyPrompt.upgradeAssistantDescription" | ||
defaultMessage="The Upgrade Assistant identifies deprecated settings in your cluster and helps you | ||
resolve issues before you upgrade. Check back here when it's time to upgrade to Elastic {nextMajor}." | ||
values={{ nextMajor: `${nextMajor}.0` }} | ||
/> | ||
</p> | ||
|
||
{currentMajor === 7 && ( | ||
<p> | ||
<EuiLink | ||
external | ||
target="_blank" | ||
href={`${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/master/migrating-8.0.html`} | ||
> | ||
<FormattedMessage | ||
id="xpack.upgradeAssistant.emptyPrompt.learnMoreDescription" | ||
defaultMessage="Learn more about migrating to {nextMajor}." | ||
values={{ | ||
nextMajor: `${nextMajor}.0`, | ||
}} | ||
/> | ||
</EuiLink> | ||
</p> | ||
)} | ||
</> | ||
} | ||
/> | ||
</EuiPageContent> | ||
); | ||
}; |
44 changes: 44 additions & 0 deletions
44
x-pack/plugins/upgrade_assistant/public/application/components/page_content.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,44 @@ | ||
/* | ||
* 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 { EuiPageHeader, EuiPageHeaderSection, EuiTitle } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
import { useAppContext } from '../app_context'; | ||
import { ComingSoonPrompt } from './coming_soon_prompt'; | ||
import { UpgradeAssistantTabs } from './tabs'; | ||
|
||
export const PageContent: React.FunctionComponent = () => { | ||
const { kibanaVersionInfo, isReadOnlyMode, http } = useAppContext(); | ||
const { nextMajor } = kibanaVersionInfo; | ||
|
||
// Read-only mode will be enabled up until the last minor before the next major release | ||
if (isReadOnlyMode) { | ||
return <ComingSoonPrompt />; | ||
} | ||
|
||
return ( | ||
<> | ||
<EuiPageHeader data-test-subj="upgradeAssistantPageContent"> | ||
<EuiPageHeaderSection> | ||
<EuiTitle size="l"> | ||
<h1> | ||
<FormattedMessage | ||
id="xpack.upgradeAssistant.appTitle" | ||
defaultMessage="{version} Upgrade Assistant" | ||
values={{ version: `${nextMajor}.0` }} | ||
/> | ||
</h1> | ||
</EuiTitle> | ||
</EuiPageHeaderSection> | ||
</EuiPageHeader> | ||
|
||
<UpgradeAssistantTabs http={http} /> | ||
</> | ||
); | ||
}; |
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
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/upgrade_assistant/tests_client_integration/helpers/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,8 @@ | ||
/* | ||
* 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 { setup, OverviewTestBed } from './overview.helpers'; |
25 changes: 25 additions & 0 deletions
25
x-pack/plugins/upgrade_assistant/tests_client_integration/helpers/overview.helpers.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,25 @@ | ||
/* | ||
* 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 { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; | ||
import { PageContent } from '../../public/application/components/page_content'; | ||
import { WithAppDependencies } from './setup_environment'; | ||
|
||
const testBedConfig: TestBedConfig = { | ||
doMountAsync: true, | ||
}; | ||
|
||
export type OverviewTestBed = TestBed<OverviewTestSubjects>; | ||
|
||
export const setup = async (overrides?: any): Promise<OverviewTestBed> => { | ||
const initTestBed = registerTestBed(WithAppDependencies(PageContent, overrides), testBedConfig); | ||
const testBed = await initTestBed(); | ||
|
||
return testBed; | ||
}; | ||
|
||
export type OverviewTestSubjects = 'comingSoonPrompt' | 'upgradeAssistantPageContent'; |
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/upgrade_assistant/tests_client_integration/helpers/setup_environment.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,37 @@ | ||
/* | ||
* 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 axios from 'axios'; | ||
|
||
import { docLinksServiceMock } from '../../../../../src/core/public/mocks'; | ||
import { HttpSetup } from '../../../../../src/core/public'; | ||
|
||
import { mockKibanaSemverVersion, UA_READONLY_MODE } from '../../common/constants'; | ||
import { AppContextProvider } from '../../public/application/app_context'; | ||
|
||
const mockHttpClient = axios.create(); | ||
|
||
const contextValue = { | ||
http: (mockHttpClient as unknown) as HttpSetup, | ||
isCloudEnabled: false, | ||
docLinks: docLinksServiceMock.createStartContract(), | ||
kibanaVersionInfo: { | ||
currentMajor: mockKibanaSemverVersion.major, | ||
prevMajor: mockKibanaSemverVersion.major - 1, | ||
nextMajor: mockKibanaSemverVersion.major + 1, | ||
}, | ||
isReadOnlyMode: UA_READONLY_MODE, | ||
}; | ||
|
||
export const WithAppDependencies = (Comp: any, overrides: any = {}) => (props: any) => { | ||
return ( | ||
<AppContextProvider value={{ ...contextValue, ...overrides }}> | ||
<Comp {...props} /> | ||
</AppContextProvider> | ||
); | ||
}; |
46 changes: 46 additions & 0 deletions
46
x-pack/plugins/upgrade_assistant/tests_client_integration/overview.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,46 @@ | ||
/* | ||
* 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 { act } from 'react-dom/test-utils'; | ||
|
||
import { OverviewTestBed, setup } from './helpers'; | ||
|
||
describe('<PageContent />', () => { | ||
let testBed: OverviewTestBed; | ||
|
||
beforeEach(async () => { | ||
await act(async () => { | ||
testBed = await setup(); | ||
}); | ||
}); | ||
|
||
describe('Coming soon prompt', () => { | ||
// Default behavior up until the last minor before the next major release | ||
test('renders the coming soon prompt by default', () => { | ||
const { exists } = testBed; | ||
|
||
expect(exists('comingSoonPrompt')).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('Tabs', () => { | ||
beforeEach(async () => { | ||
await act(async () => { | ||
// Override the default context value to verify tab content renders as expected | ||
// This will be the default behavior on the last minor before the next major release (e.g., v7.15) | ||
testBed = await setup({ isReadOnlyMode: false }); | ||
}); | ||
}); | ||
|
||
test('renders the coming soon prompt by default', () => { | ||
const { exists } = testBed; | ||
|
||
expect(exists('comingSoonPrompt')).toBe(false); | ||
expect(exists('upgradeAssistantPageContent')).toBe(true); | ||
}); | ||
}); | ||
}); |
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