diff --git a/packages/core/application/core-application-browser-internal/src/application_service.tsx b/packages/core/application/core-application-browser-internal/src/application_service.tsx index d54b71b91f119..8e5f2643929e7 100644 --- a/packages/core/application/core-application-browser-internal/src/application_service.tsx +++ b/packages/core/application/core-application-browser-internal/src/application_service.tsx @@ -13,7 +13,7 @@ import { createBrowserHistory, History } from 'history'; import type { PluginOpaqueId } from '@kbn/core-base-common'; import type { ThemeServiceStart } from '@kbn/core-theme-browser'; -import type { HttpSetup, HttpStart } from '@kbn/core-http-browser'; +import type { InternalHttpSetup, InternalHttpStart } from '@kbn/core-http-browser-internal'; import type { Capabilities } from '@kbn/core-capabilities-common'; import type { MountPoint } from '@kbn/core-mount-utils-browser'; import type { OverlayStart } from '@kbn/core-overlays-browser'; @@ -46,7 +46,7 @@ import { import { registerAnalyticsContextProvider } from './register_analytics_context_provider'; export interface SetupDeps { - http: HttpSetup; + http: InternalHttpSetup; analytics: AnalyticsServiceSetup; history?: History; /** Used to redirect to external urls */ @@ -54,7 +54,7 @@ export interface SetupDeps { } export interface StartDeps { - http: HttpStart; + http: InternalHttpStart; analytics: AnalyticsServiceStart; theme: ThemeServiceStart; overlays: OverlayStart; diff --git a/packages/core/application/core-application-browser-internal/src/utils/parse_app_url.test.ts b/packages/core/application/core-application-browser-internal/src/utils/parse_app_url.test.ts index 7bc5752a72b13..0126acd36e453 100644 --- a/packages/core/application/core-application-browser-internal/src/utils/parse_app_url.test.ts +++ b/packages/core/application/core-application-browser-internal/src/utils/parse_app_url.test.ts @@ -30,7 +30,7 @@ describe('parseAppUrl', () => { beforeEach(() => { apps = new Map(); - basePath = new BasePath('/base-path'); + basePath = new BasePath({ basePath: '/base-path' }); createApp({ id: 'foo', diff --git a/packages/core/apps/core-apps-browser-internal/src/core_app.ts b/packages/core/apps/core-apps-browser-internal/src/core_app.ts index e8a61de40bea2..c6a8583a14930 100644 --- a/packages/core/apps/core-apps-browser-internal/src/core_app.ts +++ b/packages/core/apps/core-apps-browser-internal/src/core_app.ts @@ -10,7 +10,7 @@ import type { UnregisterCallback } from 'history'; import type { CoreContext } from '@kbn/core-base-browser-internal'; import type { InternalInjectedMetadataSetup } from '@kbn/core-injected-metadata-browser-internal'; import type { DocLinksStart } from '@kbn/core-doc-links-browser'; -import type { HttpSetup, HttpStart } from '@kbn/core-http-browser'; +import type { InternalHttpSetup, InternalHttpStart } from '@kbn/core-http-browser-internal'; import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser'; import type { NotificationsSetup, NotificationsStart } from '@kbn/core-notifications-browser'; import { AppNavLinkStatus, type AppMountParameters } from '@kbn/core-application-browser'; @@ -27,7 +27,7 @@ import { renderApp as renderStatusApp } from './status'; export interface CoreAppsServiceSetupDeps { application: InternalApplicationSetup; - http: HttpSetup; + http: InternalHttpSetup; injectedMetadata: InternalInjectedMetadataSetup; notifications: NotificationsSetup; } @@ -35,7 +35,7 @@ export interface CoreAppsServiceSetupDeps { export interface CoreAppsServiceStartDeps { application: InternalApplicationStart; docLinks: DocLinksStart; - http: HttpStart; + http: InternalHttpStart; notifications: NotificationsStart; uiSettings: IUiSettingsClient; } diff --git a/packages/core/apps/core-apps-browser-internal/src/errors/error_application.test.ts b/packages/core/apps/core-apps-browser-internal/src/errors/error_application.test.ts index 5ca92bc3904f4..65f7a437631b1 100644 --- a/packages/core/apps/core-apps-browser-internal/src/errors/error_application.test.ts +++ b/packages/core/apps/core-apps-browser-internal/src/errors/error_application.test.ts @@ -22,7 +22,7 @@ describe('renderApp', () => { let unmount: () => void; beforeEach(() => { - basePath = new BasePath(); + basePath = new BasePath({ basePath: '' }); element = document.createElement('div'); history = createMemoryHistory(); unmount = renderApp( diff --git a/packages/core/apps/core-apps-browser-internal/src/errors/public_base_url.tsx b/packages/core/apps/core-apps-browser-internal/src/errors/public_base_url.tsx index 0d2e678963d8b..f125d03239802 100644 --- a/packages/core/apps/core-apps-browser-internal/src/errors/public_base_url.tsx +++ b/packages/core/apps/core-apps-browser-internal/src/errors/public_base_url.tsx @@ -12,7 +12,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import type { DocLinksStart } from '@kbn/core-doc-links-browser'; -import type { HttpStart } from '@kbn/core-http-browser'; +import type { InternalHttpStart } from '@kbn/core-http-browser-internal'; import type { NotificationsStart } from '@kbn/core-notifications-browser'; import { mountReactNode } from '@kbn/core-mount-utils-browser-internal'; @@ -21,7 +21,7 @@ export const MISSING_CONFIG_STORAGE_KEY = `core.warnings.publicBaseUrlMissingDis interface Deps { docLinks: DocLinksStart; - http: HttpStart; + http: InternalHttpStart; notifications: NotificationsStart; // Exposed for easier testing storage?: Storage; diff --git a/packages/core/apps/core-apps-browser-internal/src/errors/url_overflow.test.ts b/packages/core/apps/core-apps-browser-internal/src/errors/url_overflow.test.ts index bdf8bdf0abc6a..dae718c75afce 100644 --- a/packages/core/apps/core-apps-browser-internal/src/errors/url_overflow.test.ts +++ b/packages/core/apps/core-apps-browser-internal/src/errors/url_overflow.test.ts @@ -27,7 +27,7 @@ describe('url overflow detection', () => { let unlisten: any; beforeEach(() => { - basePath = new BasePath('/test-123'); + basePath = new BasePath({ basePath: '/test-123' }); history = createMemoryHistory(); toasts = notificationServiceMock.createStartContract().toasts; uiSettings = uiSettingsServiceMock.createStartContract(); diff --git a/packages/core/apps/core-apps-browser-internal/src/status/lib/load_status.ts b/packages/core/apps/core-apps-browser-internal/src/status/lib/load_status.ts index 6672786c72a10..7338db04716c0 100644 --- a/packages/core/apps/core-apps-browser-internal/src/status/lib/load_status.ts +++ b/packages/core/apps/core-apps-browser-internal/src/status/lib/load_status.ts @@ -189,7 +189,7 @@ export async function loadStatus({ http, notifications, }: { - http: HttpSetup; + http: Pick; notifications: NotificationsSetup; }) { let response: StatusResponse; diff --git a/packages/core/apps/core-apps-browser-internal/src/status/render_app.tsx b/packages/core/apps/core-apps-browser-internal/src/status/render_app.tsx index 4578ff0f347d6..a2af773a239ad 100644 --- a/packages/core/apps/core-apps-browser-internal/src/status/render_app.tsx +++ b/packages/core/apps/core-apps-browser-internal/src/status/render_app.tsx @@ -10,13 +10,13 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { I18nProvider } from '@kbn/i18n-react'; import { CoreThemeProvider } from '@kbn/core-theme-browser-internal'; -import type { HttpSetup } from '@kbn/core-http-browser'; +import type { InternalHttpSetup } from '@kbn/core-http-browser-internal'; import type { NotificationsSetup } from '@kbn/core-notifications-browser'; import type { AppMountParameters } from '@kbn/core-application-browser'; import { StatusApp } from './status_app'; interface Deps { - http: HttpSetup; + http: InternalHttpSetup; notifications: NotificationsSetup; } diff --git a/packages/core/apps/core-apps-browser-internal/src/status/status_app.tsx b/packages/core/apps/core-apps-browser-internal/src/status/status_app.tsx index 43e388ad170a8..88ae96bd33596 100644 --- a/packages/core/apps/core-apps-browser-internal/src/status/status_app.tsx +++ b/packages/core/apps/core-apps-browser-internal/src/status/status_app.tsx @@ -10,13 +10,13 @@ import React, { Component } from 'react'; import { EuiLoadingSpinner, EuiText, EuiPage, EuiPageBody, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; -import type { HttpSetup } from '@kbn/core-http-browser'; +import type { InternalHttpSetup } from '@kbn/core-http-browser-internal'; import type { NotificationsSetup } from '@kbn/core-notifications-browser'; import { loadStatus, type ProcessedServerResponse } from './lib'; import { MetricTiles, ServerStatus, StatusSection, VersionHeader } from './components'; interface StatusAppProps { - http: HttpSetup; + http: InternalHttpSetup; notifications: NotificationsSetup; } diff --git a/packages/core/capabilities/core-capabilities-browser-internal/src/capabilities_service.tsx b/packages/core/capabilities/core-capabilities-browser-internal/src/capabilities_service.tsx index 746911117e5ab..0751225af5311 100644 --- a/packages/core/capabilities/core-capabilities-browser-internal/src/capabilities_service.tsx +++ b/packages/core/capabilities/core-capabilities-browser-internal/src/capabilities_service.tsx @@ -8,12 +8,12 @@ import type { RecursiveReadonly } from '@kbn/utility-types'; import { deepFreeze } from '@kbn/std'; -import type { HttpStart } from '@kbn/core-http-browser'; +import type { InternalHttpStart } from '@kbn/core-http-browser-internal'; import type { Capabilities } from '@kbn/core-capabilities-common'; interface StartDeps { appIds: string[]; - http: HttpStart; + http: InternalHttpStart; } /** @internal */ diff --git a/packages/core/capabilities/core-capabilities-browser-internal/tsconfig.json b/packages/core/capabilities/core-capabilities-browser-internal/tsconfig.json index 258f96a51d15b..ca9379c024865 100644 --- a/packages/core/capabilities/core-capabilities-browser-internal/tsconfig.json +++ b/packages/core/capabilities/core-capabilities-browser-internal/tsconfig.json @@ -14,9 +14,9 @@ "kbn_references": [ "@kbn/utility-types", "@kbn/std", - "@kbn/core-http-browser", "@kbn/core-http-browser-mocks", - "@kbn/core-capabilities-common" + "@kbn/core-capabilities-common", + "@kbn/core-http-browser-internal" ], "exclude": [ "target/**/*", diff --git a/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx b/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx index eaa30238cde89..e7f1ecbd29acc 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx +++ b/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx @@ -16,7 +16,7 @@ import useObservable from 'react-use/lib/useObservable'; import type { InternalInjectedMetadataStart } from '@kbn/core-injected-metadata-browser-internal'; import type { AnalyticsServiceSetup } from '@kbn/core-analytics-browser'; import { type DocLinksStart } from '@kbn/core-doc-links-browser'; -import type { HttpStart } from '@kbn/core-http-browser'; +import type { InternalHttpStart } from '@kbn/core-http-browser-internal'; import { mountReactNode } from '@kbn/core-mount-utils-browser-internal'; import type { NotificationsStart } from '@kbn/core-notifications-browser'; import type { InternalApplicationStart } from '@kbn/core-application-browser-internal'; @@ -63,7 +63,7 @@ export interface SetupDeps { export interface StartDeps { application: InternalApplicationStart; docLinks: DocLinksStart; - http: HttpStart; + http: InternalHttpStart; injectedMetadata: InternalInjectedMetadataStart; notifications: NotificationsStart; customBranding: CustomBrandingStart; diff --git a/packages/core/chrome/core-chrome-browser-internal/src/nav_links/nav_links_service.ts b/packages/core/chrome/core-chrome-browser-internal/src/nav_links/nav_links_service.ts index e55e8cd0307a9..08466a1f35fb0 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/nav_links/nav_links_service.ts +++ b/packages/core/chrome/core-chrome-browser-internal/src/nav_links/nav_links_service.ts @@ -9,7 +9,8 @@ import { sortBy } from 'lodash'; import { BehaviorSubject, ReplaySubject } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; -import type { HttpStart, IBasePath } from '@kbn/core-http-browser'; +import type { IBasePath } from '@kbn/core-http-browser'; +import type { InternalHttpStart } from '@kbn/core-http-browser-internal'; import type { PublicAppDeepLinkInfo, PublicAppInfo } from '@kbn/core-application-browser'; import type { InternalApplicationStart } from '@kbn/core-application-browser-internal'; import type { ChromeNavLinks } from '@kbn/core-chrome-browser'; @@ -18,7 +19,7 @@ import { toNavLink } from './to_nav_link'; interface StartDeps { application: InternalApplicationStart; - http: HttpStart; + http: InternalHttpStart; } export class NavLinksService { diff --git a/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/project_navigation_service.ts b/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/project_navigation_service.ts index 38766a026cdcc..7a8f5b89db653 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/project_navigation_service.ts +++ b/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/project_navigation_service.ts @@ -16,7 +16,7 @@ import { ChromeSetProjectBreadcrumbsParams, ChromeProjectNavigationNode, } from '@kbn/core-chrome-browser'; -import type { HttpStart } from '@kbn/core-http-browser'; +import type { InternalHttpStart } from '@kbn/core-http-browser-internal'; import { BehaviorSubject, Observable, @@ -37,7 +37,7 @@ import { buildBreadcrumbs } from './breadcrumbs'; interface StartDeps { application: InternalApplicationStart; navLinks: ChromeNavLinks; - http: HttpStart; + http: InternalHttpStart; chromeBreadcrumbs$: Observable; } @@ -59,7 +59,7 @@ export class ProjectNavigationService { }>({ breadcrumbs: [], params: { absolute: false } }); private readonly stop$ = new ReplaySubject(1); private application?: InternalApplicationStart; - private http?: HttpStart; + private http?: InternalHttpStart; private unlistenHistory?: () => void; public start({ application, navLinks, http, chromeBreadcrumbs$ }: StartDeps) { diff --git a/packages/core/chrome/core-chrome-browser-internal/src/recently_accessed/recently_accessed_service.ts b/packages/core/chrome/core-chrome-browser-internal/src/recently_accessed/recently_accessed_service.ts index 414f0c796d1bd..ec9a04ab5551c 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/recently_accessed/recently_accessed_service.ts +++ b/packages/core/chrome/core-chrome-browser-internal/src/recently_accessed/recently_accessed_service.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { HttpSetup } from '@kbn/core-http-browser'; +import type { InternalHttpStart } from '@kbn/core-http-browser-internal'; import type { ChromeRecentlyAccessed, ChromeRecentlyAccessedHistoryItem, @@ -15,7 +15,7 @@ import { PersistedLog } from './persisted_log'; import { createLogKey } from './create_log_key'; interface StartDeps { - http: HttpSetup; + http: InternalHttpStart; } /** @internal */ diff --git a/packages/core/chrome/core-chrome-browser-internal/src/ui/header/__snapshots__/collapsible_nav.test.tsx.snap b/packages/core/chrome/core-chrome-browser-internal/src/ui/header/__snapshots__/collapsible_nav.test.tsx.snap index c5c82c88c8521..416ce39bbf9ba 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/ui/header/__snapshots__/collapsible_nav.test.tsx.snap +++ b/packages/core/chrome/core-chrome-browser-internal/src/ui/header/__snapshots__/collapsible_nav.test.tsx.snap @@ -733,6 +733,7 @@ exports[`CollapsibleNav renders the default nav 1`] = ` } basePath={ BasePath { + "assetsHrefBase": "/test", "basePath": "/test", "get": [Function], "prepend": [Function], @@ -918,6 +919,7 @@ exports[`CollapsibleNav renders the default nav 2`] = ` } basePath={ BasePath { + "assetsHrefBase": "/test", "basePath": "/test", "get": [Function], "prepend": [Function], diff --git a/packages/core/chrome/core-chrome-browser-internal/tsconfig.json b/packages/core/chrome/core-chrome-browser-internal/tsconfig.json index 020324c1f67bc..ed460a1965667 100644 --- a/packages/core/chrome/core-chrome-browser-internal/tsconfig.json +++ b/packages/core/chrome/core-chrome-browser-internal/tsconfig.json @@ -43,6 +43,7 @@ "@kbn/core-analytics-browser", "@kbn/shared-ux-router", "@kbn/shared-ux-link-redirect-app", + "@kbn/core-http-browser-internal", ], "exclude": [ "target/**/*", diff --git a/packages/core/deprecations/core-deprecations-browser-internal/src/deprecations_service.ts b/packages/core/deprecations/core-deprecations-browser-internal/src/deprecations_service.ts index edaf5f7f27be0..6dd78c8525f5d 100644 --- a/packages/core/deprecations/core-deprecations-browser-internal/src/deprecations_service.ts +++ b/packages/core/deprecations/core-deprecations-browser-internal/src/deprecations_service.ts @@ -8,13 +8,13 @@ import type { CoreService } from '@kbn/core-base-browser-internal'; import type { DeprecationsServiceStart } from '@kbn/core-deprecations-browser'; -import type { HttpStart } from '@kbn/core-http-browser'; +import type { InternalHttpStart } from '@kbn/core-http-browser-internal'; import { DeprecationsClient } from './deprecations_client'; export class DeprecationsService implements CoreService { public setup(): void {} - public start({ http }: { http: HttpStart }): DeprecationsServiceStart { + public start({ http }: { http: InternalHttpStart }): DeprecationsServiceStart { const deprecationsClient = new DeprecationsClient({ http }); return { diff --git a/packages/core/deprecations/core-deprecations-browser-internal/tsconfig.json b/packages/core/deprecations/core-deprecations-browser-internal/tsconfig.json index 8c7dde1c84e07..38fda3fdccf44 100644 --- a/packages/core/deprecations/core-deprecations-browser-internal/tsconfig.json +++ b/packages/core/deprecations/core-deprecations-browser-internal/tsconfig.json @@ -16,7 +16,8 @@ "@kbn/core-http-browser", "@kbn/core-http-browser-mocks", "@kbn/core-deprecations-common", - "@kbn/core-deprecations-browser" + "@kbn/core-deprecations-browser", + "@kbn/core-http-browser-internal" ], "exclude": [ "target/**/*", diff --git a/packages/core/http/core-http-browser-internal/index.ts b/packages/core/http/core-http-browser-internal/index.ts index 3baa45b8bcdf1..0b747b6261eb9 100644 --- a/packages/core/http/core-http-browser-internal/index.ts +++ b/packages/core/http/core-http-browser-internal/index.ts @@ -8,3 +8,4 @@ export { BasePath } from './src/base_path'; export { HttpService } from './src/http_service'; +export type { InternalHttpSetup, InternalHttpStart } from './src/types'; diff --git a/packages/core/http/core-http-browser-internal/src/anonymous_paths_service.test.ts b/packages/core/http/core-http-browser-internal/src/anonymous_paths_service.test.ts index dff9c4719fef4..181641700d4d6 100644 --- a/packages/core/http/core-http-browser-internal/src/anonymous_paths_service.test.ts +++ b/packages/core/http/core-http-browser-internal/src/anonymous_paths_service.test.ts @@ -12,13 +12,13 @@ import { BasePath } from './base_path'; describe('#setup()', () => { describe('#register', () => { it(`allows paths that don't start with /`, () => { - const basePath = new BasePath('/foo'); + const basePath = new BasePath({ basePath: '/foo' }); const anonymousPaths = new AnonymousPathsService().setup({ basePath }); anonymousPaths.register('bar'); }); it(`allows paths that end with '/'`, () => { - const basePath = new BasePath('/foo'); + const basePath = new BasePath({ basePath: '/foo' }); const anonymousPaths = new AnonymousPathsService().setup({ basePath }); anonymousPaths.register('/bar/'); }); @@ -26,70 +26,70 @@ describe('#setup()', () => { describe('#isAnonymous', () => { it('returns true for registered paths', () => { - const basePath = new BasePath('/foo'); + const basePath = new BasePath({ basePath: '/foo' }); const anonymousPaths = new AnonymousPathsService().setup({ basePath }); anonymousPaths.register('/bar'); expect(anonymousPaths.isAnonymous('/foo/bar')).toBe(true); }); it('returns true for paths registered with a trailing slash, but call "isAnonymous" with no trailing slash', () => { - const basePath = new BasePath('/foo'); + const basePath = new BasePath({ basePath: '/foo' }); const anonymousPaths = new AnonymousPathsService().setup({ basePath }); anonymousPaths.register('/bar/'); expect(anonymousPaths.isAnonymous('/foo/bar')).toBe(true); }); it('returns true for paths registered without a trailing slash, but call "isAnonymous" with a trailing slash', () => { - const basePath = new BasePath('/foo'); + const basePath = new BasePath({ basePath: '/foo' }); const anonymousPaths = new AnonymousPathsService().setup({ basePath }); anonymousPaths.register('/bar'); expect(anonymousPaths.isAnonymous('/foo/bar/')).toBe(true); }); it('returns true for paths registered without a starting slash', () => { - const basePath = new BasePath('/foo'); + const basePath = new BasePath({ basePath: '/foo' }); const anonymousPaths = new AnonymousPathsService().setup({ basePath }); anonymousPaths.register('bar'); expect(anonymousPaths.isAnonymous('/foo/bar')).toBe(true); }); it('returns true for paths registered with a starting slash', () => { - const basePath = new BasePath('/foo'); + const basePath = new BasePath({ basePath: '/foo' }); const anonymousPaths = new AnonymousPathsService().setup({ basePath }); anonymousPaths.register('/bar'); expect(anonymousPaths.isAnonymous('/foo/bar')).toBe(true); }); it('when there is no basePath and calling "isAnonymous" without a starting slash, returns true for paths registered with a starting slash', () => { - const basePath = new BasePath('/'); + const basePath = new BasePath({ basePath: '/foo' }); const anonymousPaths = new AnonymousPathsService().setup({ basePath }); anonymousPaths.register('/bar'); expect(anonymousPaths.isAnonymous('bar')).toBe(true); }); it('when there is no basePath and calling "isAnonymous" with a starting slash, returns true for paths registered with a starting slash', () => { - const basePath = new BasePath('/'); + const basePath = new BasePath({ basePath: '/foo' }); const anonymousPaths = new AnonymousPathsService().setup({ basePath }); anonymousPaths.register('/bar'); expect(anonymousPaths.isAnonymous('/bar')).toBe(true); }); it('returns true for paths whose capitalization is different', () => { - const basePath = new BasePath('/foo'); + const basePath = new BasePath({ basePath: '/foo' }); const anonymousPaths = new AnonymousPathsService().setup({ basePath }); anonymousPaths.register('/BAR'); expect(anonymousPaths.isAnonymous('/foo/bar')).toBe(true); }); it('returns false for other paths', () => { - const basePath = new BasePath('/foo'); + const basePath = new BasePath({ basePath: '/foo' }); const anonymousPaths = new AnonymousPathsService().setup({ basePath }); anonymousPaths.register('/bar'); expect(anonymousPaths.isAnonymous('/foo/foo')).toBe(false); }); it('returns false for sub-paths of registered paths', () => { - const basePath = new BasePath('/foo'); + const basePath = new BasePath({ basePath: '/foo' }); const anonymousPaths = new AnonymousPathsService().setup({ basePath }); anonymousPaths.register('/bar'); expect(anonymousPaths.isAnonymous('/foo/bar/baz')).toBe(false); diff --git a/packages/core/http/core-http-browser-internal/src/base_path.test.ts b/packages/core/http/core-http-browser-internal/src/base_path.test.ts index cfca537c0f5b4..ebf70c48d79c3 100644 --- a/packages/core/http/core-http-browser-internal/src/base_path.test.ts +++ b/packages/core/http/core-http-browser-internal/src/base_path.test.ts @@ -10,35 +10,31 @@ import { BasePath } from './base_path'; describe('BasePath', () => { describe('#get()', () => { - it('returns an empty string if no basePath not provided', () => { - expect(new BasePath().get()).toBe(''); - }); - it('returns basePath value if provided', () => { - expect(new BasePath('/foo').get()).toBe('/foo'); + expect(new BasePath({ basePath: '/foo' }).get()).toBe('/foo'); }); describe('#prepend()', () => { it('adds the base path to the path if it is relative and starts with a slash', () => { - const basePath = new BasePath('/foo/bar'); + const basePath = new BasePath({ basePath: '/foo/bar' }); expect(basePath.prepend('/a/b')).toBe('/foo/bar/a/b'); }); it('leaves the query string and hash of path unchanged', () => { - const basePath = new BasePath('/foo/bar'); + const basePath = new BasePath({ basePath: '/foo/bar' }); expect(basePath.prepend('/a/b?x=y#c/d/e')).toBe('/foo/bar/a/b?x=y#c/d/e'); }); it('returns the path unchanged if it does not start with a slash', () => { - const basePath = new BasePath('/foo/bar'); + const basePath = new BasePath({ basePath: '/foo/bar' }); expect(basePath.prepend('a/b')).toBe('a/b'); }); it('returns the path unchanged it it has a hostname', () => { - const basePath = new BasePath('/foo/bar'); + const basePath = new BasePath({ basePath: '/foo/bar' }); expect(basePath.prepend('http://localhost:5601/a/b')).toBe('http://localhost:5601/a/b'); }); @@ -46,19 +42,19 @@ describe('BasePath', () => { describe('#remove()', () => { it('removes the basePath if relative path starts with it', () => { - const basePath = new BasePath('/foo/bar'); + const basePath = new BasePath({ basePath: '/foo/bar' }); expect(basePath.remove('/foo/bar/a/b')).toBe('/a/b'); }); it('leaves query string and hash intact', () => { - const basePath = new BasePath('/foo/bar'); + const basePath = new BasePath({ basePath: '/foo/bar' }); expect(basePath.remove('/foo/bar/a/b?c=y#1234')).toBe('/a/b?c=y#1234'); }); it('ignores urls with hostnames', () => { - const basePath = new BasePath('/foo/bar'); + const basePath = new BasePath({ basePath: '/foo/bar' }); expect(basePath.remove('http://localhost:5601/foo/bar/a/b')).toBe( 'http://localhost:5601/foo/bar/a/b' @@ -66,13 +62,13 @@ describe('BasePath', () => { }); it('returns slash if path is just basePath', () => { - const basePath = new BasePath('/foo/bar'); + const basePath = new BasePath({ basePath: '/foo/bar' }); expect(basePath.remove('/foo/bar')).toBe('/'); }); it('returns full path if basePath is not its own segment', () => { - const basePath = new BasePath('/foo/bar'); + const basePath = new BasePath({ basePath: '/foo/bar' }); expect(basePath.remove('/foo/barhop')).toBe('/foo/barhop'); }); @@ -81,20 +77,39 @@ describe('BasePath', () => { describe('serverBasePath', () => { it('defaults to basePath', () => { - expect(new BasePath('/foo/bar').serverBasePath).toEqual('/foo/bar'); + expect(new BasePath({ basePath: '/foo/bar' }).serverBasePath).toEqual('/foo/bar'); }); it('returns value when passed into constructor', () => { - expect(new BasePath('/foo/bar', '/foo').serverBasePath).toEqual('/foo'); + expect(new BasePath({ basePath: '/foo/bar', serverBasePath: '/foo' }).serverBasePath).toEqual( + '/foo' + ); }); }); describe('publicBaseUrl', () => { it('returns value passed into construtor', () => { - expect(new BasePath('/foo/bar', '/foo').publicBaseUrl).toEqual(undefined); - expect(new BasePath('/foo/bar', '/foo', 'http://myhost.com/foo').publicBaseUrl).toEqual( - 'http://myhost.com/foo' + expect(new BasePath({ basePath: '/foo/bar' }).publicBaseUrl).toEqual(undefined); + expect( + new BasePath({ basePath: '/foo/bar', publicBaseUrl: 'http://myhost.com/foo' }).publicBaseUrl + ).toEqual('http://myhost.com/foo'); + }); + }); + + describe('assetsHrefBase', () => { + it('default to the serverBasePath if unspecified', () => { + expect(new BasePath({ basePath: '/foo/bar', serverBasePath: '/foo' }).assetsHrefBase).toEqual( + '/foo' ); }); + it('returns the correct value when explicitly set', () => { + expect( + new BasePath({ + basePath: '/foo/bar', + serverBasePath: '/foo', + assetsHrefBase: 'http://cdn/foo', + }).assetsHrefBase + ).toEqual('http://cdn/foo'); + }); }); }); diff --git a/packages/core/http/core-http-browser-internal/src/base_path.ts b/packages/core/http/core-http-browser-internal/src/base_path.ts index 63fb8917421e0..4eaa71f8290d9 100644 --- a/packages/core/http/core-http-browser-internal/src/base_path.ts +++ b/packages/core/http/core-http-browser-internal/src/base_path.ts @@ -10,18 +10,36 @@ import { IBasePath } from '@kbn/core-http-browser'; import { modifyUrl } from '@kbn/std'; export class BasePath implements IBasePath { - constructor( - private readonly basePath: string = '', - public readonly serverBasePath: string = basePath, - public readonly publicBaseUrl?: string - ) {} + private readonly basePath: string; + public readonly serverBasePath: string; + public readonly assetsHrefBase: string; + public readonly publicBaseUrl?: string; + + constructor({ + basePath, + serverBasePath, + assetsHrefBase, + publicBaseUrl, + }: { + basePath: string; + serverBasePath?: string; + assetsHrefBase?: string; + publicBaseUrl?: string; + }) { + this.basePath = basePath; + this.serverBasePath = serverBasePath ?? this.basePath; + this.assetsHrefBase = assetsHrefBase ?? this.serverBasePath; + this.publicBaseUrl = publicBaseUrl; + } public get = () => { return this.basePath; }; public prepend = (path: string): string => { - if (!this.basePath) return path; + if (!this.basePath) { + return path; + } return modifyUrl(path, (parts) => { if (!parts.hostname && parts.pathname && parts.pathname.startsWith('/')) { parts.pathname = `${this.basePath}${parts.pathname}`; diff --git a/packages/core/http/core-http-browser-internal/src/fetch.test.ts b/packages/core/http/core-http-browser-internal/src/fetch.test.ts index b46a34f768b66..d4f37a6601b69 100644 --- a/packages/core/http/core-http-browser-internal/src/fetch.test.ts +++ b/packages/core/http/core-http-browser-internal/src/fetch.test.ts @@ -27,7 +27,7 @@ const BASE_PATH = 'http://localhost/myBase'; describe('Fetch', () => { const executionContextMock = executionContextServiceMock.createSetupContract(); const fetchInstance = new Fetch({ - basePath: new BasePath(BASE_PATH), + basePath: new BasePath({ basePath: BASE_PATH }), kibanaVersion: 'VERSION', buildNumber: 1234, executionContext: executionContextMock, diff --git a/packages/core/http/core-http-browser-internal/src/http_service.ts b/packages/core/http/core-http-browser-internal/src/http_service.ts index d097dc7a14c9a..a054ca3a7c11c 100644 --- a/packages/core/http/core-http-browser-internal/src/http_service.ts +++ b/packages/core/http/core-http-browser-internal/src/http_service.ts @@ -10,8 +10,9 @@ import type { CoreService } from '@kbn/core-base-browser-internal'; import type { ExecutionContextSetup } from '@kbn/core-execution-context-browser'; import type { InternalInjectedMetadataSetup } from '@kbn/core-injected-metadata-browser-internal'; import type { FatalErrorsSetup } from '@kbn/core-fatal-errors-browser'; -import type { HttpSetup, HttpStart } from '@kbn/core-http-browser'; +import type { InternalHttpSetup, InternalHttpStart } from './types'; import { BasePath } from './base_path'; +import { StaticAssets } from './static_assets'; import { AnonymousPathsService } from './anonymous_paths_service'; import { LoadingCountService } from './loading_count_service'; import { Fetch } from './fetch'; @@ -24,19 +25,23 @@ interface HttpDeps { } /** @internal */ -export class HttpService implements CoreService { +export class HttpService implements CoreService { private readonly anonymousPaths = new AnonymousPathsService(); private readonly loadingCount = new LoadingCountService(); - private service?: HttpSetup; + private service?: InternalHttpSetup; - public setup({ injectedMetadata, fatalErrors, executionContext }: HttpDeps): HttpSetup { + public setup({ injectedMetadata, fatalErrors, executionContext }: HttpDeps): InternalHttpSetup { const kibanaVersion = injectedMetadata.getKibanaVersion(); const buildNumber = injectedMetadata.getKibanaBuildNumber(); - const basePath = new BasePath( - injectedMetadata.getBasePath(), - injectedMetadata.getServerBasePath(), - injectedMetadata.getPublicBaseUrl() - ); + const basePath = new BasePath({ + basePath: injectedMetadata.getBasePath(), + serverBasePath: injectedMetadata.getServerBasePath(), + publicBaseUrl: injectedMetadata.getPublicBaseUrl(), + assetsHrefBase: injectedMetadata.getAssetsHrefBase(), + }); + const staticAssets = new StaticAssets({ + assetsHrefBase: injectedMetadata.getAssetsHrefBase(), + }); const fetchService = new Fetch({ basePath, kibanaVersion, buildNumber, executionContext }); const loadingCount = this.loadingCount.setup({ fatalErrors }); @@ -44,6 +49,7 @@ export class HttpService implements CoreService { this.service = { basePath, + staticAssets, anonymousPaths: this.anonymousPaths.setup({ basePath }), externalUrl: new ExternalUrlService().setup({ injectedMetadata, location: window.location }), intercept: fetchService.intercept.bind(fetchService), diff --git a/packages/core/http/core-http-browser-internal/src/static_assets.test.ts b/packages/core/http/core-http-browser-internal/src/static_assets.test.ts new file mode 100644 index 0000000000000..c9083e2fd0177 --- /dev/null +++ b/packages/core/http/core-http-browser-internal/src/static_assets.test.ts @@ -0,0 +1,34 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { StaticAssets } from './static_assets'; + +describe('StaticAssets', () => { + describe('#getPluginAssetHref()', () => { + it('returns the expected value when the base is a path', () => { + const staticAssets = new StaticAssets({ assetsHrefBase: '/base-path' }); + expect(staticAssets.getPluginAssetHref('foo', 'path/to/img.gif')).toEqual( + '/base-path/plugins/foo/assets/path/to/img.gif' + ); + }); + + it('returns the expected value when the base is a full url', () => { + const staticAssets = new StaticAssets({ assetsHrefBase: 'http://cdn/cdn-base-path' }); + expect(staticAssets.getPluginAssetHref('bar', 'path/to/img.gif')).toEqual( + 'http://cdn/cdn-base-path/plugins/bar/assets/path/to/img.gif' + ); + }); + + it('removes leading slash from the', () => { + const staticAssets = new StaticAssets({ assetsHrefBase: '/base-path' }); + expect(staticAssets.getPluginAssetHref('dolly', '/path/for/something.svg')).toEqual( + '/base-path/plugins/dolly/assets/path/for/something.svg' + ); + }); + }); +}); diff --git a/packages/core/http/core-http-browser-internal/src/static_assets.ts b/packages/core/http/core-http-browser-internal/src/static_assets.ts new file mode 100644 index 0000000000000..02218e3d375d6 --- /dev/null +++ b/packages/core/http/core-http-browser-internal/src/static_assets.ts @@ -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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { InternalStaticAssets } from './types'; + +export class StaticAssets implements InternalStaticAssets { + public readonly assetsHrefBase: string; + + constructor({ assetsHrefBase }: { assetsHrefBase: string }) { + this.assetsHrefBase = assetsHrefBase.endsWith('/') + ? assetsHrefBase.slice(0, -1) + : assetsHrefBase; + } + + getPluginAssetHref(pluginName: string, assetPath: string): string { + if (assetPath.startsWith('/')) { + assetPath = assetPath.slice(1); + } + return `${this.assetsHrefBase}/plugins/${pluginName}/assets/${assetPath}`; + } +} diff --git a/packages/core/http/core-http-browser-internal/src/types.ts b/packages/core/http/core-http-browser-internal/src/types.ts new file mode 100644 index 0000000000000..83e47ff0b7262 --- /dev/null +++ b/packages/core/http/core-http-browser-internal/src/types.ts @@ -0,0 +1,21 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { HttpSetup, HttpStart } from '@kbn/core-http-browser'; + +export type InternalHttpSetup = Omit & { + staticAssets: InternalStaticAssets; +}; + +export type InternalHttpStart = Omit & { + staticAssets: InternalStaticAssets; +}; + +export interface InternalStaticAssets { + getPluginAssetHref(pluginId: string, assetPath: string): string; +} diff --git a/packages/core/http/core-http-browser-mocks/src/base_path.mock.ts b/packages/core/http/core-http-browser-mocks/src/base_path.mock.ts index 9d36d4e33c106..ad27677dd41ff 100644 --- a/packages/core/http/core-http-browser-mocks/src/base_path.mock.ts +++ b/packages/core/http/core-http-browser-mocks/src/base_path.mock.ts @@ -11,13 +11,15 @@ import type { IBasePath } from '@kbn/core-http-browser'; const createBasePathMock = ({ publicBaseUrl = '/', serverBasePath = '/', -}: { publicBaseUrl?: string; serverBasePath?: string } = {}) => { + assetsHrefBase = '/', +}: { publicBaseUrl?: string; serverBasePath?: string; assetsHrefBase?: string } = {}) => { const mock: jest.Mocked = { prepend: jest.fn(), get: jest.fn(), remove: jest.fn(), publicBaseUrl, serverBasePath, + assetsHrefBase, }; return mock; diff --git a/packages/core/http/core-http-browser-mocks/src/http_service.mock.ts b/packages/core/http/core-http-browser-mocks/src/http_service.mock.ts index 553e09875ae9e..45b445b39fad4 100644 --- a/packages/core/http/core-http-browser-mocks/src/http_service.mock.ts +++ b/packages/core/http/core-http-browser-mocks/src/http_service.mock.ts @@ -29,7 +29,10 @@ const createServiceMock = ({ patch: jest.fn(), delete: jest.fn(), options: jest.fn(), - basePath: new BasePath(basePath, undefined, publicBaseUrl), + basePath: new BasePath({ + basePath, + publicBaseUrl, + }), anonymousPaths: { register: jest.fn(), isAnonymous: jest.fn(), @@ -38,6 +41,9 @@ const createServiceMock = ({ isInternalUrl: jest.fn(), validateUrl: jest.fn(), }, + staticAssets: { + getPluginAssetHref: jest.fn(), + }, addLoadingCountSource: jest.fn(), getLoadingCount$: jest.fn().mockReturnValue(new BehaviorSubject(0)), intercept: jest.fn(), diff --git a/packages/core/http/core-http-browser/index.ts b/packages/core/http/core-http-browser/index.ts index 5f733d720c17d..de1e201132d3d 100644 --- a/packages/core/http/core-http-browser/index.ts +++ b/packages/core/http/core-http-browser/index.ts @@ -12,6 +12,7 @@ export type { IBasePath, IExternalUrl, IAnonymousPaths, + IStaticAssets, HttpHeadersInit, HttpRequestInit, HttpFetchQuery, diff --git a/packages/core/http/core-http-browser/src/types.ts b/packages/core/http/core-http-browser/src/types.ts index e9b3d2ecdd660..5d270d77afc2e 100644 --- a/packages/core/http/core-http-browser/src/types.ts +++ b/packages/core/http/core-http-browser/src/types.ts @@ -19,6 +19,12 @@ export interface HttpSetup { */ basePath: IBasePath; + /** + * APIs for creating hrefs to static assets. + * See {@link IStaticAssets} + */ + staticAssets: IStaticAssets; + /** * APIs for denoting certain paths for not requiring authentication */ @@ -96,6 +102,12 @@ export interface IBasePath { */ readonly serverBasePath: string; + /** + * Href (hypertext reference) intended to be used as the base for constructing + * other hrefs to static assets. + */ + readonly assetsHrefBase: string; + /** * The server's publicly exposed base URL, if configured. Includes protocol, host, port (optional) and the * {@link IBasePath.serverBasePath}. @@ -105,6 +117,7 @@ export interface IBasePath { */ readonly publicBaseUrl?: string; } + /** * APIs for working with external URLs. * @@ -130,6 +143,25 @@ export interface IExternalUrl { validateUrl(relativeOrAbsoluteUrl: string): URL | null; } +/** + * APIs for creating hrefs to static assets. + * + * @public + */ +export interface IStaticAssets { + /** + * Gets the full href to the current plugin's asset, + * given its path relative to the plugin's `public/assets` folder. + * + * @example + * ```ts + * // I want to retrieve the href for the asset stored under `my_plugin/public/assets/some_folder/asset.png`: + * const assetHref = core.http.statisAssets.getPluginAssetHref('some_folder/asset.png'); + * ``` + */ + getPluginAssetHref(assetPath: string): string; +} + /** * APIs for denoting paths as not requiring authentication */ @@ -318,10 +350,13 @@ export interface HttpHandler { path: string, options: HttpFetchOptions & { asResponse: true } ): Promise>; + (options: HttpFetchOptionsWithPath & { asResponse: true }): Promise< HttpResponse >; + (path: string, options?: HttpFetchOptions): Promise; + (options: HttpFetchOptionsWithPath): Promise; } @@ -368,6 +403,7 @@ export interface HttpInterceptorResponseError extends HttpResponse { request: Readonly; error: Error | IHttpFetchError; } + /** @public */ export interface HttpInterceptorRequestError { fetchOptions: Readonly; @@ -429,6 +465,7 @@ export interface HttpInterceptor { export interface IHttpInterceptController { /** Whether or not this chain has been halted. */ halted: boolean; + /** Halt the request Promise chain and do not process further interceptors or response handlers. */ halt(): void; } diff --git a/packages/core/http/core-http-server-internal/src/http_server.test.ts b/packages/core/http/core-http-server-internal/src/http_server.test.ts index f188d7a06552e..f70b035c5f22f 100644 --- a/packages/core/http/core-http-server-internal/src/http_server.test.ts +++ b/packages/core/http/core-http-server-internal/src/http_server.test.ts @@ -82,6 +82,7 @@ beforeEach(() => { cors: { enabled: false, }, + cdn: {}, shutdownTimeout: moment.duration(500, 'ms'), } as any; diff --git a/packages/core/http/core-http-server-internal/src/http_server.ts b/packages/core/http/core-http-server-internal/src/http_server.ts index c8a6f55e0a55e..fb776f5d29eb6 100644 --- a/packages/core/http/core-http-server-internal/src/http_server.ts +++ b/packages/core/http/core-http-server-internal/src/http_server.ts @@ -58,7 +58,7 @@ import { AuthStateStorage } from './auth_state_storage'; import { AuthHeadersStorage } from './auth_headers_storage'; import { BasePath } from './base_path_service'; import { getEcsResponseLog } from './logging'; -import { StaticAssets, type IStaticAssets } from './static_assets'; +import { StaticAssets, type InternalStaticAssets } from './static_assets'; /** * Adds ELU timings for the executed function to the current's context transaction @@ -136,7 +136,7 @@ export interface HttpServerSetup { * @note Static assets may be served over CDN */ registerStaticDir: (path: string, dirPath: string) => void; - staticAssets: IStaticAssets; + staticAssets: InternalStaticAssets; basePath: HttpServiceSetup['basePath']; csp: HttpServiceSetup['csp']; createCookieSessionStorageFactory: HttpServiceSetup['createCookieSessionStorageFactory']; diff --git a/packages/core/http/core-http-server-internal/src/http_service.ts b/packages/core/http/core-http-server-internal/src/http_service.ts index 96e9c8a85ba89..99d286b26f83f 100644 --- a/packages/core/http/core-http-server-internal/src/http_service.ts +++ b/packages/core/http/core-http-server-internal/src/http_service.ts @@ -199,7 +199,7 @@ export class HttpService // the `plugin` and `legacy` services. public getStartContract(): InternalHttpServiceStart { return { - ...pick(this.internalSetup!, ['auth', 'basePath', 'getServerInfo']), + ...pick(this.internalSetup!, ['auth', 'basePath', 'getServerInfo', 'staticAssets']), isListening: () => this.httpServer.isListening(), }; } diff --git a/packages/core/http/core-http-server-internal/src/static_assets.test.ts b/packages/core/http/core-http-server-internal/src/static_assets.test.ts index d80ec6aaf6ed8..0b1acd4e73fd9 100644 --- a/packages/core/http/core-http-server-internal/src/static_assets.test.ts +++ b/packages/core/http/core-http-server-internal/src/static_assets.test.ts @@ -14,18 +14,48 @@ describe('StaticAssets', () => { let basePath: BasePath; let cdnConfig: CdnConfig; let staticAssets: StaticAssets; + beforeEach(() => { - basePath = new BasePath('/test'); - cdnConfig = CdnConfig.from(); - staticAssets = new StaticAssets(basePath, cdnConfig); + basePath = new BasePath('/base-path'); }); - it('provides fallsback to server base path', () => { - expect(staticAssets.getHrefBase()).toEqual('/test'); + + describe('#getHrefBase()', () => { + it('provides fallback to server base path', () => { + cdnConfig = CdnConfig.from(); + staticAssets = new StaticAssets(basePath, cdnConfig); + expect(staticAssets.getHrefBase()).toEqual('/base-path'); + }); + + it('provides the correct HREF given a CDN is configured', () => { + cdnConfig = CdnConfig.from({ url: 'https://cdn.example.com/test' }); + staticAssets = new StaticAssets(basePath, cdnConfig); + expect(staticAssets.getHrefBase()).toEqual('https://cdn.example.com/test'); + }); }); - it('provides the correct HREF given a CDN is configured', () => { - cdnConfig = CdnConfig.from({ url: 'https://cdn.example.com/test' }); - staticAssets = new StaticAssets(basePath, cdnConfig); - expect(staticAssets.getHrefBase()).toEqual('https://cdn.example.com/test'); + describe('#getPluginAssetHref()', () => { + it('returns the expected value when CDN config is not set', () => { + cdnConfig = CdnConfig.from(); + staticAssets = new StaticAssets(basePath, cdnConfig); + expect(staticAssets.getPluginAssetHref('foo', 'path/to/img.gif')).toEqual( + '/base-path/plugins/foo/assets/path/to/img.gif' + ); + }); + + it('returns the expected value when CDN config is set', () => { + cdnConfig = CdnConfig.from({ url: 'https://cdn.example.com/test' }); + staticAssets = new StaticAssets(basePath, cdnConfig); + expect(staticAssets.getPluginAssetHref('bar', 'path/to/img.gif')).toEqual( + 'https://cdn.example.com/test/plugins/bar/assets/path/to/img.gif' + ); + }); + + it('removes leading slash from the', () => { + cdnConfig = CdnConfig.from(); + staticAssets = new StaticAssets(basePath, cdnConfig); + expect(staticAssets.getPluginAssetHref('dolly', '/path/for/something.svg')).toEqual( + '/base-path/plugins/dolly/assets/path/for/something.svg' + ); + }); }); }); diff --git a/packages/core/http/core-http-server-internal/src/static_assets.ts b/packages/core/http/core-http-server-internal/src/static_assets.ts index b4e7a529fe948..4dfe46d8d31a6 100644 --- a/packages/core/http/core-http-server-internal/src/static_assets.ts +++ b/packages/core/http/core-http-server-internal/src/static_assets.ts @@ -9,20 +9,31 @@ import type { BasePath } from './base_path_service'; import { CdnConfig } from './cdn'; -export interface IStaticAssets { +export interface InternalStaticAssets { getHrefBase(): string; + getPluginAssetHref(pluginName: string, assetPath: string): string; } -export class StaticAssets implements IStaticAssets { - constructor(private readonly basePath: BasePath, private readonly cdnConfig: CdnConfig) {} +export class StaticAssets implements InternalStaticAssets { + private readonly assetsHrefBase: string; + + constructor(basePath: BasePath, cdnConfig: CdnConfig) { + const hrefToUse = cdnConfig.baseHref ?? basePath.serverBasePath; + this.assetsHrefBase = hrefToUse.endsWith('/') ? hrefToUse.slice(0, -1) : hrefToUse; + } + /** * Returns a href (hypertext reference) intended to be used as the base for constructing * other hrefs to static assets. */ getHrefBase(): string { - if (this.cdnConfig.baseHref) { - return this.cdnConfig.baseHref; + return this.assetsHrefBase; + } + + getPluginAssetHref(pluginName: string, assetPath: string): string { + if (assetPath.startsWith('/')) { + assetPath = assetPath.slice(1); } - return this.basePath.serverBasePath; + return `${this.assetsHrefBase}/plugins/${pluginName}/assets/${assetPath}`; } } diff --git a/packages/core/http/core-http-server-internal/src/types.ts b/packages/core/http/core-http-server-internal/src/types.ts index 0acbb0d0508d6..72dde630e03db 100644 --- a/packages/core/http/core-http-server-internal/src/types.ts +++ b/packages/core/http/core-http-server-internal/src/types.ts @@ -16,8 +16,9 @@ import type { HttpServiceSetup, HttpServiceStart, } from '@kbn/core-http-server'; -import { HttpServerSetup } from './http_server'; -import { ExternalUrlConfig } from './external_url'; +import type { HttpServerSetup } from './http_server'; +import type { ExternalUrlConfig } from './external_url'; +import type { InternalStaticAssets } from './static_assets'; /** @internal */ export interface InternalHttpServicePreboot @@ -43,10 +44,10 @@ export interface InternalHttpServicePreboot /** @internal */ export interface InternalHttpServiceSetup - extends Omit { + extends Omit { auth: HttpServerSetup['auth']; server: HttpServerSetup['server']; - staticAssets: HttpServerSetup['staticAssets']; + staticAssets: InternalStaticAssets; externalUrl: ExternalUrlConfig; createRouter: ( path: string, @@ -66,7 +67,8 @@ export interface InternalHttpServiceSetup } /** @internal */ -export interface InternalHttpServiceStart extends HttpServiceStart { +export interface InternalHttpServiceStart extends Omit { + staticAssets: InternalStaticAssets; /** Indicates if the http server is listening on the configured port */ isListening: () => boolean; } diff --git a/packages/core/http/core-http-server-mocks/src/http_service.mock.ts b/packages/core/http/core-http-server-mocks/src/http_service.mock.ts index ad7e310f5a2d8..f8ecfadfeb87e 100644 --- a/packages/core/http/core-http-server-mocks/src/http_service.mock.ts +++ b/packages/core/http/core-http-server-mocks/src/http_service.mock.ts @@ -20,6 +20,7 @@ import type { HttpServicePreboot, HttpServiceSetup, HttpServiceStart, + IStaticAssets, } from '@kbn/core-http-server'; import { AuthStatus } from '@kbn/core-http-server'; import { mockRouter, RouterMock } from '@kbn/core-http-router-server-mocks'; @@ -34,17 +35,19 @@ import type { import { sessionStorageMock } from './cookie_session_storage.mocks'; type BasePathMocked = jest.Mocked; -type StaticAssetsMocked = jest.Mocked; +type InternalStaticAssetsMocked = jest.Mocked; +type StaticAssetsMocked = jest.Mocked; type AuthMocked = jest.Mocked; export type HttpServicePrebootMock = jest.Mocked; export type InternalHttpServicePrebootMock = jest.Mocked< Omit -> & { basePath: BasePathMocked; staticAssets: StaticAssetsMocked }; +> & { basePath: BasePathMocked; staticAssets: InternalStaticAssetsMocked }; export type HttpServiceSetupMock< ContextType extends RequestHandlerContextBase = RequestHandlerContextBase > = jest.Mocked, 'basePath' | 'createRouter'>> & { basePath: BasePathMocked; + staticAssets: StaticAssetsMocked; createRouter: jest.MockedFunction<() => RouterMock>; }; export type InternalHttpServiceSetupMock = jest.Mocked< @@ -55,15 +58,17 @@ export type InternalHttpServiceSetupMock = jest.Mocked< > & { auth: AuthMocked; basePath: BasePathMocked; - staticAssets: StaticAssetsMocked; + staticAssets: InternalStaticAssetsMocked; createRouter: jest.MockedFunction<(path: string) => RouterMock>; authRequestHeaders: jest.Mocked; }; export type HttpServiceStartMock = jest.Mocked & { basePath: BasePathMocked; + staticAssets: StaticAssetsMocked; }; export type InternalHttpServiceStartMock = jest.Mocked & { basePath: BasePathMocked; + staticAssets: InternalStaticAssetsMocked; }; const createBasePathMock = ( @@ -78,11 +83,12 @@ const createBasePathMock = ( remove: jest.fn(), }); -const createStaticAssetsMock = ( +const createInternalStaticAssetsMock = ( basePath: BasePathMocked, cdnUrl: undefined | string = undefined -): StaticAssetsMocked => ({ +): InternalStaticAssetsMocked => ({ getHrefBase: jest.fn(() => cdnUrl ?? basePath.serverBasePath), + getPluginAssetHref: jest.fn().mockReturnValue(cdnUrl ?? basePath.serverBasePath), }); const createAuthMock = () => { @@ -106,6 +112,7 @@ const createAuthHeaderStorageMock = () => { interface CreateMockArgs { cdnUrl?: string; } + const createInternalPrebootContractMock = (args: CreateMockArgs = {}) => { const basePath = createBasePathMock(); const mock: InternalHttpServicePrebootMock = { @@ -113,7 +120,7 @@ const createInternalPrebootContractMock = (args: CreateMockArgs = {}) => { registerRouteHandlerContext: jest.fn(), registerStaticDir: jest.fn(), basePath, - staticAssets: createStaticAssetsMock(basePath, args.cdnUrl), + staticAssets: createInternalStaticAssetsMock(basePath, args.cdnUrl), csp: CspConfig.DEFAULT, externalUrl: ExternalUrlConfig.DEFAULT, auth: createAuthMock(), @@ -144,6 +151,7 @@ const createPrebootContractMock = () => { }; const createInternalSetupContractMock = () => { + const basePath = createBasePathMock(); const mock: InternalHttpServiceSetupMock = { // we can mock other hapi server methods when we need it server: { @@ -164,9 +172,9 @@ const createInternalSetupContractMock = () => { registerOnPreResponse: jest.fn(), createRouter: jest.fn().mockImplementation(() => mockRouter.create({})), registerStaticDir: jest.fn(), - basePath: createBasePathMock(), + basePath, csp: CspConfig.DEFAULT, - staticAssets: { getHrefBase: jest.fn(() => mock.basePath.serverBasePath) }, + staticAssets: createInternalStaticAssetsMock(basePath), externalUrl: ExternalUrlConfig.DEFAULT, auth: createAuthMock(), authRequestHeaders: createAuthHeaderStorageMock(), @@ -202,6 +210,9 @@ const createSetupContractMock = < createRouter: jest.fn(), registerRouteHandlerContext: jest.fn(), getServerInfo: internalMock.getServerInfo, + staticAssets: { + getPluginAssetHref: jest.fn().mockImplementation((assetPath: string) => assetPath), + }, }; mock.createRouter.mockImplementation(() => internalMock.createRouter('')); @@ -214,14 +225,19 @@ const createStartContractMock = () => { auth: createAuthMock(), basePath: createBasePathMock(), getServerInfo: jest.fn(), + staticAssets: { + getPluginAssetHref: jest.fn().mockImplementation((assetPath: string) => assetPath), + }, }; return mock; }; const createInternalStartContractMock = () => { + const basePath = createBasePathMock(); const mock: InternalHttpServiceStartMock = { ...createStartContractMock(), + staticAssets: createInternalStaticAssetsMock(basePath), isListening: jest.fn(), }; diff --git a/packages/core/http/core-http-server/index.ts b/packages/core/http/core-http-server/index.ts index 94eefba610a44..9a28a7be5033e 100644 --- a/packages/core/http/core-http-server/index.ts +++ b/packages/core/http/core-http-server/index.ts @@ -142,3 +142,5 @@ export type { VersionedRouteRegistrar, VersionedRouter, } from './src/versioning'; + +export type { IStaticAssets } from './src/static_assets'; diff --git a/packages/core/http/core-http-server/src/http_contract.ts b/packages/core/http/core-http-server/src/http_contract.ts index 753b7b8cf0066..8ac34b26a386c 100644 --- a/packages/core/http/core-http-server/src/http_contract.ts +++ b/packages/core/http/core-http-server/src/http_contract.ts @@ -20,6 +20,7 @@ import type { OnPreRoutingHandler, } from './lifecycle'; import type { IBasePath } from './base_path'; +import type { IStaticAssets } from './static_assets'; import type { ICspConfig } from './csp'; import type { GetAuthState, IsAuthenticated } from './auth_state'; import type { SessionStorageCookieOptions, SessionStorageFactory } from './session_storage'; @@ -287,6 +288,12 @@ export interface HttpServiceSetup< */ basePath: IBasePath; + /** + * APIs for creating hrefs to static assets. + * See {@link IStaticAssets} + */ + staticAssets: IStaticAssets; + /** * The CSP config used for Kibana. */ @@ -361,6 +368,12 @@ export interface HttpServiceStart { */ basePath: IBasePath; + /** + * APIs for creating hrefs to static assets. + * See {@link IStaticAssets} + */ + staticAssets: IStaticAssets; + /** * Auth status. * See {@link HttpAuth} diff --git a/packages/core/http/core-http-server/src/static_assets.ts b/packages/core/http/core-http-server/src/static_assets.ts new file mode 100644 index 0000000000000..c0cc8597d1540 --- /dev/null +++ b/packages/core/http/core-http-server/src/static_assets.ts @@ -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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +/** + * APIs for creating hrefs to static assets. + * + * @public + */ +export interface IStaticAssets { + /** + * Gets the full href to the current plugin's asset, + * given its path relative to the plugin's `public/assets` folder. + * + * @example + * ```ts + * // I want to retrieve the href for the asset stored under `my_plugin/public/assets/some_folder/asset.png`: + * const assetHref = core.http.statisAssets.getPluginAssetHref('some_folder/asset.png'); + * ``` + */ + getPluginAssetHref(assetPath: string): string; +} diff --git a/packages/core/injected-metadata/core-injected-metadata-browser-internal/src/injected_metadata_service.ts b/packages/core/injected-metadata/core-injected-metadata-browser-internal/src/injected_metadata_service.ts index ca818f9f79dc7..a50de7ca3f5e7 100644 --- a/packages/core/injected-metadata/core-injected-metadata-browser-internal/src/injected_metadata_service.ts +++ b/packages/core/injected-metadata/core-injected-metadata-browser-internal/src/injected_metadata_service.ts @@ -48,6 +48,10 @@ export class InjectedMetadataService { return this.state.publicBaseUrl; }, + getAssetsHrefBase: () => { + return this.state.assetsHrefBase; + }, + getAnonymousStatusPage: () => { return this.state.anonymousStatusPage; }, diff --git a/packages/core/injected-metadata/core-injected-metadata-browser-internal/src/types.ts b/packages/core/injected-metadata/core-injected-metadata-browser-internal/src/types.ts index 67c9c6ff4d665..3b996e68e50b3 100644 --- a/packages/core/injected-metadata/core-injected-metadata-browser-internal/src/types.ts +++ b/packages/core/injected-metadata/core-injected-metadata-browser-internal/src/types.ts @@ -29,6 +29,7 @@ export interface InternalInjectedMetadataSetup { getBasePath: () => string; getServerBasePath: () => string; getPublicBaseUrl: () => string | undefined; + getAssetsHrefBase: () => string; getKibanaBuildNumber: () => number; getKibanaBranch: () => string; getKibanaVersion: () => string; diff --git a/packages/core/injected-metadata/core-injected-metadata-browser-mocks/src/injected_metadata_service.mock.ts b/packages/core/injected-metadata/core-injected-metadata-browser-mocks/src/injected_metadata_service.mock.ts index 98f1f8c65c37f..3d76d48cbdb9b 100644 --- a/packages/core/injected-metadata/core-injected-metadata-browser-mocks/src/injected_metadata_service.mock.ts +++ b/packages/core/injected-metadata/core-injected-metadata-browser-mocks/src/injected_metadata_service.mock.ts @@ -16,6 +16,7 @@ const createSetupContractMock = () => { const setupContract: jest.Mocked = { getBasePath: jest.fn(), getServerBasePath: jest.fn(), + getAssetsHrefBase: jest.fn(), getPublicBaseUrl: jest.fn(), getKibanaVersion: jest.fn(), getKibanaBranch: jest.fn(), @@ -31,6 +32,9 @@ const createSetupContractMock = () => { getKibanaBuildNumber: jest.fn(), getCustomBranding: jest.fn(), }; + setupContract.getBasePath.mockReturnValue('/base-path'); + setupContract.getServerBasePath.mockReturnValue('/server-base-path'); + setupContract.getAssetsHrefBase.mockReturnValue('/assets-base-path'); setupContract.getCspConfig.mockReturnValue({ warnLegacyBrowsers: true }); setupContract.getExternalUrlConfig.mockReturnValue({ policy: [] }); setupContract.getKibanaVersion.mockReturnValue('kibanaVersion'); diff --git a/packages/core/injected-metadata/core-injected-metadata-common-internal/src/types.ts b/packages/core/injected-metadata/core-injected-metadata-common-internal/src/types.ts index 944ec94554b25..dd9d6bced5c98 100644 --- a/packages/core/injected-metadata/core-injected-metadata-common-internal/src/types.ts +++ b/packages/core/injected-metadata/core-injected-metadata-common-internal/src/types.ts @@ -42,6 +42,7 @@ export interface InjectedMetadata { basePath: string; serverBasePath: string; publicBaseUrl?: string; + assetsHrefBase: string; clusterInfo: InjectedMetadataClusterInfo; env: { mode: EnvironmentMode; diff --git a/packages/core/lifecycle/core-lifecycle-browser-internal/src/internal_core_setup.ts b/packages/core/lifecycle/core-lifecycle-browser-internal/src/internal_core_setup.ts index 9ef51b986458c..396c834082422 100644 --- a/packages/core/lifecycle/core-lifecycle-browser-internal/src/internal_core_setup.ts +++ b/packages/core/lifecycle/core-lifecycle-browser-internal/src/internal_core_setup.ts @@ -9,10 +9,12 @@ import type { CoreSetup } from '@kbn/core-lifecycle-browser'; import type { InternalApplicationSetup } from '@kbn/core-application-browser-internal'; import type { InternalInjectedMetadataSetup } from '@kbn/core-injected-metadata-browser-internal'; +import type { InternalHttpSetup } from '@kbn/core-http-browser-internal'; /** @internal */ export interface InternalCoreSetup - extends Omit { + extends Omit { application: InternalApplicationSetup; injectedMetadata: InternalInjectedMetadataSetup; + http: InternalHttpSetup; } diff --git a/packages/core/lifecycle/core-lifecycle-browser-internal/src/internal_core_start.ts b/packages/core/lifecycle/core-lifecycle-browser-internal/src/internal_core_start.ts index f6b20626cd561..1806f52b8292d 100644 --- a/packages/core/lifecycle/core-lifecycle-browser-internal/src/internal_core_start.ts +++ b/packages/core/lifecycle/core-lifecycle-browser-internal/src/internal_core_start.ts @@ -9,9 +9,11 @@ import type { CoreStart } from '@kbn/core-lifecycle-browser'; import type { InternalApplicationStart } from '@kbn/core-application-browser-internal'; import type { InternalInjectedMetadataStart } from '@kbn/core-injected-metadata-browser-internal'; +import type { InternalHttpStart } from '@kbn/core-http-browser-internal'; /** @internal */ -export interface InternalCoreStart extends Omit { +export interface InternalCoreStart extends Omit { application: InternalApplicationStart; injectedMetadata: InternalInjectedMetadataStart; + http: InternalHttpStart; } diff --git a/packages/core/lifecycle/core-lifecycle-browser-internal/tsconfig.json b/packages/core/lifecycle/core-lifecycle-browser-internal/tsconfig.json index 5f6dcff8fd678..7d5c7fd5c06fd 100644 --- a/packages/core/lifecycle/core-lifecycle-browser-internal/tsconfig.json +++ b/packages/core/lifecycle/core-lifecycle-browser-internal/tsconfig.json @@ -14,7 +14,8 @@ "kbn_references": [ "@kbn/core-lifecycle-browser", "@kbn/core-application-browser-internal", - "@kbn/core-injected-metadata-browser-internal" + "@kbn/core-injected-metadata-browser-internal", + "@kbn/core-http-browser-internal" ], "exclude": [ "target/**/*", diff --git a/packages/core/plugins/core-plugins-browser-internal/src/plugin_context.ts b/packages/core/plugins/core-plugins-browser-internal/src/plugin_context.ts index 604eb86093758..94ada11ac5b24 100644 --- a/packages/core/plugins/core-plugins-browser-internal/src/plugin_context.ts +++ b/packages/core/plugins/core-plugins-browser-internal/src/plugin_context.ts @@ -82,7 +82,13 @@ export function createPluginSetupContext< customBranding: deps.customBranding, fatalErrors: deps.fatalErrors, executionContext: deps.executionContext, - http: deps.http, + http: { + ...deps.http, + staticAssets: { + getPluginAssetHref: (assetPath: string) => + deps.http.staticAssets.getPluginAssetHref(plugin.name, assetPath), + }, + }, notifications: deps.notifications, uiSettings: deps.uiSettings, settings: deps.settings, @@ -133,7 +139,13 @@ export function createPluginStartContext< customBranding: deps.customBranding, docLinks: deps.docLinks, executionContext: deps.executionContext, - http: deps.http, + http: { + ...deps.http, + staticAssets: { + getPluginAssetHref: (assetPath: string) => + deps.http.staticAssets.getPluginAssetHref(plugin.name, assetPath), + }, + }, chrome: omit(deps.chrome, 'getComponent'), i18n: deps.i18n, notifications: deps.notifications, diff --git a/packages/core/plugins/core-plugins-browser-internal/src/plugins_service.test.ts b/packages/core/plugins/core-plugins-browser-internal/src/plugins_service.test.ts index 00c056a20d87d..c1c612d387204 100644 --- a/packages/core/plugins/core-plugins-browser-internal/src/plugins_service.test.ts +++ b/packages/core/plugins/core-plugins-browser-internal/src/plugins_service.test.ts @@ -104,6 +104,10 @@ describe('PluginsService', () => { application: expect.any(Object), plugins: expect.any(Object), getStartServices: expect.any(Function), + http: { + ...mockSetupDeps.http, + staticAssets: expect.any(Object), + }, }; // @ts-expect-error this file was not being type checked properly in the past, error is legit mockStartDeps = { @@ -128,6 +132,10 @@ describe('PluginsService', () => { application: expect.any(Object), plugins: expect.any(Object), chrome: omit(mockStartDeps.chrome, 'getComponent'), + http: { + ...mockStartDeps.http, + staticAssets: expect.any(Object), + }, }; // Reset these for each test. diff --git a/packages/core/plugins/core-plugins-server-internal/src/plugin_context.ts b/packages/core/plugins/core-plugins-server-internal/src/plugin_context.ts index 8d493e78aae8b..c3ed7f6a433b9 100644 --- a/packages/core/plugins/core-plugins-server-internal/src/plugin_context.ts +++ b/packages/core/plugins/core-plugins-server-internal/src/plugin_context.ts @@ -235,6 +235,10 @@ export function createPluginSetupContext({ registerOnPostAuth: deps.http.registerOnPostAuth, registerOnPreResponse: deps.http.registerOnPreResponse, basePath: deps.http.basePath, + staticAssets: { + getPluginAssetHref: (assetPath: string) => + deps.http.staticAssets.getPluginAssetHref(plugin.name, assetPath), + }, csp: deps.http.csp, getServerInfo: deps.http.getServerInfo, }, @@ -324,6 +328,10 @@ export function createPluginStartContext({ auth: deps.http.auth, basePath: deps.http.basePath, getServerInfo: deps.http.getServerInfo, + staticAssets: { + getPluginAssetHref: (assetPath: string) => + deps.http.staticAssets.getPluginAssetHref(plugin.name, assetPath), + }, }, savedObjects: { getScopedClient: deps.savedObjects.getScopedClient, diff --git a/packages/core/rendering/core-rendering-server-internal/src/__snapshots__/rendering_service.test.ts.snap b/packages/core/rendering/core-rendering-server-internal/src/__snapshots__/rendering_service.test.ts.snap index d444959de3c9e..535624e4a8320 100644 --- a/packages/core/rendering/core-rendering-server-internal/src/__snapshots__/rendering_service.test.ts.snap +++ b/packages/core/rendering/core-rendering-server-internal/src/__snapshots__/rendering_service.test.ts.snap @@ -3,6 +3,7 @@ exports[`RenderingService preboot() render() renders "core" CDN url injected 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "http://foo.bar:1773", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -70,6 +71,7 @@ Object { exports[`RenderingService preboot() render() renders "core" page 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -133,6 +135,7 @@ Object { exports[`RenderingService preboot() render() renders "core" page driven by settings 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -200,6 +203,7 @@ Object { exports[`RenderingService preboot() render() renders "core" page for blank basepath 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "", "branch": Any, "buildNumber": Any, @@ -263,6 +267,7 @@ Object { exports[`RenderingService preboot() render() renders "core" page for unauthenticated requests 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -326,6 +331,7 @@ Object { exports[`RenderingService preboot() render() renders "core" page with global settings 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -393,6 +399,7 @@ Object { exports[`RenderingService preboot() render() renders "core" with excluded global user settings 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -456,6 +463,7 @@ Object { exports[`RenderingService preboot() render() renders "core" with excluded user settings 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -519,6 +527,7 @@ Object { exports[`RenderingService setup() render() renders "core" CDN url injected 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -591,6 +600,7 @@ Object { exports[`RenderingService setup() render() renders "core" page 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -654,6 +664,7 @@ Object { exports[`RenderingService setup() render() renders "core" page driven by settings 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -726,6 +737,7 @@ Object { exports[`RenderingService setup() render() renders "core" page for blank basepath 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "", "branch": Any, "buildNumber": Any, @@ -794,6 +806,7 @@ Object { exports[`RenderingService setup() render() renders "core" page for unauthenticated requests 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -857,6 +870,7 @@ Object { exports[`RenderingService setup() render() renders "core" page with global settings 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -929,6 +943,7 @@ Object { exports[`RenderingService setup() render() renders "core" with excluded global user settings 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, @@ -997,6 +1012,7 @@ Object { exports[`RenderingService setup() render() renders "core" with excluded user settings 1`] = ` Object { "anonymousStatusPage": false, + "assetsHrefBase": "/mock-server-basepath", "basePath": "/mock-server-basepath", "branch": Any, "buildNumber": Any, diff --git a/packages/core/rendering/core-rendering-server-internal/src/rendering_service.tsx b/packages/core/rendering/core-rendering-server-internal/src/rendering_service.tsx index 1791f55e563b6..f5bb1f5fa115f 100644 --- a/packages/core/rendering/core-rendering-server-internal/src/rendering_service.tsx +++ b/packages/core/rendering/core-rendering-server-internal/src/rendering_service.tsx @@ -209,6 +209,7 @@ export class RenderingService { basePath, serverBasePath, publicBaseUrl, + assetsHrefBase: staticAssetsHrefBase, env, clusterInfo, anonymousStatusPage: status?.isStatusPageAnonymous() ?? false, diff --git a/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_client.ts b/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_client.ts index 0493652b1192f..a5e112ca2aa74 100644 --- a/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_client.ts +++ b/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_client.ts @@ -7,7 +7,8 @@ */ import { pick, throttle, cloneDeep } from 'lodash'; -import type { HttpSetup, HttpFetchOptions } from '@kbn/core-http-browser'; +import type { HttpFetchOptions } from '@kbn/core-http-browser'; +import type { InternalHttpSetup } from '@kbn/core-http-browser-internal'; import type { SavedObject, SavedObjectTypeIdTuple } from '@kbn/core-saved-objects-common'; import type { SavedObjectsBulkResolveResponse as SavedObjectsBulkResolveResponseServer, @@ -106,7 +107,7 @@ const getObjectsToResolve = (queue: BatchResolveQueueEntry[]) => { * @deprecated See https://github.com/elastic/kibana/issues/149098 */ export class SavedObjectsClient implements SavedObjectsClientContract { - private http: HttpSetup; + private http: InternalHttpSetup; private batchGetQueue: BatchGetQueueEntry[]; private batchResolveQueue: BatchResolveQueueEntry[]; @@ -180,7 +181,7 @@ export class SavedObjectsClient implements SavedObjectsClientContract { ); /** @internal */ - constructor(http: HttpSetup) { + constructor(http: InternalHttpSetup) { this.http = http; this.batchGetQueue = []; this.batchResolveQueue = []; diff --git a/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_service.ts b/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_service.ts index 7cef8a1c39057..f806dc6b69ef0 100644 --- a/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_service.ts +++ b/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_service.ts @@ -7,7 +7,7 @@ */ import type { CoreService } from '@kbn/core-base-browser-internal'; -import type { HttpStart } from '@kbn/core-http-browser'; +import type { InternalHttpStart } from '@kbn/core-http-browser-internal'; import type { SavedObjectsStart } from '@kbn/core-saved-objects-browser'; import { SavedObjectsClient } from './saved_objects_client'; @@ -17,7 +17,7 @@ import { SavedObjectsClient } from './saved_objects_client'; export class SavedObjectsService implements CoreService { public async setup() {} - public async start({ http }: { http: HttpStart }): Promise { + public async start({ http }: { http: InternalHttpStart }): Promise { return { client: new SavedObjectsClient(http) }; } diff --git a/packages/core/saved-objects/core-saved-objects-browser-internal/tsconfig.json b/packages/core/saved-objects/core-saved-objects-browser-internal/tsconfig.json index a29dbf58b4117..d9b414c39220e 100644 --- a/packages/core/saved-objects/core-saved-objects-browser-internal/tsconfig.json +++ b/packages/core/saved-objects/core-saved-objects-browser-internal/tsconfig.json @@ -19,6 +19,7 @@ "@kbn/core-saved-objects-api-server", "@kbn/core-saved-objects-api-browser", "@kbn/core-http-browser-mocks", + "@kbn/core-http-browser-internal", ], "exclude": [ "target/**/*", diff --git a/packages/core/ui-settings/core-ui-settings-browser-internal/src/settings_service.ts b/packages/core/ui-settings/core-ui-settings-browser-internal/src/settings_service.ts index edda603644fa2..202f8ceb1206d 100644 --- a/packages/core/ui-settings/core-ui-settings-browser-internal/src/settings_service.ts +++ b/packages/core/ui-settings/core-ui-settings-browser-internal/src/settings_service.ts @@ -9,14 +9,14 @@ import { Subject } from 'rxjs'; import type { InternalInjectedMetadataSetup } from '@kbn/core-injected-metadata-browser-internal'; -import type { HttpSetup } from '@kbn/core-http-browser'; +import type { InternalHttpSetup } from '@kbn/core-http-browser-internal'; import type { SettingsStart, SettingsSetup } from '@kbn/core-ui-settings-browser'; import { UiSettingsApi } from './ui_settings_api'; import { UiSettingsClient } from './ui_settings_client'; import { UiSettingsGlobalClient } from './ui_settings_global_client'; export interface SettingsServiceDeps { - http: HttpSetup; + http: InternalHttpSetup; injectedMetadata: InternalInjectedMetadataSetup; } diff --git a/packages/core/ui-settings/core-ui-settings-browser-internal/src/ui_settings_api.ts b/packages/core/ui-settings/core-ui-settings-browser-internal/src/ui_settings_api.ts index c96232b9f9b48..ac469734609c8 100644 --- a/packages/core/ui-settings/core-ui-settings-browser-internal/src/ui_settings_api.ts +++ b/packages/core/ui-settings/core-ui-settings-browser-internal/src/ui_settings_api.ts @@ -7,7 +7,7 @@ */ import { BehaviorSubject } from 'rxjs'; -import type { HttpSetup } from '@kbn/core-http-browser'; +import type { InternalHttpSetup } from '@kbn/core-http-browser-internal'; import type { UiSettingsState } from '@kbn/core-ui-settings-browser'; import { UiSettingsScope } from '@kbn/core-ui-settings-common'; @@ -37,7 +37,7 @@ export class UiSettingsApi { private readonly loadingCount$ = new BehaviorSubject(0); - constructor(private readonly http: HttpSetup) {} + constructor(private readonly http: InternalHttpSetup) {} /** * Adds a key+value that will be sent to the server ASAP. If a request is diff --git a/packages/core/ui-settings/core-ui-settings-browser-internal/src/ui_settings_service.ts b/packages/core/ui-settings/core-ui-settings-browser-internal/src/ui_settings_service.ts index c531d18aded13..5827919f21ad5 100644 --- a/packages/core/ui-settings/core-ui-settings-browser-internal/src/ui_settings_service.ts +++ b/packages/core/ui-settings/core-ui-settings-browser-internal/src/ui_settings_service.ts @@ -9,14 +9,14 @@ import { Subject } from 'rxjs'; import type { InternalInjectedMetadataSetup } from '@kbn/core-injected-metadata-browser-internal'; -import type { HttpSetup } from '@kbn/core-http-browser'; +import type { InternalHttpSetup } from '@kbn/core-http-browser-internal'; import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser'; import { UiSettingsApi } from './ui_settings_api'; import { UiSettingsClient } from './ui_settings_client'; export interface UiSettingsServiceDeps { - http: HttpSetup; + http: InternalHttpSetup; injectedMetadata: InternalInjectedMetadataSetup; } diff --git a/packages/core/ui-settings/core-ui-settings-browser-internal/tsconfig.json b/packages/core/ui-settings/core-ui-settings-browser-internal/tsconfig.json index 0beed2d6ddfb0..bcedc9db9175e 100644 --- a/packages/core/ui-settings/core-ui-settings-browser-internal/tsconfig.json +++ b/packages/core/ui-settings/core-ui-settings-browser-internal/tsconfig.json @@ -12,12 +12,12 @@ ], "kbn_references": [ "@kbn/core-test-helpers-http-setup-browser", - "@kbn/core-http-browser", "@kbn/core-ui-settings-browser", "@kbn/core-ui-settings-common", "@kbn/core-http-browser-mocks", "@kbn/core-injected-metadata-browser-mocks", "@kbn/core-injected-metadata-browser-internal", + "@kbn/core-http-browser-internal", ], "exclude": [ "target/**/*", diff --git a/packages/home/sample_data_card/src/sample_data_card.tsx b/packages/home/sample_data_card/src/sample_data_card.tsx index a8da0a7494da4..a952431c50971 100644 --- a/packages/home/sample_data_card/src/sample_data_card.tsx +++ b/packages/home/sample_data_card/src/sample_data_card.tsx @@ -6,11 +6,10 @@ * Side Public License, v 1. */ -import React, { useMemo } from 'react'; +import React from 'react'; import { useEuiTheme } from '@elastic/eui'; import type { SampleDataSet } from '@kbn/home-sample-data-types'; -import { useServices } from './services'; import { SampleDataCard as Component, Props as ComponentProps } from './sample_data_card.component'; /** @@ -27,12 +26,10 @@ export interface Props extends Pick { * function. */ export const SampleDataCard = ({ sampleDataSet, onStatusChange }: Props) => { - const { addBasePath } = useServices(); const { colorMode } = useEuiTheme(); const { darkPreviewImagePath, previewImagePath } = sampleDataSet; - const path = + const imagePath = colorMode === 'DARK' && darkPreviewImagePath ? darkPreviewImagePath : previewImagePath; - const imagePath = useMemo(() => addBasePath(path), [addBasePath, path]); return ; }; diff --git a/src/core/public/index.ts b/src/core/public/index.ts index b874a937257b2..6b29603dd63f6 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -187,6 +187,7 @@ export type { HttpResponse, HttpHandler, IBasePath, + IStaticAssets, IAnonymousPaths, IExternalUrl, IHttpInterceptController, diff --git a/src/core/server/index.ts b/src/core/server/index.ts index 30562d389ac41..3e63315e6d8fa 100644 --- a/src/core/server/index.ts +++ b/src/core/server/index.ts @@ -184,6 +184,7 @@ export type { ICspConfig, IExternalUrlConfig, IBasePath, + IStaticAssets, SessionStorage, SessionStorageCookieOptions, SessionCookieValidationResult, diff --git a/src/core/server/integration_tests/http/http_server.test.ts b/src/core/server/integration_tests/http/http_server.test.ts index f65a5b59487be..da10b231b7a22 100644 --- a/src/core/server/integration_tests/http/http_server.test.ts +++ b/src/core/server/integration_tests/http/http_server.test.ts @@ -36,6 +36,7 @@ describe('Http server', () => { allowFromAnyIp: true, ipAllowlist: [], }, + cdn: {}, cors: { enabled: false, }, diff --git a/src/plugins/data_views/public/data_views/data_views_api_client.test.ts b/src/plugins/data_views/public/data_views/data_views_api_client.test.ts index 90a208650a965..f36776153ee3a 100644 --- a/src/plugins/data_views/public/data_views/data_views_api_client.test.ts +++ b/src/plugins/data_views/public/data_views/data_views_api_client.test.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ +import type { HttpSetup } from '@kbn/core/public'; import { http } from './data_views_api_client.test.mock'; import { DataViewsApiClient } from './data_views_api_client'; import { FIELDS_FOR_WILDCARD_PATH as expectedPath } from '../../common/constants'; @@ -16,7 +17,7 @@ describe('IndexPatternsApiClient', () => { beforeEach(() => { fetchSpy = jest.spyOn(http, 'fetch').mockImplementation(() => Promise.resolve({})); - indexPatternsApiClient = new DataViewsApiClient(http); + indexPatternsApiClient = new DataViewsApiClient(http as HttpSetup); }); test('uses the right URI to fetch fields for wildcard', async function () { diff --git a/src/plugins/home/server/services/sample_data/data_sets/ecommerce/index.ts b/src/plugins/home/server/services/sample_data/data_sets/ecommerce/index.ts index e995510c99fee..f68036496914d 100644 --- a/src/plugins/home/server/services/sample_data/data_sets/ecommerce/index.ts +++ b/src/plugins/home/server/services/sample_data/data_sets/ecommerce/index.ts @@ -10,7 +10,7 @@ import path from 'path'; import { i18n } from '@kbn/i18n'; import { getSavedObjects } from './saved_objects'; import { fieldMappings } from './field_mappings'; -import { SampleDatasetSchema } from '../../lib/sample_dataset_registry_types'; +import { SampleDatasetProvider } from '../../lib/sample_dataset_registry_types'; const ecommerceName = i18n.translate('home.sampleData.ecommerceSpecTitle', { defaultMessage: 'Sample eCommerce orders', @@ -19,14 +19,17 @@ const ecommerceDescription = i18n.translate('home.sampleData.ecommerceSpecDescri defaultMessage: 'Sample data, visualizations, and dashboards for tracking eCommerce orders.', }); -export const ecommerceSpecProvider = function (): SampleDatasetSchema { +export const ecommerceSpecProvider: SampleDatasetProvider = ({ staticAssets }) => { return { id: 'ecommerce', name: ecommerceName, description: ecommerceDescription, - previewImagePath: '/plugins/home/assets/sample_data_resources/ecommerce/dashboard.webp', - darkPreviewImagePath: - '/plugins/home/assets/sample_data_resources/ecommerce/dashboard_dark.webp', + previewImagePath: staticAssets.getPluginAssetHref( + '/sample_data_resources/ecommerce/dashboard.webp' + ), + darkPreviewImagePath: staticAssets.getPluginAssetHref( + '/sample_data_resources/ecommerce/dashboard_dark.webp' + ), overviewDashboard: '722b74f0-b882-11e8-a6d9-e546fe2bba5f', defaultIndex: 'ff959d40-b880-11e8-a6d9-e546fe2bba5f', savedObjects: getSavedObjects(), @@ -41,6 +44,6 @@ export const ecommerceSpecProvider = function (): SampleDatasetSchema { }, ], status: 'not_installed', - iconPath: '/plugins/home/assets/sample_data_resources/ecommerce/icon.svg', + iconPath: staticAssets.getPluginAssetHref('/sample_data_resources/ecommerce/icon.svg'), }; }; diff --git a/src/plugins/home/server/services/sample_data/data_sets/flights/index.ts b/src/plugins/home/server/services/sample_data/data_sets/flights/index.ts index 691ac8334cbc3..7481f4cd50721 100644 --- a/src/plugins/home/server/services/sample_data/data_sets/flights/index.ts +++ b/src/plugins/home/server/services/sample_data/data_sets/flights/index.ts @@ -10,7 +10,7 @@ import path from 'path'; import { i18n } from '@kbn/i18n'; import { getSavedObjects } from './saved_objects'; import { fieldMappings } from './field_mappings'; -import { SampleDatasetSchema } from '../../lib/sample_dataset_registry_types'; +import { SampleDatasetProvider } from '../../lib/sample_dataset_registry_types'; const flightsName = i18n.translate('home.sampleData.flightsSpecTitle', { defaultMessage: 'Sample flight data', @@ -19,13 +19,17 @@ const flightsDescription = i18n.translate('home.sampleData.flightsSpecDescriptio defaultMessage: 'Sample data, visualizations, and dashboards for monitoring flight routes.', }); -export const flightsSpecProvider = function (): SampleDatasetSchema { +export const flightsSpecProvider: SampleDatasetProvider = ({ staticAssets }) => { return { id: 'flights', name: flightsName, description: flightsDescription, - previewImagePath: '/plugins/home/assets/sample_data_resources/flights/dashboard.webp', - darkPreviewImagePath: '/plugins/home/assets/sample_data_resources/flights/dashboard_dark.webp', + previewImagePath: staticAssets.getPluginAssetHref( + '/sample_data_resources/flights/dashboard.webp' + ), + darkPreviewImagePath: staticAssets.getPluginAssetHref( + '/sample_data_resources/flights/dashboard_dark.webp' + ), overviewDashboard: '7adfa750-4c81-11e8-b3d7-01146121b73d', defaultIndex: 'd3d7af60-4c81-11e8-b3d7-01146121b73d', savedObjects: getSavedObjects(), @@ -40,6 +44,6 @@ export const flightsSpecProvider = function (): SampleDatasetSchema { }, ], status: 'not_installed', - iconPath: '/plugins/home/assets/sample_data_resources/flights/icon.svg', + iconPath: staticAssets.getPluginAssetHref('/sample_data_resources/flights/icon.svg'), }; }; diff --git a/src/plugins/home/server/services/sample_data/data_sets/logs/index.ts b/src/plugins/home/server/services/sample_data/data_sets/logs/index.ts index 219b7ea2cc9d0..6f001e85c6151 100644 --- a/src/plugins/home/server/services/sample_data/data_sets/logs/index.ts +++ b/src/plugins/home/server/services/sample_data/data_sets/logs/index.ts @@ -10,7 +10,7 @@ import path from 'path'; import { i18n } from '@kbn/i18n'; import { getSavedObjects } from './saved_objects'; import { fieldMappings } from './field_mappings'; -import { SampleDatasetSchema } from '../../lib/sample_dataset_registry_types'; +import { SampleDatasetProvider } from '../../lib/sample_dataset_registry_types'; const logsName = i18n.translate('home.sampleData.logsSpecTitle', { defaultMessage: 'Sample web logs', @@ -20,13 +20,15 @@ const logsDescription = i18n.translate('home.sampleData.logsSpecDescription', { }); export const GLOBE_ICON_PATH = '/plugins/home/assets/sample_data_resources/logs/icon.svg'; -export const logsSpecProvider = function (): SampleDatasetSchema { +export const logsSpecProvider: SampleDatasetProvider = ({ staticAssets }) => { return { id: 'logs', name: logsName, description: logsDescription, - previewImagePath: '/plugins/home/assets/sample_data_resources/logs/dashboard.webp', - darkPreviewImagePath: '/plugins/home/assets/sample_data_resources/logs/dashboard_dark.webp', + previewImagePath: staticAssets.getPluginAssetHref('/sample_data_resources/logs/dashboard.webp'), + darkPreviewImagePath: staticAssets.getPluginAssetHref( + '/sample_data_resources/logs/dashboard_dark.webp' + ), overviewDashboard: 'edf84fe0-e1a0-11e7-b6d5-4dc382ef7f5b', defaultIndex: '90943e30-9a47-11e8-b64d-95841ca0b247', savedObjects: getSavedObjects(), @@ -42,6 +44,6 @@ export const logsSpecProvider = function (): SampleDatasetSchema { }, ], status: 'not_installed', - iconPath: GLOBE_ICON_PATH, + iconPath: staticAssets.getPluginAssetHref('/sample_data_resources/logs/icon.svg'), }; }; diff --git a/src/plugins/home/server/services/sample_data/data_sets/logs_tsdb/index.ts b/src/plugins/home/server/services/sample_data/data_sets/logs_tsdb/index.ts index bfc4ec4554191..39dc153eb2b19 100644 --- a/src/plugins/home/server/services/sample_data/data_sets/logs_tsdb/index.ts +++ b/src/plugins/home/server/services/sample_data/data_sets/logs_tsdb/index.ts @@ -10,7 +10,7 @@ import path from 'path'; import { i18n } from '@kbn/i18n'; import { getSavedObjects } from './saved_objects'; import { fieldMappings } from './field_mappings'; -import { SampleDatasetSchema } from '../../lib/sample_dataset_registry_types'; +import { SampleDatasetProvider } from '../../lib/sample_dataset_registry_types'; const logsName = i18n.translate('home.sampleData.logsTsdbSpecTitle', { defaultMessage: 'Sample web logs (TSDB)', @@ -20,7 +20,7 @@ const logsDescription = i18n.translate('home.sampleData.logsTsdbSpecDescription' }); export const GLOBE_ICON_PATH = '/plugins/home/assets/sample_data_resources/logs/icon.svg'; -export const logsTSDBSpecProvider = function (): SampleDatasetSchema { +export const logsTSDBSpecProvider: SampleDatasetProvider = ({ staticAssets }) => { const startDate = new Date(); const endDate = new Date(); startDate.setMonth(startDate.getMonth() - 1); @@ -29,8 +29,10 @@ export const logsTSDBSpecProvider = function (): SampleDatasetSchema { id: 'logstsdb', name: logsName, description: logsDescription, - previewImagePath: '/plugins/home/assets/sample_data_resources/logs/dashboard.webp', - darkPreviewImagePath: '/plugins/home/assets/sample_data_resources/logs/dashboard_dark.webp', + previewImagePath: staticAssets.getPluginAssetHref('/sample_data_resources/logs/dashboard.webp'), + darkPreviewImagePath: staticAssets.getPluginAssetHref( + '/sample_data_resources/logs/dashboard_dark.webp' + ), overviewDashboard: 'edf84fe0-e1a0-11e7-b6d5-4dc382ef8f5b', defaultIndex: '90943e30-9a47-11e8-b64d-95841ca0c247', savedObjects: getSavedObjects(), @@ -53,6 +55,6 @@ export const logsTSDBSpecProvider = function (): SampleDatasetSchema { }, ], status: 'not_installed', - iconPath: GLOBE_ICON_PATH, + iconPath: staticAssets.getPluginAssetHref('/sample_data_resources/logs/icon.svg'), }; }; diff --git a/src/plugins/home/server/services/sample_data/lib/sample_dataset_registry_types.ts b/src/plugins/home/server/services/sample_data/lib/sample_dataset_registry_types.ts index 9b1212e13b024..eb248cc4d4078 100644 --- a/src/plugins/home/server/services/sample_data/lib/sample_dataset_registry_types.ts +++ b/src/plugins/home/server/services/sample_data/lib/sample_dataset_registry_types.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ +import type { IStaticAssets } from '@kbn/core/server'; import type { SampleDatasetSchema } from './sample_dataset_schema'; export type { SampleDatasetSchema, DataIndexSchema } from './sample_dataset_schema'; @@ -27,7 +28,11 @@ export enum EmbeddableTypes { SEARCH_EMBEDDABLE_TYPE = 'search', VISUALIZE_EMBEDDABLE_TYPE = 'visualization', } -export type SampleDatasetProvider = () => SampleDatasetSchema; + +export interface SampleDatasetProviderContext { + staticAssets: IStaticAssets; +} +export type SampleDatasetProvider = (context: SampleDatasetProviderContext) => SampleDatasetSchema; /** This type is used to identify an object in a sample dataset. */ export interface SampleObject { diff --git a/src/plugins/home/server/services/sample_data/sample_data_registry.ts b/src/plugins/home/server/services/sample_data/sample_data_registry.ts index 47ddc122f82cb..1f96cbe20def2 100644 --- a/src/plugins/home/server/services/sample_data/sample_data_registry.ts +++ b/src/plugins/home/server/services/sample_data/sample_data_registry.ts @@ -15,6 +15,7 @@ import { SampleDatasetSchema, SampleDatasetDashboardPanel, AppLinkData, + SampleDatasetProviderContext, } from './lib/sample_dataset_registry_types'; import { sampleDataSchema } from './lib/sample_dataset_schema'; @@ -34,11 +35,15 @@ export class SampleDataRegistry { private readonly sampleDatasets: SampleDatasetSchema[] = []; private readonly appLinksMap = new Map(); + private sampleDataProviderContext?: SampleDatasetProviderContext; private registerSampleDataSet(specProvider: SampleDatasetProvider) { + if (!this.sampleDataProviderContext) { + throw new Error('#registerSampleDataSet called before #setup'); + } let value: SampleDatasetSchema; try { - value = sampleDataSchema.validate(specProvider()); + value = sampleDataSchema.validate(specProvider(this.sampleDataProviderContext)); } catch (error) { throw new Error(`Unable to register sample dataset spec because it's invalid. ${error}`); } @@ -83,6 +88,10 @@ export class SampleDataRegistry { createInstallRoute(router, this.sampleDatasets, logger, usageTracker, core.analytics); createUninstallRoute(router, this.sampleDatasets, logger, usageTracker, core.analytics); + this.sampleDataProviderContext = { + staticAssets: core.http.staticAssets, + }; + this.registerSampleDataSet(flightsSpecProvider); this.registerSampleDataSet(logsSpecProvider); this.registerSampleDataSet(ecommerceSpecProvider); diff --git a/src/plugins/home/server/services/tutorials/lib/tutorials_registry_types.ts b/src/plugins/home/server/services/tutorials/lib/tutorials_registry_types.ts index f0746764f4641..dd625c6086717 100644 --- a/src/plugins/home/server/services/tutorials/lib/tutorials_registry_types.ts +++ b/src/plugins/home/server/services/tutorials/lib/tutorials_registry_types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { KibanaRequest } from '@kbn/core/server'; +import type { KibanaRequest, IStaticAssets } from '@kbn/core/server'; import type { TutorialSchema } from './tutorial_schema'; export { TutorialsCategory } from '../../../../common/constants'; @@ -25,6 +25,7 @@ export type Platform = 'WINDOWS' | 'OSX' | 'DEB' | 'RPM'; export interface TutorialContext { kibanaBranch: string; + staticAssets: IStaticAssets; [key: string]: unknown; } export type TutorialProvider = (context: TutorialContext) => TutorialSchema; diff --git a/src/plugins/home/server/services/tutorials/tutorials_registry.test.ts b/src/plugins/home/server/services/tutorials/tutorials_registry.test.ts index 5a8c6dc55bda4..c8d9fa9d27aec 100644 --- a/src/plugins/home/server/services/tutorials/tutorials_registry.test.ts +++ b/src/plugins/home/server/services/tutorials/tutorials_registry.test.ts @@ -166,10 +166,9 @@ describe('TutorialsRegistry', () => { describe('start', () => { test('exposes proper contract', () => { - const start = new TutorialsRegistry(mockInitContext).start( - coreMock.createStart(), - mockCustomIntegrationsPluginSetup - ); + const registry = new TutorialsRegistry(mockInitContext); + registry.setup(mockCoreSetup, mockCustomIntegrationsPluginSetup); + const start = registry.start(coreMock.createStart(), mockCustomIntegrationsPluginSetup); expect(start).toBeDefined(); }); }); diff --git a/src/plugins/home/server/services/tutorials/tutorials_registry.ts b/src/plugins/home/server/services/tutorials/tutorials_registry.ts index 0ef800f63228b..eb3c6e931ff60 100644 --- a/src/plugins/home/server/services/tutorials/tutorials_registry.ts +++ b/src/plugins/home/server/services/tutorials/tutorials_registry.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { CoreSetup, CoreStart, PluginInitializerContext } from '@kbn/core/server'; +import { CoreSetup, CoreStart, PluginInitializerContext, IStaticAssets } from '@kbn/core/server'; import { CustomIntegrationsPluginSetup } from '@kbn/custom-integrations-plugin/server'; import { IntegrationCategory } from '@kbn/custom-integrations-plugin/common'; import { @@ -71,10 +71,13 @@ function registerBeatsTutorialsWithCustomIntegrations( export class TutorialsRegistry { private tutorialProviders: TutorialProvider[] = []; // pre-register all the tutorials we know we want in here private readonly scopedTutorialContextFactories: TutorialContextFactory[] = []; + private staticAssets!: IStaticAssets; constructor(private readonly initContext: PluginInitializerContext) {} public setup(core: CoreSetup, customIntegrations?: CustomIntegrationsPluginSetup) { + this.staticAssets = core.http.staticAssets; + const router = core.http.createRouter(); router.get( { path: '/api/kibana/home/tutorials', validate: false }, @@ -143,7 +146,10 @@ export class TutorialsRegistry { } private get baseTutorialContext(): TutorialContext { - return { kibanaBranch: this.initContext.env.packageInfo.branch }; + return { + kibanaBranch: this.initContext.env.packageInfo.branch, + staticAssets: this.staticAssets, + }; } } diff --git a/src/plugins/home/server/tutorials/activemq_logs/index.ts b/src/plugins/home/server/tutorials/activemq_logs/index.ts index af1a79e445fd8..b152d760bd60f 100644 --- a/src/plugins/home/server/tutorials/activemq_logs/index.ts +++ b/src/plugins/home/server/tutorials/activemq_logs/index.ts @@ -38,7 +38,7 @@ export function activemqLogsSpecProvider(context: TutorialContext): TutorialSche learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-activemq.html', }, }), - euiIconType: '/plugins/home/assets/logos/activemq.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/activemq.svg'), artifacts: { dashboards: [ { @@ -54,7 +54,7 @@ export function activemqLogsSpecProvider(context: TutorialContext): TutorialSche }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/activemq_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/activemq_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/activemq_metrics/index.ts b/src/plugins/home/server/tutorials/activemq_metrics/index.ts index c5c68ba0fe0ea..a255a85fa6960 100644 --- a/src/plugins/home/server/tutorials/activemq_metrics/index.ts +++ b/src/plugins/home/server/tutorials/activemq_metrics/index.ts @@ -38,7 +38,7 @@ export function activemqMetricsSpecProvider(context: TutorialContext): TutorialS learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-activemq.html', }, }), - euiIconType: '/plugins/home/assets/logos/activemq.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/activemq.svg'), isBeta: true, artifacts: { application: { diff --git a/src/plugins/home/server/tutorials/apache_logs/index.ts b/src/plugins/home/server/tutorials/apache_logs/index.ts index 2d729daefdc65..3bd77f587f09d 100644 --- a/src/plugins/home/server/tutorials/apache_logs/index.ts +++ b/src/plugins/home/server/tutorials/apache_logs/index.ts @@ -55,7 +55,7 @@ export function apacheLogsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/apache_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/apache_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/apache_metrics/index.ts b/src/plugins/home/server/tutorials/apache_metrics/index.ts index 114483f7414de..a021401890503 100644 --- a/src/plugins/home/server/tutorials/apache_metrics/index.ts +++ b/src/plugins/home/server/tutorials/apache_metrics/index.ts @@ -54,7 +54,7 @@ export function apacheMetricsSpecProvider(context: TutorialContext): TutorialSch }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/apache_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/apache_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/auditbeat/index.ts b/src/plugins/home/server/tutorials/auditbeat/index.ts index e315398578781..fe9928ff368bb 100644 --- a/src/plugins/home/server/tutorials/auditbeat/index.ts +++ b/src/plugins/home/server/tutorials/auditbeat/index.ts @@ -54,7 +54,7 @@ processes, users, logins, sockets information, file accesses, and more. \ }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/auditbeat/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/auditbeat/screenshot.webp'), onPrem: onPremInstructions(platforms, context), elasticCloud: cloudInstructions(platforms, context), onPremElasticCloud: onPremCloudInstructions(platforms, context), diff --git a/src/plugins/home/server/tutorials/auditd_logs/index.ts b/src/plugins/home/server/tutorials/auditd_logs/index.ts index 383eb46d83a7a..438e847efe337 100644 --- a/src/plugins/home/server/tutorials/auditd_logs/index.ts +++ b/src/plugins/home/server/tutorials/auditd_logs/index.ts @@ -39,7 +39,7 @@ export function auditdLogsSpecProvider(context: TutorialContext): TutorialSchema learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-auditd.html', }, }), - euiIconType: '/plugins/home/assets/logos/linux.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/linux.svg'), artifacts: { dashboards: [ { @@ -55,7 +55,7 @@ export function auditdLogsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/auditd_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/auditd_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/aws_logs/index.ts b/src/plugins/home/server/tutorials/aws_logs/index.ts index dd20d8d282f10..e8c178c040ad3 100644 --- a/src/plugins/home/server/tutorials/aws_logs/index.ts +++ b/src/plugins/home/server/tutorials/aws_logs/index.ts @@ -55,7 +55,7 @@ export function awsLogsSpecProvider(context: TutorialContext): TutorialSchema { }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/aws_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/aws_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/aws_metrics/index.ts b/src/plugins/home/server/tutorials/aws_metrics/index.ts index cdc4a3970b426..d5bf865b79026 100644 --- a/src/plugins/home/server/tutorials/aws_metrics/index.ts +++ b/src/plugins/home/server/tutorials/aws_metrics/index.ts @@ -56,7 +56,7 @@ export function awsMetricsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/aws_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/aws_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/azure_logs/index.ts b/src/plugins/home/server/tutorials/azure_logs/index.ts index 8efa2cea888ec..62f75a3eb0537 100644 --- a/src/plugins/home/server/tutorials/azure_logs/index.ts +++ b/src/plugins/home/server/tutorials/azure_logs/index.ts @@ -56,7 +56,7 @@ export function azureLogsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/azure_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/azure_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/azure_metrics/index.ts b/src/plugins/home/server/tutorials/azure_metrics/index.ts index 32f9840b9ed65..59492f6704ac8 100644 --- a/src/plugins/home/server/tutorials/azure_metrics/index.ts +++ b/src/plugins/home/server/tutorials/azure_metrics/index.ts @@ -55,7 +55,7 @@ export function azureMetricsSpecProvider(context: TutorialContext): TutorialSche }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/azure_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/azure_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/barracuda_logs/index.ts b/src/plugins/home/server/tutorials/barracuda_logs/index.ts index 70daca5656a66..d91b77495dca2 100644 --- a/src/plugins/home/server/tutorials/barracuda_logs/index.ts +++ b/src/plugins/home/server/tutorials/barracuda_logs/index.ts @@ -40,7 +40,7 @@ export function barracudaLogsSpecProvider(context: TutorialContext): TutorialSch learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-barracuda.html', }, }), - euiIconType: '/plugins/home/assets/logos/barracuda.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/barracuda.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/checkpoint_logs/index.ts b/src/plugins/home/server/tutorials/checkpoint_logs/index.ts index 3fa333c218396..bd7457f0157f5 100644 --- a/src/plugins/home/server/tutorials/checkpoint_logs/index.ts +++ b/src/plugins/home/server/tutorials/checkpoint_logs/index.ts @@ -39,7 +39,7 @@ export function checkpointLogsSpecProvider(context: TutorialContext): TutorialSc learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-checkpoint.html', }, }), - euiIconType: '/plugins/home/assets/logos/checkpoint.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/checkpoint.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/cisco_logs/index.ts b/src/plugins/home/server/tutorials/cisco_logs/index.ts index 098819c14297f..c125c283702d9 100644 --- a/src/plugins/home/server/tutorials/cisco_logs/index.ts +++ b/src/plugins/home/server/tutorials/cisco_logs/index.ts @@ -39,7 +39,7 @@ export function ciscoLogsSpecProvider(context: TutorialContext): TutorialSchema learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-cisco.html', }, }), - euiIconType: '/plugins/home/assets/logos/cisco.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/cisco.svg'), artifacts: { dashboards: [ { @@ -55,7 +55,7 @@ export function ciscoLogsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/cisco_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/cisco_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/cockroachdb_metrics/index.ts b/src/plugins/home/server/tutorials/cockroachdb_metrics/index.ts index 1d5cbd95d67f5..14c1d2c1b9c19 100644 --- a/src/plugins/home/server/tutorials/cockroachdb_metrics/index.ts +++ b/src/plugins/home/server/tutorials/cockroachdb_metrics/index.ts @@ -38,7 +38,7 @@ export function cockroachdbMetricsSpecProvider(context: TutorialContext): Tutori learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-cockroachdb.html', }, }), - euiIconType: '/plugins/home/assets/logos/cockroachdb.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/cockroachdb.svg'), artifacts: { dashboards: [ { @@ -57,7 +57,9 @@ export function cockroachdbMetricsSpecProvider(context: TutorialContext): Tutori }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/cockroachdb_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref( + '/cockroachdb_metrics/screenshot.webp' + ), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/consul_metrics/index.ts b/src/plugins/home/server/tutorials/consul_metrics/index.ts index bc1d1b6f1d1ea..64b7cb80e8813 100644 --- a/src/plugins/home/server/tutorials/consul_metrics/index.ts +++ b/src/plugins/home/server/tutorials/consul_metrics/index.ts @@ -38,7 +38,7 @@ export function consulMetricsSpecProvider(context: TutorialContext): TutorialSch learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-consul.html', }, }), - euiIconType: '/plugins/home/assets/logos/consul.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/consul.svg'), artifacts: { dashboards: [ { @@ -54,7 +54,7 @@ export function consulMetricsSpecProvider(context: TutorialContext): TutorialSch }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/consul_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/consul_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/coredns_logs/index.ts b/src/plugins/home/server/tutorials/coredns_logs/index.ts index fedea213c0087..a740144e07400 100644 --- a/src/plugins/home/server/tutorials/coredns_logs/index.ts +++ b/src/plugins/home/server/tutorials/coredns_logs/index.ts @@ -39,7 +39,7 @@ export function corednsLogsSpecProvider(context: TutorialContext): TutorialSchem learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-coredns.html', }, }), - euiIconType: '/plugins/home/assets/logos/coredns.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/coredns.svg'), artifacts: { dashboards: [ { @@ -55,7 +55,7 @@ export function corednsLogsSpecProvider(context: TutorialContext): TutorialSchem }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/coredns_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/coredns_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/coredns_metrics/index.ts b/src/plugins/home/server/tutorials/coredns_metrics/index.ts index b3e5de7fb58a8..82f1205971aac 100644 --- a/src/plugins/home/server/tutorials/coredns_metrics/index.ts +++ b/src/plugins/home/server/tutorials/coredns_metrics/index.ts @@ -38,7 +38,7 @@ export function corednsMetricsSpecProvider(context: TutorialContext): TutorialSc learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-coredns.html', }, }), - euiIconType: '/plugins/home/assets/logos/coredns.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/coredns.svg'), artifacts: { application: { label: i18n.translate('home.tutorials.corednsMetrics.artifacts.application.label', { @@ -52,7 +52,7 @@ export function corednsMetricsSpecProvider(context: TutorialContext): TutorialSc }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/coredns_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/coredns_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/couchdb_metrics/index.ts b/src/plugins/home/server/tutorials/couchdb_metrics/index.ts index 59f8431fe6a08..c63d9a045f590 100644 --- a/src/plugins/home/server/tutorials/couchdb_metrics/index.ts +++ b/src/plugins/home/server/tutorials/couchdb_metrics/index.ts @@ -38,7 +38,7 @@ export function couchdbMetricsSpecProvider(context: TutorialContext): TutorialSc learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-couchdb.html', }, }), - euiIconType: '/plugins/home/assets/logos/couchdb.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/couchdb.svg'), artifacts: { dashboards: [ { @@ -57,7 +57,7 @@ export function couchdbMetricsSpecProvider(context: TutorialContext): TutorialSc }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/couchdb_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/couchdb_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/crowdstrike_logs/index.ts b/src/plugins/home/server/tutorials/crowdstrike_logs/index.ts index f55d84e7b58c9..566624d8252b1 100644 --- a/src/plugins/home/server/tutorials/crowdstrike_logs/index.ts +++ b/src/plugins/home/server/tutorials/crowdstrike_logs/index.ts @@ -43,7 +43,7 @@ export function crowdstrikeLogsSpecProvider(context: TutorialContext): TutorialS learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-crowdstrike.html', }, }), - euiIconType: '/plugins/home/assets/logos/crowdstrike.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/crowdstrike.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/cylance_logs/index.ts b/src/plugins/home/server/tutorials/cylance_logs/index.ts index 805391dc4d364..e1781fa69df5d 100644 --- a/src/plugins/home/server/tutorials/cylance_logs/index.ts +++ b/src/plugins/home/server/tutorials/cylance_logs/index.ts @@ -39,7 +39,7 @@ export function cylanceLogsSpecProvider(context: TutorialContext): TutorialSchem learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-cylance.html', }, }), - euiIconType: '/plugins/home/assets/logos/cylance.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/cylance.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/docker_metrics/index.ts b/src/plugins/home/server/tutorials/docker_metrics/index.ts index 180723079acba..6f683c7eb9b77 100644 --- a/src/plugins/home/server/tutorials/docker_metrics/index.ts +++ b/src/plugins/home/server/tutorials/docker_metrics/index.ts @@ -54,7 +54,7 @@ export function dockerMetricsSpecProvider(context: TutorialContext): TutorialSch }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/docker_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/docker_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/elasticsearch_logs/index.ts b/src/plugins/home/server/tutorials/elasticsearch_logs/index.ts index bdcc65ead4182..1763a434d4906 100644 --- a/src/plugins/home/server/tutorials/elasticsearch_logs/index.ts +++ b/src/plugins/home/server/tutorials/elasticsearch_logs/index.ts @@ -54,7 +54,9 @@ export function elasticsearchLogsSpecProvider(context: TutorialContext): Tutoria }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/elasticsearch_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref( + '/elasticsearch_logs/screenshot.webp' + ), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/envoyproxy_logs/index.ts b/src/plugins/home/server/tutorials/envoyproxy_logs/index.ts index 06f0587e1021d..aa071297ed978 100644 --- a/src/plugins/home/server/tutorials/envoyproxy_logs/index.ts +++ b/src/plugins/home/server/tutorials/envoyproxy_logs/index.ts @@ -39,7 +39,7 @@ export function envoyproxyLogsSpecProvider(context: TutorialContext): TutorialSc learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-envoyproxy.html', }, }), - euiIconType: '/plugins/home/assets/logos/envoyproxy.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/envoyproxy.svg'), artifacts: { dashboards: [ { @@ -58,7 +58,7 @@ export function envoyproxyLogsSpecProvider(context: TutorialContext): TutorialSc }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/envoyproxy_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/envoyproxy_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/envoyproxy_metrics/index.ts b/src/plugins/home/server/tutorials/envoyproxy_metrics/index.ts index 03bc5d13baf9c..8c4396ff90ba0 100644 --- a/src/plugins/home/server/tutorials/envoyproxy_metrics/index.ts +++ b/src/plugins/home/server/tutorials/envoyproxy_metrics/index.ts @@ -38,7 +38,7 @@ export function envoyproxyMetricsSpecProvider(context: TutorialContext): Tutoria learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-envoyproxy.html', }, }), - euiIconType: '/plugins/home/assets/logos/envoyproxy.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/envoyproxy.svg'), artifacts: { dashboards: [], exportedFields: { diff --git a/src/plugins/home/server/tutorials/f5_logs/index.ts b/src/plugins/home/server/tutorials/f5_logs/index.ts index ae596b52a538b..e79018c6b58e4 100644 --- a/src/plugins/home/server/tutorials/f5_logs/index.ts +++ b/src/plugins/home/server/tutorials/f5_logs/index.ts @@ -39,7 +39,7 @@ export function f5LogsSpecProvider(context: TutorialContext): TutorialSchema { learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-f5.html', }, }), - euiIconType: '/plugins/home/assets/logos/f5.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/f5.svg'), artifacts: { dashboards: [], application: { @@ -53,7 +53,7 @@ export function f5LogsSpecProvider(context: TutorialContext): TutorialSchema { }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/f5_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/f5_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/fortinet_logs/index.ts b/src/plugins/home/server/tutorials/fortinet_logs/index.ts index 32338480fb009..4128f7460b90d 100644 --- a/src/plugins/home/server/tutorials/fortinet_logs/index.ts +++ b/src/plugins/home/server/tutorials/fortinet_logs/index.ts @@ -39,7 +39,7 @@ export function fortinetLogsSpecProvider(context: TutorialContext): TutorialSche learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-fortinet.html', }, }), - euiIconType: '/plugins/home/assets/logos/fortinet.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/fortinet.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/gcp_logs/index.ts b/src/plugins/home/server/tutorials/gcp_logs/index.ts index 6c33ac1fbaa0b..bc0fa1de8184e 100644 --- a/src/plugins/home/server/tutorials/gcp_logs/index.ts +++ b/src/plugins/home/server/tutorials/gcp_logs/index.ts @@ -57,7 +57,7 @@ export function gcpLogsSpecProvider(context: TutorialContext): TutorialSchema { }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/gcp_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/gcp_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/gcp_metrics/index.ts b/src/plugins/home/server/tutorials/gcp_metrics/index.ts index 649fd54dbde52..4b9fc9c23e790 100644 --- a/src/plugins/home/server/tutorials/gcp_metrics/index.ts +++ b/src/plugins/home/server/tutorials/gcp_metrics/index.ts @@ -55,7 +55,7 @@ export function gcpMetricsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/gcp_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/gcp_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/haproxy_logs/index.ts b/src/plugins/home/server/tutorials/haproxy_logs/index.ts index 6d83b9c544994..4cfa85570d8f5 100644 --- a/src/plugins/home/server/tutorials/haproxy_logs/index.ts +++ b/src/plugins/home/server/tutorials/haproxy_logs/index.ts @@ -55,7 +55,7 @@ export function haproxyLogsSpecProvider(context: TutorialContext): TutorialSchem }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/haproxy_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/haproxy_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/ibmmq_logs/index.ts b/src/plugins/home/server/tutorials/ibmmq_logs/index.ts index fd3327a555b41..0ca37ece3584c 100644 --- a/src/plugins/home/server/tutorials/ibmmq_logs/index.ts +++ b/src/plugins/home/server/tutorials/ibmmq_logs/index.ts @@ -38,7 +38,7 @@ export function ibmmqLogsSpecProvider(context: TutorialContext): TutorialSchema learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-ibmmq.html', }, }), - euiIconType: '/plugins/home/assets/logos/ibmmq.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/ibmmq.svg'), artifacts: { dashboards: [ { @@ -54,7 +54,7 @@ export function ibmmqLogsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/ibmmq_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/ibmmq_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/ibmmq_metrics/index.ts b/src/plugins/home/server/tutorials/ibmmq_metrics/index.ts index 6b81919ce2814..b6411f1b0bff1 100644 --- a/src/plugins/home/server/tutorials/ibmmq_metrics/index.ts +++ b/src/plugins/home/server/tutorials/ibmmq_metrics/index.ts @@ -38,7 +38,7 @@ export function ibmmqMetricsSpecProvider(context: TutorialContext): TutorialSche learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-ibmmq.html', }, }), - euiIconType: '/plugins/home/assets/logos/ibmmq.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/ibmmq.svg'), isBeta: true, artifacts: { application: { @@ -53,7 +53,7 @@ export function ibmmqMetricsSpecProvider(context: TutorialContext): TutorialSche }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/ibmmq_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/ibmmq_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/icinga_logs/index.ts b/src/plugins/home/server/tutorials/icinga_logs/index.ts index b8d51b1a1809f..c1cf308543429 100644 --- a/src/plugins/home/server/tutorials/icinga_logs/index.ts +++ b/src/plugins/home/server/tutorials/icinga_logs/index.ts @@ -39,7 +39,7 @@ export function icingaLogsSpecProvider(context: TutorialContext): TutorialSchema learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-icinga.html', }, }), - euiIconType: '/plugins/home/assets/logos/icinga.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/icinga.svg'), artifacts: { dashboards: [ { @@ -55,7 +55,7 @@ export function icingaLogsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/icinga_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/icinga_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/iis_logs/index.ts b/src/plugins/home/server/tutorials/iis_logs/index.ts index 1b7af958d4f9e..1ce2657b50923 100644 --- a/src/plugins/home/server/tutorials/iis_logs/index.ts +++ b/src/plugins/home/server/tutorials/iis_logs/index.ts @@ -40,7 +40,7 @@ export function iisLogsSpecProvider(context: TutorialContext): TutorialSchema { learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-iis.html', }, }), - euiIconType: '/plugins/home/assets/logos/iis.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/iis.svg'), artifacts: { dashboards: [ { @@ -56,7 +56,7 @@ export function iisLogsSpecProvider(context: TutorialContext): TutorialSchema { }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/iis_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/iis_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/iis_metrics/index.ts b/src/plugins/home/server/tutorials/iis_metrics/index.ts index 68f167c7be04d..052b90c0719bb 100644 --- a/src/plugins/home/server/tutorials/iis_metrics/index.ts +++ b/src/plugins/home/server/tutorials/iis_metrics/index.ts @@ -39,7 +39,7 @@ export function iisMetricsSpecProvider(context: TutorialContext): TutorialSchema }, }), isBeta: true, - euiIconType: '/plugins/home/assets/logos/iis.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/iis.svg'), artifacts: { dashboards: [ { @@ -55,7 +55,7 @@ export function iisMetricsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/iis_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/iis_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/infoblox_logs/index.ts b/src/plugins/home/server/tutorials/infoblox_logs/index.ts index ad82d25993dca..f86ccbf0084b6 100644 --- a/src/plugins/home/server/tutorials/infoblox_logs/index.ts +++ b/src/plugins/home/server/tutorials/infoblox_logs/index.ts @@ -39,7 +39,7 @@ export function infobloxLogsSpecProvider(context: TutorialContext): TutorialSche learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-infoblox.html', }, }), - euiIconType: '/plugins/home/assets/logos/infoblox.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/infoblox.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/iptables_logs/index.ts b/src/plugins/home/server/tutorials/iptables_logs/index.ts index 082b0a239714a..856a8b0331482 100644 --- a/src/plugins/home/server/tutorials/iptables_logs/index.ts +++ b/src/plugins/home/server/tutorials/iptables_logs/index.ts @@ -42,7 +42,7 @@ export function iptablesLogsSpecProvider(context: TutorialContext): TutorialSche learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-iptables.html', }, }), - euiIconType: '/plugins/home/assets/logos/linux.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/linux.svg'), artifacts: { dashboards: [ { @@ -58,7 +58,7 @@ export function iptablesLogsSpecProvider(context: TutorialContext): TutorialSche }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/iptables_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/iptables_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/juniper_logs/index.ts b/src/plugins/home/server/tutorials/juniper_logs/index.ts index a6d34d1e8447f..04d2e708aeab3 100644 --- a/src/plugins/home/server/tutorials/juniper_logs/index.ts +++ b/src/plugins/home/server/tutorials/juniper_logs/index.ts @@ -39,7 +39,7 @@ export function juniperLogsSpecProvider(context: TutorialContext): TutorialSchem learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-juniper.html', }, }), - euiIconType: '/plugins/home/assets/logos/juniper.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/juniper.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/kafka_logs/index.ts b/src/plugins/home/server/tutorials/kafka_logs/index.ts index cb78ffbaeaea7..a4918995965c6 100644 --- a/src/plugins/home/server/tutorials/kafka_logs/index.ts +++ b/src/plugins/home/server/tutorials/kafka_logs/index.ts @@ -55,7 +55,7 @@ export function kafkaLogsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/kafka_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/kafka_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/kubernetes_metrics/index.ts b/src/plugins/home/server/tutorials/kubernetes_metrics/index.ts index bb40e88e7541d..6db2731349e23 100644 --- a/src/plugins/home/server/tutorials/kubernetes_metrics/index.ts +++ b/src/plugins/home/server/tutorials/kubernetes_metrics/index.ts @@ -57,7 +57,9 @@ export function kubernetesMetricsSpecProvider(context: TutorialContext): Tutoria }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/kubernetes_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref( + '/kubernetes_metrics/screenshot.webp' + ), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/microsoft_logs/index.ts b/src/plugins/home/server/tutorials/microsoft_logs/index.ts index fc8926df08420..bc7eb73f60625 100644 --- a/src/plugins/home/server/tutorials/microsoft_logs/index.ts +++ b/src/plugins/home/server/tutorials/microsoft_logs/index.ts @@ -39,7 +39,7 @@ export function microsoftLogsSpecProvider(context: TutorialContext): TutorialSch learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-microsoft.html', }, }), - euiIconType: '/plugins/home/assets/logos/microsoft.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/microsoft.svg'), artifacts: { dashboards: [ { @@ -55,7 +55,7 @@ export function microsoftLogsSpecProvider(context: TutorialContext): TutorialSch }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/microsoft_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/microsoft_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/misp_logs/index.ts b/src/plugins/home/server/tutorials/misp_logs/index.ts index 7cb31f8db3a46..3fcd6f35faae9 100644 --- a/src/plugins/home/server/tutorials/misp_logs/index.ts +++ b/src/plugins/home/server/tutorials/misp_logs/index.ts @@ -39,7 +39,7 @@ export function mispLogsSpecProvider(context: TutorialContext): TutorialSchema { learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-misp.html', }, }), - euiIconType: '/plugins/home/assets/logos/misp.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/misp.svg'), artifacts: { dashboards: [ { @@ -55,7 +55,7 @@ export function mispLogsSpecProvider(context: TutorialContext): TutorialSchema { }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/misp_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/misp_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/mongodb_logs/index.ts b/src/plugins/home/server/tutorials/mongodb_logs/index.ts index 3f2618d15c844..4cd48e2af715c 100644 --- a/src/plugins/home/server/tutorials/mongodb_logs/index.ts +++ b/src/plugins/home/server/tutorials/mongodb_logs/index.ts @@ -55,7 +55,7 @@ export function mongodbLogsSpecProvider(context: TutorialContext): TutorialSchem }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/mongodb_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/mongodb_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/mongodb_metrics/index.ts b/src/plugins/home/server/tutorials/mongodb_metrics/index.ts index c4b56cef60d17..441ede88c5c38 100644 --- a/src/plugins/home/server/tutorials/mongodb_metrics/index.ts +++ b/src/plugins/home/server/tutorials/mongodb_metrics/index.ts @@ -57,7 +57,7 @@ export function mongodbMetricsSpecProvider(context: TutorialContext): TutorialSc }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/mongodb_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/mongodb_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/mssql_logs/index.ts b/src/plugins/home/server/tutorials/mssql_logs/index.ts index 2add9281860bd..ab8363afd25b6 100644 --- a/src/plugins/home/server/tutorials/mssql_logs/index.ts +++ b/src/plugins/home/server/tutorials/mssql_logs/index.ts @@ -39,7 +39,7 @@ export function mssqlLogsSpecProvider(context: TutorialContext): TutorialSchema learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-mssql.html', }, }), - euiIconType: '/plugins/home/assets/logos/microsoft.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/microsoft.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/mssql_metrics/index.ts b/src/plugins/home/server/tutorials/mssql_metrics/index.ts index 5dd6bca41a812..33091b6b04504 100644 --- a/src/plugins/home/server/tutorials/mssql_metrics/index.ts +++ b/src/plugins/home/server/tutorials/mssql_metrics/index.ts @@ -38,7 +38,7 @@ export function mssqlMetricsSpecProvider(context: TutorialContext): TutorialSche learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-mssql.html', }, }), - euiIconType: '/plugins/home/assets/logos/mssql.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/mssql.svg'), isBeta: false, artifacts: { dashboards: [ @@ -55,7 +55,7 @@ export function mssqlMetricsSpecProvider(context: TutorialContext): TutorialSche }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/mssql_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/mssql_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/munin_metrics/index.ts b/src/plugins/home/server/tutorials/munin_metrics/index.ts index 1e3e091ab0b8e..aa9ba8e72ddd3 100644 --- a/src/plugins/home/server/tutorials/munin_metrics/index.ts +++ b/src/plugins/home/server/tutorials/munin_metrics/index.ts @@ -26,7 +26,7 @@ export function muninMetricsSpecProvider(context: TutorialContext): TutorialSche defaultMessage: 'Munin Metrics', }), moduleName, - euiIconType: '/plugins/home/assets/logos/munin.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/munin.svg'), isBeta: true, category: TutorialsCategory.METRICS, shortDescription: i18n.translate('home.tutorials.muninMetrics.shortDescription', { diff --git a/src/plugins/home/server/tutorials/mysql_logs/index.ts b/src/plugins/home/server/tutorials/mysql_logs/index.ts index 5ca657283d514..776926d9bd74d 100644 --- a/src/plugins/home/server/tutorials/mysql_logs/index.ts +++ b/src/plugins/home/server/tutorials/mysql_logs/index.ts @@ -55,7 +55,7 @@ export function mysqlLogsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/mysql_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/mysql_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/mysql_metrics/index.ts b/src/plugins/home/server/tutorials/mysql_metrics/index.ts index 8710fb70a4e2f..61f6d936f88e8 100644 --- a/src/plugins/home/server/tutorials/mysql_metrics/index.ts +++ b/src/plugins/home/server/tutorials/mysql_metrics/index.ts @@ -54,7 +54,7 @@ export function mysqlMetricsSpecProvider(context: TutorialContext): TutorialSche }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/mysql_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/mysql_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/nats_logs/index.ts b/src/plugins/home/server/tutorials/nats_logs/index.ts index d72a6df5e7104..2695edaf99380 100644 --- a/src/plugins/home/server/tutorials/nats_logs/index.ts +++ b/src/plugins/home/server/tutorials/nats_logs/index.ts @@ -40,7 +40,7 @@ export function natsLogsSpecProvider(context: TutorialContext): TutorialSchema { learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-nats.html', }, }), - euiIconType: '/plugins/home/assets/logos/nats.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/nats.svg'), artifacts: { dashboards: [ { @@ -56,7 +56,7 @@ export function natsLogsSpecProvider(context: TutorialContext): TutorialSchema { }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/nats_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/nats_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/nats_metrics/index.ts b/src/plugins/home/server/tutorials/nats_metrics/index.ts index 1aab107a61210..e9226331b5ec3 100644 --- a/src/plugins/home/server/tutorials/nats_metrics/index.ts +++ b/src/plugins/home/server/tutorials/nats_metrics/index.ts @@ -38,7 +38,7 @@ export function natsMetricsSpecProvider(context: TutorialContext): TutorialSchem learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-nats.html', }, }), - euiIconType: '/plugins/home/assets/logos/nats.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/nats.svg'), artifacts: { dashboards: [ { @@ -54,7 +54,7 @@ export function natsMetricsSpecProvider(context: TutorialContext): TutorialSchem }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/nats_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/nats_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/netscout_logs/index.ts b/src/plugins/home/server/tutorials/netscout_logs/index.ts index 9418a787be5d3..64e7fb351fff8 100644 --- a/src/plugins/home/server/tutorials/netscout_logs/index.ts +++ b/src/plugins/home/server/tutorials/netscout_logs/index.ts @@ -39,7 +39,7 @@ export function netscoutLogsSpecProvider(context: TutorialContext): TutorialSche learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-netscout.html', }, }), - euiIconType: '/plugins/home/assets/logos/netscout.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/netscout.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/nginx_logs/index.ts b/src/plugins/home/server/tutorials/nginx_logs/index.ts index 451d1b8acbabb..5a08a6ebcddf4 100644 --- a/src/plugins/home/server/tutorials/nginx_logs/index.ts +++ b/src/plugins/home/server/tutorials/nginx_logs/index.ts @@ -55,7 +55,7 @@ export function nginxLogsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/nginx_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/nginx_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/nginx_metrics/index.ts b/src/plugins/home/server/tutorials/nginx_metrics/index.ts index 9441f59bbe56b..d133af96d03e0 100644 --- a/src/plugins/home/server/tutorials/nginx_metrics/index.ts +++ b/src/plugins/home/server/tutorials/nginx_metrics/index.ts @@ -59,7 +59,7 @@ which must be enabled in your Nginx installation. \ }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/nginx_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/nginx_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/o365_logs/index.ts b/src/plugins/home/server/tutorials/o365_logs/index.ts index c3cecbef32504..87dd8e7dcf246 100644 --- a/src/plugins/home/server/tutorials/o365_logs/index.ts +++ b/src/plugins/home/server/tutorials/o365_logs/index.ts @@ -42,7 +42,7 @@ export function o365LogsSpecProvider(context: TutorialContext): TutorialSchema { learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-o365.html', }, }), - euiIconType: '/plugins/home/assets/logos/o365.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/o365.svg'), artifacts: { dashboards: [ { @@ -58,7 +58,7 @@ export function o365LogsSpecProvider(context: TutorialContext): TutorialSchema { }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/o365_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/o365_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/okta_logs/index.ts b/src/plugins/home/server/tutorials/okta_logs/index.ts index c3929cff09099..4e4206ce95318 100644 --- a/src/plugins/home/server/tutorials/okta_logs/index.ts +++ b/src/plugins/home/server/tutorials/okta_logs/index.ts @@ -40,7 +40,7 @@ export function oktaLogsSpecProvider(context: TutorialContext): TutorialSchema { learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-okta.html', }, }), - euiIconType: '/plugins/home/assets/logos/okta.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/okta.svg'), artifacts: { dashboards: [ { @@ -56,7 +56,7 @@ export function oktaLogsSpecProvider(context: TutorialContext): TutorialSchema { }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/okta_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/okta_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/openmetrics_metrics/index.ts b/src/plugins/home/server/tutorials/openmetrics_metrics/index.ts index 9c0f6e89b6fa6..56db28fb0e9e2 100644 --- a/src/plugins/home/server/tutorials/openmetrics_metrics/index.ts +++ b/src/plugins/home/server/tutorials/openmetrics_metrics/index.ts @@ -39,7 +39,7 @@ export function openmetricsMetricsSpecProvider(context: TutorialContext): Tutori learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-openmetrics.html', }, }), - euiIconType: '/plugins/home/assets/logos/openmetrics.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/openmetrics.svg'), artifacts: { dashboards: [], exportedFields: { diff --git a/src/plugins/home/server/tutorials/oracle_metrics/index.ts b/src/plugins/home/server/tutorials/oracle_metrics/index.ts index 14f8dd0c39774..71cdedc6bb3ba 100644 --- a/src/plugins/home/server/tutorials/oracle_metrics/index.ts +++ b/src/plugins/home/server/tutorials/oracle_metrics/index.ts @@ -40,7 +40,7 @@ export function oracleMetricsSpecProvider(context: TutorialContext): TutorialSch learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-' + moduleName + '.html', }, }), - euiIconType: '/plugins/home/assets/logos/oracle.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/oracle.svg'), artifacts: { application: { label: i18n.translate('home.tutorials.oracleMetrics.artifacts.application.label', { diff --git a/src/plugins/home/server/tutorials/osquery_logs/index.ts b/src/plugins/home/server/tutorials/osquery_logs/index.ts index 8bf4ba94e9497..e73eb7e544df8 100644 --- a/src/plugins/home/server/tutorials/osquery_logs/index.ts +++ b/src/plugins/home/server/tutorials/osquery_logs/index.ts @@ -43,7 +43,7 @@ export function osqueryLogsSpecProvider(context: TutorialContext): TutorialSchem learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-osquery.html', }, }), - euiIconType: '/plugins/home/assets/logos/osquery.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/osquery.svg'), artifacts: { dashboards: [ { diff --git a/src/plugins/home/server/tutorials/panw_logs/index.ts b/src/plugins/home/server/tutorials/panw_logs/index.ts index 1279b0ebaf5a6..2aa4d6ebb6f2a 100644 --- a/src/plugins/home/server/tutorials/panw_logs/index.ts +++ b/src/plugins/home/server/tutorials/panw_logs/index.ts @@ -42,7 +42,7 @@ export function panwLogsSpecProvider(context: TutorialContext): TutorialSchema { learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-panw.html', }, }), - euiIconType: '/plugins/home/assets/logos/paloalto.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/paloalto.svg'), artifacts: { dashboards: [ { @@ -58,7 +58,7 @@ export function panwLogsSpecProvider(context: TutorialContext): TutorialSchema { }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/panw_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/panw_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/postgresql_logs/index.ts b/src/plugins/home/server/tutorials/postgresql_logs/index.ts index 0338d33d9851a..2f8d6acc10f93 100644 --- a/src/plugins/home/server/tutorials/postgresql_logs/index.ts +++ b/src/plugins/home/server/tutorials/postgresql_logs/index.ts @@ -58,7 +58,7 @@ export function postgresqlLogsSpecProvider(context: TutorialContext): TutorialSc }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/postgresql_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/postgresql_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/rabbitmq_logs/index.ts b/src/plugins/home/server/tutorials/rabbitmq_logs/index.ts index 49ca87b1fbaa0..5cfa4d9a7fedc 100644 --- a/src/plugins/home/server/tutorials/rabbitmq_logs/index.ts +++ b/src/plugins/home/server/tutorials/rabbitmq_logs/index.ts @@ -39,7 +39,7 @@ export function rabbitmqLogsSpecProvider(context: TutorialContext): TutorialSche learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-rabbitmq.html', }, }), - euiIconType: '/plugins/home/assets/logos/rabbitmq.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/rabbitmq.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/rabbitmq_metrics/index.ts b/src/plugins/home/server/tutorials/rabbitmq_metrics/index.ts index 49b4abb6bf836..c3c955e4658a4 100644 --- a/src/plugins/home/server/tutorials/rabbitmq_metrics/index.ts +++ b/src/plugins/home/server/tutorials/rabbitmq_metrics/index.ts @@ -58,7 +58,7 @@ export function rabbitmqMetricsSpecProvider(context: TutorialContext): TutorialS }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/rabbitmq_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/rabbitmq_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/radware_logs/index.ts b/src/plugins/home/server/tutorials/radware_logs/index.ts index 4abd897c0aff3..607fe2fa60149 100644 --- a/src/plugins/home/server/tutorials/radware_logs/index.ts +++ b/src/plugins/home/server/tutorials/radware_logs/index.ts @@ -39,7 +39,7 @@ export function radwareLogsSpecProvider(context: TutorialContext): TutorialSchem learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-radware.html', }, }), - euiIconType: '/plugins/home/assets/logos/radware.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/radware.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/redis_logs/index.ts b/src/plugins/home/server/tutorials/redis_logs/index.ts index f0110b1e4f360..5a278706f7530 100644 --- a/src/plugins/home/server/tutorials/redis_logs/index.ts +++ b/src/plugins/home/server/tutorials/redis_logs/index.ts @@ -61,7 +61,7 @@ Note that the `slowlog` fileset is experimental. \ }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/redis_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/redis_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/redis_metrics/index.ts b/src/plugins/home/server/tutorials/redis_metrics/index.ts index 1b541226ca24d..bef4dcf6b0778 100644 --- a/src/plugins/home/server/tutorials/redis_metrics/index.ts +++ b/src/plugins/home/server/tutorials/redis_metrics/index.ts @@ -54,7 +54,7 @@ export function redisMetricsSpecProvider(context: TutorialContext): TutorialSche }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/redis_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/redis_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/redisenterprise_metrics/index.ts b/src/plugins/home/server/tutorials/redisenterprise_metrics/index.ts index 608ce867727d3..fd1c26f4da16b 100644 --- a/src/plugins/home/server/tutorials/redisenterprise_metrics/index.ts +++ b/src/plugins/home/server/tutorials/redisenterprise_metrics/index.ts @@ -53,7 +53,9 @@ export function redisenterpriseMetricsSpecProvider(context: TutorialContext): Tu }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/redisenterprise_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref( + '/redisenterprise_metrics/screenshot.webp' + ), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/santa_logs/index.ts b/src/plugins/home/server/tutorials/santa_logs/index.ts index eda644458ba3e..292c1b20c41d6 100644 --- a/src/plugins/home/server/tutorials/santa_logs/index.ts +++ b/src/plugins/home/server/tutorials/santa_logs/index.ts @@ -56,7 +56,7 @@ export function santaLogsSpecProvider(context: TutorialContext): TutorialSchema }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/santa_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/santa_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/sonicwall_logs/index.ts b/src/plugins/home/server/tutorials/sonicwall_logs/index.ts index 5e88eb03d75d2..00995b6767abf 100644 --- a/src/plugins/home/server/tutorials/sonicwall_logs/index.ts +++ b/src/plugins/home/server/tutorials/sonicwall_logs/index.ts @@ -39,7 +39,7 @@ export function sonicwallLogsSpecProvider(context: TutorialContext): TutorialSch learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-sonicwall.html', }, }), - euiIconType: '/plugins/home/assets/logos/sonicwall.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/sonicwall.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/sophos_logs/index.ts b/src/plugins/home/server/tutorials/sophos_logs/index.ts index a504ae2a30802..5f43d0bccaf57 100644 --- a/src/plugins/home/server/tutorials/sophos_logs/index.ts +++ b/src/plugins/home/server/tutorials/sophos_logs/index.ts @@ -39,7 +39,7 @@ export function sophosLogsSpecProvider(context: TutorialContext): TutorialSchema learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-sophos.html', }, }), - euiIconType: '/plugins/home/assets/logos/sophos.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/sophos.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/stan_metrics/index.ts b/src/plugins/home/server/tutorials/stan_metrics/index.ts index ca0be2097af13..c83b405e2058a 100644 --- a/src/plugins/home/server/tutorials/stan_metrics/index.ts +++ b/src/plugins/home/server/tutorials/stan_metrics/index.ts @@ -38,7 +38,7 @@ export function stanMetricsSpecProvider(context: TutorialContext): TutorialSchem learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-stan.html', }, }), - euiIconType: '/plugins/home/assets/logos/stan.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/stan.svg'), artifacts: { dashboards: [ { @@ -54,7 +54,7 @@ export function stanMetricsSpecProvider(context: TutorialContext): TutorialSchem }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/stan_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/stan_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/statsd_metrics/index.ts b/src/plugins/home/server/tutorials/statsd_metrics/index.ts index a7c8a27aa7afd..695c890bb449d 100644 --- a/src/plugins/home/server/tutorials/statsd_metrics/index.ts +++ b/src/plugins/home/server/tutorials/statsd_metrics/index.ts @@ -35,7 +35,7 @@ export function statsdMetricsSpecProvider(context: TutorialContext): TutorialSch learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-statsd.html', }, }), - euiIconType: '/plugins/home/assets/logos/statsd.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/statsd.svg'), artifacts: { dashboards: [], exportedFields: { diff --git a/src/plugins/home/server/tutorials/suricata_logs/index.ts b/src/plugins/home/server/tutorials/suricata_logs/index.ts index dfff18cd8f196..aa8a24a843c6d 100644 --- a/src/plugins/home/server/tutorials/suricata_logs/index.ts +++ b/src/plugins/home/server/tutorials/suricata_logs/index.ts @@ -40,7 +40,7 @@ export function suricataLogsSpecProvider(context: TutorialContext): TutorialSche learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-suricata.html', }, }), - euiIconType: '/plugins/home/assets/logos/suricata.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/suricata.svg'), artifacts: { dashboards: [ { @@ -56,7 +56,7 @@ export function suricataLogsSpecProvider(context: TutorialContext): TutorialSche }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/suricata_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/suricata_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/system_metrics/index.ts b/src/plugins/home/server/tutorials/system_metrics/index.ts index b9d607c9fc59c..1db7e1e335337 100644 --- a/src/plugins/home/server/tutorials/system_metrics/index.ts +++ b/src/plugins/home/server/tutorials/system_metrics/index.ts @@ -40,7 +40,7 @@ It collects system wide statistics and statistics per process and filesystem. \ learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-system.html', }, }), - euiIconType: '/plugins/home/assets/logos/system.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/system.svg'), artifacts: { dashboards: [ { @@ -56,7 +56,7 @@ It collects system wide statistics and statistics per process and filesystem. \ }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/system_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/system_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/tomcat_logs/index.ts b/src/plugins/home/server/tutorials/tomcat_logs/index.ts index 99198f835402c..6694f54428c99 100644 --- a/src/plugins/home/server/tutorials/tomcat_logs/index.ts +++ b/src/plugins/home/server/tutorials/tomcat_logs/index.ts @@ -39,7 +39,7 @@ export function tomcatLogsSpecProvider(context: TutorialContext): TutorialSchema learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-tomcat.html', }, }), - euiIconType: '/plugins/home/assets/logos/tomcat.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/tomcat.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/home/server/tutorials/traefik_logs/index.ts b/src/plugins/home/server/tutorials/traefik_logs/index.ts index 7c096f68aabfb..13a1c448c876a 100644 --- a/src/plugins/home/server/tutorials/traefik_logs/index.ts +++ b/src/plugins/home/server/tutorials/traefik_logs/index.ts @@ -39,7 +39,7 @@ export function traefikLogsSpecProvider(context: TutorialContext): TutorialSchem learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-traefik.html', }, }), - euiIconType: '/plugins/home/assets/logos/traefik.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/traefik.svg'), artifacts: { dashboards: [ { diff --git a/src/plugins/home/server/tutorials/traefik_metrics/index.ts b/src/plugins/home/server/tutorials/traefik_metrics/index.ts index 1bba0718fbd99..daa83e051bd28 100644 --- a/src/plugins/home/server/tutorials/traefik_metrics/index.ts +++ b/src/plugins/home/server/tutorials/traefik_metrics/index.ts @@ -35,7 +35,7 @@ export function traefikMetricsSpecProvider(context: TutorialContext): TutorialSc learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-traefik.html', }, }), - euiIconType: '/plugins/home/assets/logos/traefik.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/traefik.svg'), artifacts: { dashboards: [], exportedFields: { diff --git a/src/plugins/home/server/tutorials/uptime_monitors/index.ts b/src/plugins/home/server/tutorials/uptime_monitors/index.ts index 86b3e99e11057..653cf939108b3 100644 --- a/src/plugins/home/server/tutorials/uptime_monitors/index.ts +++ b/src/plugins/home/server/tutorials/uptime_monitors/index.ts @@ -53,7 +53,7 @@ export function uptimeMonitorsSpecProvider(context: TutorialContext): TutorialSc }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/uptime_monitors/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/uptime_monitors/screenshot.webp'), onPrem: onPremInstructions([], context), elasticCloud: cloudInstructions(context), onPremElasticCloud: onPremCloudInstructions(context), diff --git a/src/plugins/home/server/tutorials/uwsgi_metrics/index.ts b/src/plugins/home/server/tutorials/uwsgi_metrics/index.ts index 4fb6725255e0a..fedc37523baae 100644 --- a/src/plugins/home/server/tutorials/uwsgi_metrics/index.ts +++ b/src/plugins/home/server/tutorials/uwsgi_metrics/index.ts @@ -38,7 +38,7 @@ export function uwsgiMetricsSpecProvider(context: TutorialContext): TutorialSche learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-uwsgi.html', }, }), - euiIconType: '/plugins/home/assets/logos/uwsgi.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/uwsgi.svg'), isBeta: false, artifacts: { dashboards: [ @@ -55,7 +55,7 @@ export function uwsgiMetricsSpecProvider(context: TutorialContext): TutorialSche }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/uwsgi_metrics/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/uwsgi_metrics/screenshot.webp'), onPrem: onPremInstructions(moduleName, context), elasticCloud: cloudInstructions(moduleName, context), onPremElasticCloud: onPremCloudInstructions(moduleName, context), diff --git a/src/plugins/home/server/tutorials/vsphere_metrics/index.ts b/src/plugins/home/server/tutorials/vsphere_metrics/index.ts index 946da1b884a80..66359772a14c5 100644 --- a/src/plugins/home/server/tutorials/vsphere_metrics/index.ts +++ b/src/plugins/home/server/tutorials/vsphere_metrics/index.ts @@ -38,7 +38,7 @@ export function vSphereMetricsSpecProvider(context: TutorialContext): TutorialSc learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-vsphere.html', }, }), - euiIconType: '/plugins/home/assets/logos/vsphere.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/vsphere.svg'), isBeta: true, artifacts: { application: { diff --git a/src/plugins/home/server/tutorials/zeek_logs/index.ts b/src/plugins/home/server/tutorials/zeek_logs/index.ts index 387f1041f4974..1460fb6acf9b4 100644 --- a/src/plugins/home/server/tutorials/zeek_logs/index.ts +++ b/src/plugins/home/server/tutorials/zeek_logs/index.ts @@ -40,7 +40,7 @@ export function zeekLogsSpecProvider(context: TutorialContext): TutorialSchema { learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-zeek.html', }, }), - euiIconType: '/plugins/home/assets/logos/zeek.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/zeek.svg'), artifacts: { dashboards: [ { @@ -56,7 +56,7 @@ export function zeekLogsSpecProvider(context: TutorialContext): TutorialSchema { }, }, completionTimeMinutes: 10, - previewImagePath: '/plugins/home/assets/zeek_logs/screenshot.webp', + previewImagePath: context.staticAssets.getPluginAssetHref('/zeek_logs/screenshot.webp'), onPrem: onPremInstructions(moduleName, platforms, context), elasticCloud: cloudInstructions(moduleName, platforms, context), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context), diff --git a/src/plugins/home/server/tutorials/zookeeper_metrics/index.ts b/src/plugins/home/server/tutorials/zookeeper_metrics/index.ts index dd65f61a78b3c..2479650a5198d 100644 --- a/src/plugins/home/server/tutorials/zookeeper_metrics/index.ts +++ b/src/plugins/home/server/tutorials/zookeeper_metrics/index.ts @@ -26,7 +26,7 @@ export function zookeeperMetricsSpecProvider(context: TutorialContext): Tutorial defaultMessage: 'Zookeeper Metrics', }), moduleName, - euiIconType: '/plugins/home/assets/logos/zookeeper.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/zookeeper.svg'), isBeta: false, category: TutorialsCategory.METRICS, shortDescription: i18n.translate('home.tutorials.zookeeperMetrics.shortDescription', { diff --git a/src/plugins/home/server/tutorials/zscaler_logs/index.ts b/src/plugins/home/server/tutorials/zscaler_logs/index.ts index 316590c74fd76..47be9df4cdf5c 100644 --- a/src/plugins/home/server/tutorials/zscaler_logs/index.ts +++ b/src/plugins/home/server/tutorials/zscaler_logs/index.ts @@ -39,7 +39,7 @@ export function zscalerLogsSpecProvider(context: TutorialContext): TutorialSchem learnMoreLink: '{config.docs.beats.filebeat}/filebeat-module-zscaler.html', }, }), - euiIconType: '/plugins/home/assets/logos/zscaler.svg', + euiIconType: context.staticAssets.getPluginAssetHref('/logos/zscaler.svg'), artifacts: { dashboards: [], application: { diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap b/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap index 1a2fdf031a9d3..92bae41b22e58 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap @@ -188,6 +188,7 @@ exports[`SavedObjectsTable should render normally 1`] = ` } basePath={ BasePath { + "assetsHrefBase": "", "basePath": "", "get": [Function], "prepend": [Function], diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/__snapshots__/flyout.test.tsx.snap b/src/plugins/saved_objects_management/public/management_section/objects_table/components/__snapshots__/flyout.test.tsx.snap index 7d4ed131f6eac..03ba5cf5d9ead 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/__snapshots__/flyout.test.tsx.snap +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/__snapshots__/flyout.test.tsx.snap @@ -174,6 +174,7 @@ exports[`Flyout conflicts should allow conflict resolution 2`] = ` "register": [MockFunction], }, "basePath": BasePath { + "assetsHrefBase": "", "basePath": "", "get": [Function], "prepend": [Function], @@ -195,6 +196,9 @@ exports[`Flyout conflicts should allow conflict resolution 2`] = ` "patch": [MockFunction], "post": [MockFunction], "put": [MockFunction], + "staticAssets": Object { + "getPluginAssetHref": [MockFunction], + }, }, "state": Object { "conflictingRecord": undefined, @@ -401,6 +405,7 @@ exports[`Flyout summary should display summary when import is complete 1`] = ` allowedTypes={Array []} basePath={ BasePath { + "assetsHrefBase": "", "basePath": "", "get": [Function], "prepend": [Function], diff --git a/src/plugins/telemetry_management_section/public/components/__snapshots__/telemetry_management_section.test.tsx.snap b/src/plugins/telemetry_management_section/public/components/__snapshots__/telemetry_management_section.test.tsx.snap index 515add8c29dd4..430cf538779b6 100644 --- a/src/plugins/telemetry_management_section/public/components/__snapshots__/telemetry_management_section.test.tsx.snap +++ b/src/plugins/telemetry_management_section/public/components/__snapshots__/telemetry_management_section.test.tsx.snap @@ -281,6 +281,7 @@ exports[`TelemetryManagementSectionComponent renders null because allowChangingO "register": [MockFunction], }, "basePath": BasePath { + "assetsHrefBase": "", "basePath": "", "get": [Function], "prepend": [Function], @@ -302,6 +303,9 @@ exports[`TelemetryManagementSectionComponent renders null because allowChangingO "patch": [MockFunction], "post": [MockFunction], "put": [MockFunction], + "staticAssets": Object { + "getPluginAssetHref": [MockFunction], + }, }, "isScreenshotMode": false, "notifications": Object { diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx index 2f0910627be9b..8e11a1929ca16 100644 --- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx @@ -89,7 +89,7 @@ describe('roleMappingsManagementApp', () => { expect(docTitle.reset).not.toHaveBeenCalled(); expect(container).toMatchInlineSnapshot(`
- Role Mappings Page: {"notifications":{"toasts":{}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/","search":"","hash":""}},"readOnly":false} + Role Mappings Page: {"notifications":{"toasts":{}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/","search":"","hash":""}},"readOnly":false}
`); @@ -111,7 +111,7 @@ describe('roleMappingsManagementApp', () => { expect(docTitle.reset).not.toHaveBeenCalled(); expect(container).toMatchInlineSnapshot(`
- Role Mappings Page: {"notifications":{"toasts":{}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/","search":"","hash":""}},"readOnly":true} + Role Mappings Page: {"notifications":{"toasts":{}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/","search":"","hash":""}},"readOnly":true}
`); @@ -136,7 +136,7 @@ describe('roleMappingsManagementApp', () => { expect(docTitle.reset).not.toHaveBeenCalled(); expect(container).toMatchInlineSnapshot(`
- Role Mapping Edit Page: {"action":"edit","roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"notifications":{"toasts":{}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit","search":"","hash":""}},"readOnly":false} + Role Mapping Edit Page: {"action":"edit","roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"notifications":{"toasts":{}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit","search":"","hash":""}},"readOnly":false}
`); @@ -166,7 +166,7 @@ describe('roleMappingsManagementApp', () => { expect(docTitle.reset).not.toHaveBeenCalled(); expect(container).toMatchInlineSnapshot(`
- Role Mapping Edit Page: {"action":"edit","name":"role@mapping","roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"notifications":{"toasts":{}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit/role@mapping","search":"","hash":""}},"readOnly":false} + Role Mapping Edit Page: {"action":"edit","name":"role@mapping","roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"notifications":{"toasts":{}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit/role@mapping","search":"","hash":""}},"readOnly":false}
`); @@ -197,7 +197,7 @@ describe('roleMappingsManagementApp', () => { expect(docTitle.reset).not.toHaveBeenCalled(); expect(container).toMatchInlineSnapshot(`
- Role Mapping Edit Page: {"action":"edit","name":"role@mapping","roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"notifications":{"toasts":{}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit/role@mapping","search":"","hash":""}},"readOnly":true} + Role Mapping Edit Page: {"action":"edit","name":"role@mapping","roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"notifications":{"toasts":{}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit/role@mapping","search":"","hash":""}},"readOnly":true}
`); diff --git a/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx b/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx index 5e9d5fcc56350..300f5e195b510 100644 --- a/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx +++ b/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx @@ -90,7 +90,7 @@ describe('rolesManagementApp', () => { expect(docTitle.reset).not.toHaveBeenCalled(); expect(container).toMatchInlineSnapshot(`
- Roles Page: {"notifications":{"toasts":{}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/","search":"","hash":""}},"readOnly":false} + Roles Page: {"notifications":{"toasts":{}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/","search":"","hash":""}},"readOnly":false}
`); @@ -112,7 +112,7 @@ describe('rolesManagementApp', () => { expect(docTitle.reset).not.toHaveBeenCalled(); expect(container).toMatchInlineSnapshot(`
- Role Edit Page: {"action":"edit","rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"userAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"indicesAPIClient":{"fieldCache":{},"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"privilegesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}},"notifications":{"toasts":{}},"fatalErrors":{},"license":{"features$":{}},"docLinks":{},"uiCapabilities":{"catalogue":{},"management":{},"navLinks":{},"roles":{"save":true}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit","search":"","hash":""}}} + Role Edit Page: {"action":"edit","rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"userAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"indicesAPIClient":{"fieldCache":{},"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"privilegesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}},"notifications":{"toasts":{}},"fatalErrors":{},"license":{"features$":{}},"docLinks":{},"uiCapabilities":{"catalogue":{},"management":{},"navLinks":{},"roles":{"save":true}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit","search":"","hash":""}}}
`); @@ -139,7 +139,7 @@ describe('rolesManagementApp', () => { expect(docTitle.reset).not.toHaveBeenCalled(); expect(container).toMatchInlineSnapshot(`
- Role Edit Page: {"action":"edit","roleName":"role@name","rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"userAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"indicesAPIClient":{"fieldCache":{},"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"privilegesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}},"notifications":{"toasts":{}},"fatalErrors":{},"license":{"features$":{}},"docLinks":{},"uiCapabilities":{"catalogue":{},"management":{},"navLinks":{},"roles":{"save":true}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit/role@name","search":"","hash":""}}} + Role Edit Page: {"action":"edit","roleName":"role@name","rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"userAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"indicesAPIClient":{"fieldCache":{},"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"privilegesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}},"notifications":{"toasts":{}},"fatalErrors":{},"license":{"features$":{}},"docLinks":{},"uiCapabilities":{"catalogue":{},"management":{},"navLinks":{},"roles":{"save":true}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit/role@name","search":"","hash":""}}}
`); @@ -166,7 +166,7 @@ describe('rolesManagementApp', () => { expect(docTitle.reset).not.toHaveBeenCalled(); expect(container).toMatchInlineSnapshot(`
- Role Edit Page: {"action":"clone","roleName":"someRoleName","rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"userAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"indicesAPIClient":{"fieldCache":{},"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"privilegesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}},"notifications":{"toasts":{}},"fatalErrors":{},"license":{"features$":{}},"docLinks":{},"uiCapabilities":{"catalogue":{},"management":{},"navLinks":{},"roles":{"save":true}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/clone/someRoleName","search":"","hash":""}}} + Role Edit Page: {"action":"clone","roleName":"someRoleName","rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"userAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"indicesAPIClient":{"fieldCache":{},"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"privilegesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}}},"http":{"basePath":{"basePath":"","serverBasePath":"","assetsHrefBase":""},"anonymousPaths":{},"externalUrl":{},"staticAssets":{}},"notifications":{"toasts":{}},"fatalErrors":{},"license":{"features$":{}},"docLinks":{},"uiCapabilities":{"catalogue":{},"management":{},"navLinks":{},"roles":{"save":true}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/clone/someRoleName","search":"","hash":""}}}
`); diff --git a/x-pack/plugins/security/public/session/unauthorized_response_http_interceptor.test.ts b/x-pack/plugins/security/public/session/unauthorized_response_http_interceptor.test.ts index 7f3f0d57d449c..202d1b2d578c6 100644 --- a/x-pack/plugins/security/public/session/unauthorized_response_http_interceptor.test.ts +++ b/x-pack/plugins/security/public/session/unauthorized_response_http_interceptor.test.ts @@ -8,6 +8,7 @@ // @ts-ignore import fetchMock from 'fetch-mock/es5/client'; +import type { HttpSetup } from '@kbn/core/public'; import { applicationServiceMock } from '@kbn/core/public/mocks'; import { setup } from '@kbn/core-test-helpers-http-setup-browser'; @@ -30,7 +31,7 @@ const setupHttp = (basePath: string) => { const { http } = setup((injectedMetadata) => { injectedMetadata.getBasePath.mockReturnValue(basePath); }); - return http; + return http as HttpSetup; }; const tenant = ''; const application = applicationServiceMock.createStartContract();