diff --git a/cherry.sh b/cherry.sh new file mode 100644 index 0000000000000..155bec683225f --- /dev/null +++ b/cherry.sh @@ -0,0 +1,176 @@ +#!/bin/bash + +git cherry-pick ec3c28f29590d2d916826fb066fad059f3eb3152 --strategy-option theirs + + +git cherry-pick af6b908df145576f7249efeb08c9b33bd3805a29 --strategy-option theirs + + +git cherry-pick 03e3baad4d95bdb35269261b55006ecb5e978b8c --strategy-option theirs + + +git cherry-pick 4a14a94942e798b8753639fb82d9cb06cbb0d8f4 --strategy-option theirs + + +git cherry-pick 77fe9ecf306f676f1ff39a52c57a8012e12b0f0a --strategy-option theirs + + +git cherry-pick 7947341c823acb01029a5954a4b55e61a4ed3b43 --strategy-option theirs + + +git cherry-pick 7c79a81b25845304d7bfdd74f5fb3dd77b1aef93 --strategy-option theirs + + +git cherry-pick ec09a417c2ce16b452c3c9ec711553b2112d85c9 --strategy-option theirs + + +git cherry-pick 047fe77093b87ff45c2a6a2fbb3fe4284de8bead --strategy-option theirs + + +git cherry-pick 986ac3b3733ca57ce5cd18f5a66cbcef6e0a91d4 --strategy-option theirs + + +git cherry-pick efdc7d579a4aacffed757ba01593c43aac449740 --strategy-option theirs + + +git cherry-pick f558a7932fe7d7cc7e62f139fdc79fcf17550871 --strategy-option theirs + + +git cherry-pick 0f451a577b268c3f65eda235713bec3978400b91 --strategy-option theirs + + +git cherry-pick f15250e7845afc2a12a26f157ecffc08125c3d31 --strategy-option theirs + + +git cherry-pick ee32afb8490746d290b119440fea85869984c4ba --strategy-option theirs + + +git cherry-pick 1a74022b023f0013d27b186d05db186d1939682a --strategy-option theirs + + +git cherry-pick de660291d421ebbf65308d0fde81e1de8fb16e2d --strategy-option theirs + + +git cherry-pick 25de6438383f86f9cffcd87f5359634cb8048029 --strategy-option theirs + + +git cherry-pick d4dbce0e1e2deb59093cab2baf8eef1d3661f8a3 --strategy-option theirs + + +git cherry-pick 48b25a611ca85f823a9236112ffdaea8118c7f2e --strategy-option theirs + + +git cherry-pick 7779b38aea10ad7983379f60004fae5ce51c5232 --strategy-option theirs + + +git cherry-pick 7515700242278753e2526093a89652edb23ec98e --strategy-option theirs + + +git cherry-pick af9d3f5f42c4c26f4e814ab364941fe994500d5a --strategy-option theirs + + +git cherry-pick 67871d5719b96d1f5cb7242e700b226e3dd4ed3b --strategy-option theirs + + +git cherry-pick 5250db866817873dfc9ca862f3a68e24b3f0fa15 --strategy-option theirs + + +git cherry-pick 426bda8432201bcb55ee83629464b71d8b2614fb --strategy-option theirs + + +git cherry-pick 252889814fc144a34a0f34f6fa726a9b6b75a41e --strategy-option theirs + + +git cherry-pick 5393b374d9ee97107e685eec24c942a422d3ff84 --strategy-option theirs + + +git cherry-pick e23c26fcbd5fd501d6c436097ed3035a98322e33 --strategy-option theirs + + +git cherry-pick 8dd4122285edd2c5981432acd8269382117371ab --strategy-option theirs + + +git cherry-pick c6152461155ddfa6714270099267f28ec147ac1b --strategy-option theirs + + +git cherry-pick ac94ed9aaa3ed62136c79dfa59421389b55c2936 --strategy-option theirs + + +git cherry-pick d7ce247f813763e8ee9fd7faf80c754481a8b260 --strategy-option theirs + + +git cherry-pick 70f2677213b021a968d00f4fda9927dc8a877ff8 --strategy-option theirs + + +git cherry-pick 1ad9a7275759845885ade59b86bec604da8294a4 --strategy-option theirs + + +git cherry-pick 3c35cbf750f28efb088ceb488ffec7c5c7e4e052 --strategy-option theirs + + +git cherry-pick c9292e548cd53c6388b71fdbd64f999337cfb848 --strategy-option theirs + + +git cherry-pick 71bfe79f3be55980737ff3152f197c750073b585 --strategy-option theirs + + +git cherry-pick 52723a5814d66ff073cbc125ea00ac666f34f65b --strategy-option theirs + + +git cherry-pick dacf0c2a6cabf088b0f17f4eca57e01c466286c0 --strategy-option theirs + + +git cherry-pick 991d24bad21ccf4b8350cba2b2ed3ceca6d90cea --strategy-option theirs + + +git cherry-pick b409e2eb50aec6699d9fa61307d1d3b945544782 --strategy-option theirs + + +git cherry-pick 231ab177b8c58c4389056fd205b4df9433cbb4b1 --strategy-option theirs + + +git cherry-pick a85f7a536193834f8d6a3ab0aaf5e3c8ed6d9009 --strategy-option theirs + +git cherry-pick ade05d911c4667e9ec04bc31322e911a13eba391 --strategy-option theirs + + +git cherry-pick 16271f55563db40032e9abb81cc7819965c35232 --strategy-option theirs + + +git cherry-pick c385d498874d4ca34f454e3cb9ad9e4c0e3219ae --strategy-option theirs + + +git cherry-pick 66742934a495ac0095854006169c3c6dada0d68f --strategy-option theirs + + +git cherry-pick 6b3eb50e6ace45eb0310f6ee99e6083425c9a43d --strategy-option theirs + + +git cherry-pick 3042c1115c9f5e3731dc94a95a559e4fb1a6047a --strategy-option theirs + + +git cherry-pick 794366f41590dd609afeea24794db7c029360090 --strategy-option theirs + + +git cherry-pick 0d614dc16593ab3810ff4589019e253c6d38eaf8 --strategy-option theirs + + +git cherry-pick f69faccb9ddd393662fac08ccc3dd284c22feff6 --strategy-option theirs + + +git cherry-pick 2763514508d58e72834bb285a77411c6000dd943 --strategy-option theirs + + +git cherry-pick 7bdfcf1afc29cf35f1d408063d7422bac8166f7a --strategy-option theirs + + +git cherry-pick 1b62981a1a51e4edcaad538fb3c26e3ed1de2b17 --strategy-option theirs + + +git cherry-pick 4732d4a7322433636d8736d53a30cd7ee9b0e4ed --strategy-option theirs + + +git cherry-pick 0e3853a00fce83339058421b807587bcf622e79e --strategy-option theirs + + +git cherry-pick 21d7bc8391169cdf62006c647472823f7d37205f --strategy-option theirs \ No newline at end of file diff --git a/x-pack/plugins/snapshot_restore/public/locator.ts b/x-pack/plugins/snapshot_restore/public/locator.ts index fac7d389d8e96..ba57446a03887 100644 --- a/x-pack/plugins/snapshot_restore/public/locator.ts +++ b/x-pack/plugins/snapshot_restore/public/locator.ts @@ -22,8 +22,7 @@ export interface SnapshotRestoreLocatorDefinitionDependencies { } export class SnapshotRestoreLocatorDefinition - implements LocatorDefinition -{ + implements LocatorDefinition { constructor(protected readonly deps: SnapshotRestoreLocatorDefinitionDependencies) {} public readonly id = SNAPSHOT_RESTORE_LOCATOR_ID; diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/app_context.mock.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/app_context.mock.ts index ce9a1fbf79197..b8d8e3d2505ef 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/app_context.mock.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/app_context.mock.ts @@ -11,12 +11,24 @@ import { notificationServiceMock, applicationServiceMock, } from 'src/core/public/mocks'; +import { sharePluginMock } from 'src/plugins/share/public/mocks'; import { HttpSetup } from 'src/core/public'; import { mockKibanaSemverVersion } from '../../../common/constants'; import { apiService } from '../../../public/application/lib/api'; import { breadcrumbService } from '../../../public/application/lib/breadcrumbs'; +// We'll mock these values to avoid testing the locators themselves. +const idToUrlMap = { + SNAPSHOT_RESTORE_LOCATOR: 'snapshotAndRestoreUrl', +}; + +const shareMock = sharePluginMock.createSetupContract(); +shareMock.url.locators.get = (id) => ({ + // @ts-expect-error This object is missing some properties that we're not using in the UI + getUrl: (): string | undefined => idToUrlMap[id], +}); + export const getAppContextMock = (mockHttpClient: HttpSetup) => ({ http: mockHttpClient, docLinks: docLinksServiceMock.createStartContract(), @@ -31,4 +43,5 @@ export const getAppContextMock = (mockHttpClient: HttpSetup) => ({ breadcrumbs: breadcrumbService, getUrlForApp: applicationServiceMock.createStartContract().getUrlForApp, deprecations: deprecationsServiceMock.createStartContract(), + share: shareMock, }); diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/backup_step/backup_step.test.tsx b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/backup_step/backup_step.test.tsx new file mode 100644 index 0000000000000..ab571790d56c6 --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/backup_step/backup_step.test.tsx @@ -0,0 +1,31 @@ +/* + * 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 { setupEnvironment } from '../../helpers'; +import { OverviewTestBed, setupOverviewPage } from '../overview.helpers'; + +describe('Overview - Backup Step', () => { + let testBed: OverviewTestBed; + const { server } = setupEnvironment(); + + beforeEach(async () => { + testBed = await setupOverviewPage(); + testBed.component.update(); + }); + + afterAll(() => { + server.restore(); + }); + + describe('On-prem', () => { + test('Shows link to Snapshot and Restore', () => { + const { exists, find } = testBed; + expect(exists('snapshotRestoreLink')).toBe(true); + expect(find('snapshotRestoreLink').props().href).toBe('snapshotAndRestoreUrl'); + }); + }); +}); diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/upgrade_step/upgrade_step.test.tsx b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/upgrade_step/upgrade_step.test.tsx index 617aea19a129d..61fc6b45fa4c7 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/upgrade_step/upgrade_step.test.tsx +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/upgrade_step/upgrade_step.test.tsx @@ -23,15 +23,17 @@ describe('Overview - Upgrade Step', () => { server.restore(); }); - describe('Step 3 - Upgrade stack', () => { - test('Shows link to setup upgrade docs for on-prem installations', () => { + describe('On-prem', () => { + test('Shows link to setup upgrade docs', () => { const { exists } = testBed; expect(exists('upgradeSetupDocsLink')).toBe(true); expect(exists('upgradeSetupCloudLink')).toBe(false); }); + }); - test('Shows upgrade cta and link to docs for cloud installations', async () => { + describe('On Cloud', () => { + test('Shows upgrade CTA and link to docs', async () => { await act(async () => { testBed = await setupOverviewPage({ kibanaContextOverrides: { @@ -47,8 +49,8 @@ describe('Overview - Upgrade Step', () => { const { component, exists, find } = testBed; component.update(); - expect(exists('upgradeSetupCloudLink')).toBe(true); expect(exists('upgradeSetupDocsLink')).toBe(true); + expect(exists('upgradeSetupCloudLink')).toBe(true); expect(find('upgradeSetupCloudLink').props().href).toBe( 'https://cloud.elastic.co./deployments/bfdad4ef99a24212a06d387593686d63' diff --git a/x-pack/plugins/upgrade_assistant/kibana.json b/x-pack/plugins/upgrade_assistant/kibana.json index e66f25318a28c..a250ecd55f1a9 100644 --- a/x-pack/plugins/upgrade_assistant/kibana.json +++ b/x-pack/plugins/upgrade_assistant/kibana.json @@ -8,7 +8,7 @@ "githubTeam": "kibana-stack-management" }, "configPath": ["xpack", "upgrade_assistant"], - "requiredPlugins": ["management", "discover", "data", "licensing", "features", "infra"], + "requiredPlugins": ["management", "discover", "data", "licensing", "features", "infra", "share"], "optionalPlugins": ["usageCollection", "cloud"], "requiredBundles": ["esUiShared", "kibanaReact"] } diff --git a/x-pack/plugins/upgrade_assistant/public/application/app_context.tsx b/x-pack/plugins/upgrade_assistant/public/application/app_context.tsx index 88b5bd4721c36..9543c1c4db385 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/app_context.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/app_context.tsx @@ -5,6 +5,7 @@ * 2.0. */ +import React, { createContext, useContext } from 'react'; import { CoreStart, DeprecationsServiceStart, @@ -12,7 +13,7 @@ import { HttpSetup, NotificationsStart, } from 'src/core/public'; -import React, { createContext, useContext } from 'react'; +import { SharePluginSetup } from 'src/plugins/share/public'; import { ApiService } from './lib/api'; import { BreadcrumbService } from './lib/breadcrumbs'; @@ -32,6 +33,7 @@ export interface ContextValue { breadcrumbs: BreadcrumbService; getUrlForApp: CoreStart['application']['getUrlForApp']; deprecations: DeprecationsServiceStart; + share: SharePluginSetup; } export const AppContext = createContext({} as any); diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/backup_step/backup_step.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/backup_step/backup_step.tsx new file mode 100644 index 0000000000000..006d8ed3d38ae --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/backup_step/backup_step.tsx @@ -0,0 +1,76 @@ +/* + * 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, { useState, useEffect } from 'react'; +import { i18n } from '@kbn/i18n'; +import { EuiText, EuiButton, EuiSpacer } from '@elastic/eui'; +import type { EuiStepProps } from '@elastic/eui/src/components/steps/step'; + +import { useAppContext } from '../../../app_context'; + +const i18nTexts = { + backupStepTitle: i18n.translate('xpack.upgradeAssistant.overview.backupStepTitle', { + defaultMessage: 'Back up your data', + }), + + backupStepDescription: i18n.translate('xpack.upgradeAssistant.overview.backupStepDescription', { + defaultMessage: 'Back up your data before addressing any deprecation issues.', + }), +}; + +const SnapshotRestoreAppLink: React.FunctionComponent = () => { + const { share } = useAppContext(); + + const [snapshotRestoreUrl, setSnapshotRestoreUrl] = useState(); + + useEffect(() => { + const getSnapshotRestoreUrl = async () => { + const locator = share.url.locators.get('SNAPSHOT_RESTORE_LOCATOR'); + + if (!locator) { + return; + } + + const url = await locator.getUrl({ + page: 'snapshots', + }); + setSnapshotRestoreUrl(url); + }; + + getSnapshotRestoreUrl(); + }, [share]); + + return ( + + {i18n.translate('xpack.upgradeAssistant.overview.snapshotRestoreLink', { + defaultMessage: 'Create snapshot', + })} + + ); +}; + +const BackupStep: React.FunctionComponent = () => { + return ( + <> + +

