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 0726b8597de2e..4cd2570f1d393 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 @@ -21,12 +21,15 @@ import { breadcrumbService } from '../../../public/application/lib/breadcrumbs'; // We'll mock these values to avoid testing the locators themselves. const idToUrlMap = { SNAPSHOT_RESTORE_LOCATOR: 'snapshotAndRestoreUrl', + DISCOVER_APP_LOCATOR: 'discoverUrl', }; 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 useUrl: (): string | undefined => idToUrlMap[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) => ({ diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/kibana_context.mock.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/kibana_context.mock.ts index 785c8dc49a76c..043e141f4a360 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/kibana_context.mock.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/kibana_context.mock.ts @@ -6,25 +6,9 @@ */ import { dataPluginMock } from '../../../../../../src/plugins/data/public/mocks'; -import { discoverPluginMock } from '../../../../../../src/plugins/discover/public/mocks'; import { applicationServiceMock } from '../../../../../../src/core/public/application/application_service.mock'; -const discoverMock = discoverPluginMock.createStartContract(); - export const kibanaContextMock = { data: dataPluginMock.createStartContract(), application: applicationServiceMock.createStartContract(), - discover: { - ...discoverMock, - locator: { - ...discoverMock.locator, - getLocation: jest.fn(() => - Promise.resolve({ - app: '/discover', - path: 'logs', - state: {}, - }) - ), - }, - }, }; diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_logs_step/fix_logs_step.test.tsx b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_logs_step/fix_logs_step.test.tsx index c19f06f03ecc2..dec34ba1e3720 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_logs_step/fix_logs_step.test.tsx +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/fix_logs_step/fix_logs_step.test.tsx @@ -151,11 +151,7 @@ describe('Overview - Fix deprecation logs step', () => { test('Has a link to see logs in discover app', async () => { await act(async () => { - testBed = await setupOverviewPage({ - getUrlForApp: jest.fn((app, options) => { - return `${app}/${options.path}`; - }), - }); + testBed = await setupOverviewPage(); }); const { exists, component, find } = testBed; @@ -163,7 +159,7 @@ describe('Overview - Fix deprecation logs step', () => { component.update(); expect(exists('viewDiscoverLogs')).toBe(true); - expect(find('viewDiscoverLogs').props().href).toBe('/discover/logs'); + expect(find('viewDiscoverLogs').props().href).toBe('discoverUrl'); }); }); diff --git a/x-pack/plugins/upgrade_assistant/kibana.json b/x-pack/plugins/upgrade_assistant/kibana.json index 948459ca7e95f..4573be8fdc041 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", "share"], + "requiredPlugins": ["management", "data", "licensing", "features", "infra", "share"], "optionalPlugins": ["usageCollection", "cloud"], "requiredBundles": ["esUiShared", "kibanaReact", "kibanaUtils"] } diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_logs_step/external_links.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_logs_step/external_links.tsx index 0cd5ad5bfdb2f..7ddd1c562ac3f 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_logs_step/external_links.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_logs_step/external_links.tsx @@ -39,24 +39,26 @@ const getDeprecationIndexPatternId = async (dataService: DataPublicPluginStart) }; const DiscoverAppLink: FunctionComponent = () => { - const { getUrlForApp } = useAppContext(); - const { data: dataService, discover: discoverService } = useKibana().services; + const { share } = useAppContext(); + const { data: dataService } = useKibana().services; const [discoveryUrl, setDiscoveryUrl] = useState(); useEffect(() => { const getDiscoveryUrl = async () => { const indexPatternId = await getDeprecationIndexPatternId(dataService); - const appLocation = await discoverService?.locator?.getLocation({ indexPatternId }); + const locator = share.url.locators.get('DISCOVER_APP_LOCATOR'); - const result = getUrlForApp(appLocation?.app as string, { - path: appLocation?.path, - }); - setDiscoveryUrl(result); + if (!locator) { + return; + } + + const url = await locator.getUrl({ indexPatternId }); + setDiscoveryUrl(url); }; getDiscoveryUrl(); - }, [dataService, discoverService, getUrlForApp]); + }, [dataService, share.url.locators]); return ( diff --git a/x-pack/plugins/upgrade_assistant/public/plugin.ts b/x-pack/plugins/upgrade_assistant/public/plugin.ts index ca7ee174b20f5..1b083caca0418 100644 --- a/x-pack/plugins/upgrade_assistant/public/plugin.ts +++ b/x-pack/plugins/upgrade_assistant/public/plugin.ts @@ -41,8 +41,8 @@ export class UpgradeAssistantUIPlugin title: pluginName, order: 1, async mount(params) { - const [coreStart, { discover, data }] = await coreSetup.getStartServices(); - const services: AppServicesContext = { discover, data, cloud }; + const [coreStart, { data }] = await coreSetup.getStartServices(); + const services: AppServicesContext = { data, cloud }; const { chrome: { docTitle }, diff --git a/x-pack/plugins/upgrade_assistant/public/types.ts b/x-pack/plugins/upgrade_assistant/public/types.ts index 356a2e22c3c7f..5a9ece6de5006 100644 --- a/x-pack/plugins/upgrade_assistant/public/types.ts +++ b/x-pack/plugins/upgrade_assistant/public/types.ts @@ -13,7 +13,6 @@ import { CloudSetup } from '../../cloud/public'; import { LicensingPluginStart } from '../../licensing/public'; export interface AppServicesContext { - discover: DiscoverStart; data: DataPublicPluginStart; cloud?: CloudSetup; }