{i18nTexts.backupStepDescription}

+
+ + + + + + ); +}; + +export const getBackupStep = (): EuiStepProps => { + return { + title: i18nTexts.backupStepTitle, + status: 'incomplete', + children: , + }; +}; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/backup_step/index.ts b/x-pack/plugins/upgrade_assistant/public/application/components/overview/backup_step/index.ts new file mode 100644 index 0000000000000..8daac9645fa12 --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/backup_step/index.ts @@ -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 { getBackupStep } from './backup_step'; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/overview.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/overview.tsx index 3f6bf25e9abf0..cae6a6e263550 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/overview.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/overview.tsx @@ -21,6 +21,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { useAppContext } from '../../app_context'; +import { getBackupStep } from './backup_step'; import { getFixIssuesStep } from './fix_issues_step'; import { getFixLogsStep } from './fix_logs_step'; import { getUpgradeStep } from './upgrade_step'; @@ -83,6 +84,7 @@ export const Overview: FunctionComponent = () => { { + const { element, ...appDependencies } = deps; + render(, element); + return () => { + unmountComponentAtNode(element); + }; +}; + export async function mountManagementSection( coreSetup: CoreSetup, params: ManagementAppMountParams, kibanaVersionInfo: KibanaVersionContext, readonly: boolean, + share: SharePluginSetup, services: AppServicesContext ) { const [{ i18n, docLinks, notifications, application, deprecations }] = @@ -43,6 +60,7 @@ export async function mountManagementSection( getUrlForApp: application.getUrlForApp, deprecations, application, + share, services, }); } diff --git a/x-pack/plugins/upgrade_assistant/public/application/render_app.tsx b/x-pack/plugins/upgrade_assistant/public/application/render_app.tsx deleted file mode 100644 index 248e6961a74e5..0000000000000 --- a/x-pack/plugins/upgrade_assistant/public/application/render_app.tsx +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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 { render, unmountComponentAtNode } from 'react-dom'; -import { AppDependencies, RootComponent } from './app'; - -interface BootDependencies extends AppDependencies { - element: HTMLElement; -} - -export const renderApp = (deps: BootDependencies) => { - const { element, ...appDependencies } = deps; - render(, element); - return () => { - unmountComponentAtNode(element); - }; -}; diff --git a/x-pack/plugins/upgrade_assistant/public/plugin.ts b/x-pack/plugins/upgrade_assistant/public/plugin.ts index 32e825fbdc20d..bb6bf35029959 100644 --- a/x-pack/plugins/upgrade_assistant/public/plugin.ts +++ b/x-pack/plugins/upgrade_assistant/public/plugin.ts @@ -21,7 +21,7 @@ export class UpgradeAssistantUIPlugin { constructor(private ctx: PluginInitializerContext) {} - setup(coreSetup: CoreSetup, { management, cloud }: SetupDependencies) { + setup(coreSetup: CoreSetup, { management, cloud, share }: SetupDependencies) { const { readonly, ui: { enabled: isUpgradeAssistantUiEnabled }, @@ -56,14 +56,15 @@ export class UpgradeAssistantUIPlugin docTitle.change(pluginName); - const { mountManagementSection } = await import('./application/mount_management_section'); - const unmountAppCallback = await mountManagementSection( - coreSetup, - params, - kibanaVersionInfo, - readonly, - services - ); + const { mountManagementSection } = await import('./application/mount_management_section'); + const unmountAppCallback = await mountManagementSection( + coreSetup, + params, + kibanaVersionInfo, + readonly, + share, + services + ); return () => { docTitle.reset(); diff --git a/x-pack/plugins/upgrade_assistant/public/types.ts b/x-pack/plugins/upgrade_assistant/public/types.ts index cbeaf22bb095b..b07f0dbc7c206 100644 --- a/x-pack/plugins/upgrade_assistant/public/types.ts +++ b/x-pack/plugins/upgrade_assistant/public/types.ts @@ -8,19 +8,22 @@ import { DiscoverStart } from 'src/plugins/discover/public'; import { ManagementSetup } from 'src/plugins/management/public'; import { DataPublicPluginStart } from 'src/plugins/data/public'; +import { SharePluginSetup } from 'src/plugins/share/public'; import { CloudSetup } from '../../cloud/public'; import { LicensingPluginStart } from '../../licensing/public'; export interface AppServicesContext { - cloud?: CloudSetup; discover: DiscoverStart; data: DataPublicPluginStart; + cloud?: CloudSetup; } export interface SetupDependencies { management: ManagementSetup; + share: SharePluginSetup; cloud?: CloudSetup; } + export interface StartDependencies { licensing: LicensingPluginStart; discover: DiscoverStart;