Migrate Core's Overlays service to packages (#137365)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Christiane (Tina) Heiligers 2022-07-29 10:52:49 -07:00 committed by GitHub
parent 405c9041e7
commit 103aa675c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
102 changed files with 1196 additions and 244 deletions

View file

@ -218,9 +218,14 @@
"@kbn/core-metrics-server": "link:bazel-bin/packages/core/metrics/core-metrics-server",
"@kbn/core-metrics-server-internal": "link:bazel-bin/packages/core/metrics/core-metrics-server-internal",
"@kbn/core-metrics-server-mocks": "link:bazel-bin/packages/core/metrics/core-metrics-server-mocks",
"@kbn/core-mount-utils-browser": "link:bazel-bin/packages/core/mount-utils/core-mount-utils-browser",
"@kbn/core-mount-utils-browser-internal": "link:bazel-bin/packages/core/mount-utils/core-mount-utils-browser-internal",
"@kbn/core-node-server": "link:bazel-bin/packages/core/node/core-node-server",
"@kbn/core-node-server-internal": "link:bazel-bin/packages/core/node/core-node-server-internal",
"@kbn/core-node-server-mocks": "link:bazel-bin/packages/core/node/core-node-server-mocks",
"@kbn/core-overlays-browser": "link:bazel-bin/packages/core/overlays/core-overlays-browser",
"@kbn/core-overlays-browser-internal": "link:bazel-bin/packages/core/overlays/core-overlays-browser-internal",
"@kbn/core-overlays-browser-mocks": "link:bazel-bin/packages/core/overlays/core-overlays-browser-mocks",
"@kbn/core-preboot-server": "link:bazel-bin/packages/core/preboot/core-preboot-server",
"@kbn/core-preboot-server-internal": "link:bazel-bin/packages/core/preboot/core-preboot-server-internal",
"@kbn/core-preboot-server-mocks": "link:bazel-bin/packages/core/preboot/core-preboot-server-mocks",
@ -840,9 +845,14 @@
"@types/kbn__core-metrics-server": "link:bazel-bin/packages/core/metrics/core-metrics-server/npm_module_types",
"@types/kbn__core-metrics-server-internal": "link:bazel-bin/packages/core/metrics/core-metrics-server-internal/npm_module_types",
"@types/kbn__core-metrics-server-mocks": "link:bazel-bin/packages/core/metrics/core-metrics-server-mocks/npm_module_types",
"@types/kbn__core-mount-utils-browser": "link:bazel-bin/packages/core/mount-utils/core-mount-utils-browser/npm_module_types",
"@types/kbn__core-mount-utils-browser-internal": "link:bazel-bin/packages/core/mount-utils/core-mount-utils-browser-internal/npm_module_types",
"@types/kbn__core-node-server": "link:bazel-bin/packages/core/node/core-node-server/npm_module_types",
"@types/kbn__core-node-server-internal": "link:bazel-bin/packages/core/node/core-node-server-internal/npm_module_types",
"@types/kbn__core-node-server-mocks": "link:bazel-bin/packages/core/node/core-node-server-mocks/npm_module_types",
"@types/kbn__core-overlays-browser": "link:bazel-bin/packages/core/overlays/core-overlays-browser/npm_module_types",
"@types/kbn__core-overlays-browser-internal": "link:bazel-bin/packages/core/overlays/core-overlays-browser-internal/npm_module_types",
"@types/kbn__core-overlays-browser-mocks": "link:bazel-bin/packages/core/overlays/core-overlays-browser-mocks/npm_module_types",
"@types/kbn__core-preboot-server": "link:bazel-bin/packages/core/preboot/core-preboot-server/npm_module_types",
"@types/kbn__core-preboot-server-internal": "link:bazel-bin/packages/core/preboot/core-preboot-server-internal/npm_module_types",
"@types/kbn__core-preboot-server-mocks": "link:bazel-bin/packages/core/preboot/core-preboot-server-mocks/npm_module_types",

View file

@ -86,9 +86,14 @@ filegroup(
"//packages/core/metrics/core-metrics-server-internal:build",
"//packages/core/metrics/core-metrics-server-mocks:build",
"//packages/core/metrics/core-metrics-server:build",
"//packages/core/mount-utils/core-mount-utils-browser-internal:build",
"//packages/core/mount-utils/core-mount-utils-browser:build",
"//packages/core/node/core-node-server-internal:build",
"//packages/core/node/core-node-server-mocks:build",
"//packages/core/node/core-node-server:build",
"//packages/core/overlays/core-overlays-browser-internal:build",
"//packages/core/overlays/core-overlays-browser-mocks:build",
"//packages/core/overlays/core-overlays-browser:build",
"//packages/core/preboot/core-preboot-server-internal:build",
"//packages/core/preboot/core-preboot-server-mocks:build",
"//packages/core/preboot/core-preboot-server:build",
@ -333,9 +338,14 @@ filegroup(
"//packages/core/metrics/core-metrics-server-internal:build_types",
"//packages/core/metrics/core-metrics-server-mocks:build_types",
"//packages/core/metrics/core-metrics-server:build_types",
"//packages/core/mount-utils/core-mount-utils-browser-internal:build_types",
"//packages/core/mount-utils/core-mount-utils-browser:build_types",
"//packages/core/node/core-node-server-internal:build_types",
"//packages/core/node/core-node-server-mocks:build_types",
"//packages/core/node/core-node-server:build_types",
"//packages/core/overlays/core-overlays-browser-internal:build_types",
"//packages/core/overlays/core-overlays-browser-mocks:build_types",
"//packages/core/overlays/core-overlays-browser:build_types",
"//packages/core/preboot/core-preboot-server-internal:build_types",
"//packages/core/preboot/core-preboot-server-mocks:build_types",
"//packages/core/preboot/core-preboot-server:build_types",

View file

@ -0,0 +1,113 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
PKG_DIRNAME = "core-mount-utils-browser-internal"
PKG_REQUIRE_NAME = "@kbn/core-mount-utils-browser-internal"
SOURCE_FILES = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
],
exclude = [
"**/*.test.*",
"**/*.stories.*",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
]
RUNTIME_DEPS = [
"@npm//react",
"@npm//react-dom",
"@npm//enzyme",
"//packages/kbn-i18n-react",
]
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/react",
"@npm//@types/react-dom",
"//packages/kbn-i18n-react:npm_module_types",
"//packages/core/mount-utils/core-mount-utils-browser:npm_module_types"
]
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)
jsts_transpiler(
name = "target_web",
srcs = SRCS,
build_pkg_name = package_name(),
web = True,
)
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)
ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
emit_declaration_only = True,
out_dir = "target_types",
root_dir = "src",
tsconfig = ":tsconfig",
)
js_library(
name = PKG_DIRNAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":target_web"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
pkg_npm(
name = "npm_module",
deps = [":" + PKG_DIRNAME],
)
filegroup(
name = "build",
srcs = [":npm_module"],
visibility = ["//visibility:public"],
)
pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)
filegroup(
name = "build_types",
srcs = [":npm_module_types"],
visibility = ["//visibility:public"],
)

View file

@ -0,0 +1,3 @@
# @kbn/core-mount-utils-browser-internal
This package contains the implementation and tests for Core's browser-side mount utilities.

View file

@ -0,0 +1,13 @@
/*
* 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.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/mount-utils/core-mount-utils-browser-internal'],
};

View file

@ -0,0 +1,8 @@
{
"name": "@kbn/core-mount-utils-browser-internal",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"browser": "./target_web/index.js",
"license": "SSPL-1.0 OR Elastic License 2.0"
}

View file

@ -0,0 +1,10 @@
/*
* 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.
*/
export { MountWrapper, mountReactNode } from './mount';
export { KBN_LOAD_MARKS } from './consts';

View file

@ -9,17 +9,24 @@
import React, { useEffect, useRef } from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { I18nProvider } from '@kbn/i18n-react';
import { MountPoint } from '../types';
import type { MountPoint } from '@kbn/core-mount-utils-browser';
const defaultWrapperClass = 'kbnMountWrapper';
interface MountWrapperComponentProps {
mount: MountPoint;
className?: string;
}
/**
* MountWrapper is a react component to mount a {@link MountPoint} inside a react tree.
* @internal
*/
type MountWrapperComponent = React.FunctionComponent<MountWrapperComponentProps>;
/**
* MountWrapper is a react component to mount a {@link MountPoint} inside a react tree.
*/
export const MountWrapper: React.FunctionComponent<{ mount: MountPoint; className?: string }> = ({
mount,
className = defaultWrapperClass,
}) => {
export const MountWrapper: MountWrapperComponent = ({ mount, className = defaultWrapperClass }) => {
const element = useRef(null);
useEffect(() => mount(element.current!), [mount]);
return <div className={className} ref={element} />;

View file

@ -0,0 +1,19 @@
{
"extends": "../../../../tsconfig.bazel.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"stripInternal": false,
"types": [
"jest",
"node",
"react"
]
},
"include": [
"src/**/*"
]
}

View file

@ -0,0 +1,107 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
PKG_DIRNAME = "core-mount-utils-browser"
PKG_REQUIRE_NAME = "@kbn/core-mount-utils-browser"
SOURCE_FILES = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
],
exclude = [
"**/*.test.*",
"**/*.stories.*",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
]
RUNTIME_DEPS = [
"@npm//react"
]
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/react"
]
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)
jsts_transpiler(
name = "target_web",
srcs = SRCS,
build_pkg_name = package_name(),
web = True,
)
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)
ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
emit_declaration_only = True,
out_dir = "target_types",
root_dir = "src",
tsconfig = ":tsconfig",
)
js_library(
name = PKG_DIRNAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":target_web"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
pkg_npm(
name = "npm_module",
deps = [":" + PKG_DIRNAME],
)
filegroup(
name = "build",
srcs = [":npm_module"],
visibility = ["//visibility:public"],
)
pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)
filegroup(
name = "build_types",
srcs = [":npm_module_types"],
visibility = ["//visibility:public"],
)

View file

@ -0,0 +1,3 @@
# @kbn/core-mount-utils-browser
This package contains the public type for Core's browser-side mount utilities public types.

View file

@ -0,0 +1,13 @@
/*
* 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.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/mount-utils/core-mount-utils-browser'],
};

View file

@ -0,0 +1,8 @@
{
"name": "@kbn/core-mount-utils-browser",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"browser": "./target_web/index.js",
"license": "SSPL-1.0 OR Elastic License 2.0"
}

View file

@ -0,0 +1,10 @@
/*
* 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.
*/
export type { MountPoint, UnmountCallback } from './mount_point';
export type { OverlayRef } from './overlay_ref';

View file

@ -6,13 +6,6 @@
* Side Public License, v 1.
*/
export type {
UiSettingsParams,
PublicUiSettingsParams,
UserProvidedValues,
UiSettingsType,
} from '@kbn/core-ui-settings-common';
/**
* A function that should mount DOM content inside the provided container element
* and return a handler to unmount it.

View file

@ -0,0 +1,19 @@
{
"extends": "../../../../tsconfig.bazel.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"stripInternal": false,
"types": [
"jest",
"node",
"react"
]
},
"include": [
"src/**/*"
]
}

View file

@ -0,0 +1,124 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
PKG_DIRNAME = "core-overlays-browser-internal"
PKG_REQUIRE_NAME = "@kbn/core-overlays-browser-internal"
SOURCE_FILES = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.scss"
],
exclude = [
"**/*.test.*",
"**/*.stories.*",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
]
RUNTIME_DEPS = [
"@npm//react",
"@npm//react-markdown",
"//packages/kbn-i18n-react",
"//packages/core/theme/core-theme-browser-internal",
"//packages/core/mount-utils/core-mount-utils-browser-internal",
]
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/react",
"@npm//react-markdown",
"//packages/kbn-i18n-react:npm_module_types",
"//packages/core/theme/core-theme-browser:npm_module_types",
"//packages/core/theme/core-theme-browser-internal:npm_module_types",
"//packages/core/mount-utils/core-mount-utils-browser-internal:npm_module_types",
"//packages/core/i18n/core-i18n-browser:npm_module_types",
"//packages/core/ui-settings/core-ui-settings-browser:npm_module_types",
"//packages/core/overlays/core-overlays-browser:npm_module_types"
]
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)
jsts_transpiler(
name = "target_web",
srcs = SRCS,
build_pkg_name = package_name(),
web = True,
additional_args = [
"--copy-files",
"--quiet"
]
)
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)
ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
emit_declaration_only = True,
out_dir = "target_types",
root_dir = "src",
tsconfig = ":tsconfig",
)
js_library(
name = PKG_DIRNAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":target_web"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
pkg_npm(
name = "npm_module",
deps = [":" + PKG_DIRNAME],
)
filegroup(
name = "build",
srcs = [":npm_module"],
visibility = ["//visibility:public"],
)
pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)
filegroup(
name = "build_types",
srcs = [":npm_module_types"],
visibility = ["//visibility:public"],
)

View file

@ -0,0 +1,3 @@
# @kbn/core-overlays-browser-internal
This package contains the implementation and internal types for Core's browser-side Overlays service.

View file

@ -0,0 +1,13 @@
/*
* 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.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/overlays/core-overlays-browser-internal'],
};

View file

@ -0,0 +1,8 @@
{
"name": "@kbn/core-overlays-browser-internal",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"browser": "./target_web/index.js",
"license": "SSPL-1.0 OR Elastic License 2.0"
}

View file

@ -12,7 +12,7 @@ import { mount } from 'enzyme';
import { BannersList } from './banners_list';
import { BehaviorSubject } from 'rxjs';
import { OverlayBanner } from './banners_service';
import type { OverlayBanner } from './banners_service';
describe('BannersList', () => {
test('renders null if no banners', () => {

View file

@ -8,8 +8,7 @@
import React, { useEffect, useRef, useState } from 'react';
import { Observable } from 'rxjs';
import { OverlayBanner } from './banners_service';
import type { OverlayBanner } from './banners_service';
interface Props {
banners$: Observable<OverlayBanner[]>;

View file

@ -0,0 +1,25 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 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 { InternalOverlayBannersStart } from './banners_service';
// internal duplicate of public mock for `createStartContractMock`
export const createStartContractMock = () => {
const startContract: jest.Mocked<InternalOverlayBannersStart> = {
add: jest.fn(),
remove: jest.fn(),
replace: jest.fn(),
get$: jest.fn(),
getComponent: jest.fn(),
};
return startContract;
};
export const overlayBannersServiceMock = {
createStartContract: createStartContractMock,
};

View file

@ -6,13 +6,13 @@
* Side Public License, v 1.
*/
import { OverlayBannersService, OverlayBannersStart } from './banners_service';
import { InternalOverlayBannersStart, OverlayBannersService } from './banners_service';
import { take } from 'rxjs/operators';
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
describe('OverlayBannersService', () => {
let service: OverlayBannersStart;
let service: InternalOverlayBannersStart;
beforeEach(() => {
service = new OverlayBannersService().start({
i18n: i18nServiceMock.createStartContract(),

View file

@ -7,50 +7,25 @@
*/
import React from 'react';
import { BehaviorSubject, Observable } from 'rxjs';
import { BehaviorSubject, type Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import type { I18nStart } from '@kbn/core-i18n-browser';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import type { MountPoint } from '@kbn/core-mount-utils-browser';
import type { OverlayBannersStart } from '@kbn/core-overlays-browser';
import { PriorityMap } from './priority_map';
import { BannersList } from './banners_list';
import { MountPoint } from '../../types';
import { UserBannerService } from './user_banner_service';
/** @public */
export interface OverlayBannersStart {
/**
* Add a new banner
*
* @param mount {@link MountPoint}
* @param priority optional priority order to display this banner. Higher priority values are shown first.
* @returns a unique identifier for the given banner to be used with {@link OverlayBannersStart.remove} and
* {@link OverlayBannersStart.replace}
*/
add(mount: MountPoint, priority?: number): string;
/**
* Remove a banner
*
* @param id the unique identifier for the banner returned by {@link OverlayBannersStart.add}
* @returns if the banner was found or not
*/
remove(id: string): boolean;
/**
* Replace a banner in place
*
* @param id the unique identifier for the banner returned by {@link OverlayBannersStart.add}
* @param mount {@link MountPoint}
* @param priority optional priority order to display this banner. Higher priority values are shown first.
* @returns a new identifier for the given banner to be used with {@link OverlayBannersStart.remove} and
* {@link OverlayBannersStart.replace}
*/
replace(id: string | undefined, mount: MountPoint, priority?: number): string;
interface StartDeps {
i18n: I18nStart;
uiSettings: IUiSettingsClient;
}
export interface InternalOverlayBannersStart extends OverlayBannersStart {
/** @internal */
get$(): Observable<OverlayBanner[]>;
getComponent(): JSX.Element;
}
/** @internal */
@ -60,21 +35,16 @@ export interface OverlayBanner {
readonly priority: number;
}
interface StartDeps {
i18n: I18nStart;
uiSettings: IUiSettingsClient;
}
/** @internal */
export class OverlayBannersService {
private readonly userBanner = new UserBannerService();
public start({ i18n, uiSettings }: StartDeps): OverlayBannersStart {
public start({ i18n, uiSettings }: StartDeps): InternalOverlayBannersStart {
let uniqueId = 0;
const genId = () => `${uniqueId++}`;
const banners$ = new BehaviorSubject(new PriorityMap<string, OverlayBanner>());
const service: OverlayBannersStart = {
const service: InternalOverlayBannersStart = {
add: (mount, priority = 0) => {
const id = genId();
const nextBanner: OverlayBanner = { id, mount, priority };

View file

@ -7,4 +7,4 @@
*/
export { OverlayBannersService } from './banners_service';
export type { OverlayBannersStart } from './banners_service';
export type { InternalOverlayBannersStart, OverlayBanner } from './banners_service';

View file

@ -8,7 +8,7 @@
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
import { UserBannerService } from './user_banner_service';
import { overlayBannersServiceMock } from './banners_service.mock';
import { overlayBannersServiceMock } from './banners_service.test.mocks';
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { Subject } from 'rxjs';

View file

@ -16,7 +16,7 @@ import { EuiCallOut, EuiButton, EuiLoadingSpinner } from '@elastic/eui';
import type { I18nStart } from '@kbn/core-i18n-browser';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import { OverlayBannersStart } from './banners_service';
import type { OverlayBannersStart } from '@kbn/core-overlays-browser';
interface StartDeps {
banners: OverlayBannersStart;

View file

@ -11,8 +11,9 @@ import { mockReactDomRender, mockReactDomUnmount } from '../overlay.test.mocks';
import { mount } from 'enzyme';
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { FlyoutService, OverlayFlyoutStart } from './flyout_service';
import { OverlayRef } from '../types';
import { FlyoutService } from './flyout_service';
import type { OverlayRef } from '@kbn/core-mount-utils-browser';
import type { OverlayFlyoutStart } from '@kbn/core-overlays-browser';
const i18nMock = i18nServiceMock.createStartContract();
const themeMock = themeServiceMock.createStartContract();

View file

@ -8,16 +8,16 @@
/* eslint-disable max-classes-per-file */
import { EuiFlyout, EuiFlyoutSize, EuiOverlayMaskProps } from '@elastic/eui';
import { EuiFlyout } from '@elastic/eui';
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Subject } from 'rxjs';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import { CoreContextProvider } from '@kbn/core-theme-browser-internal';
import { MountPoint } from '../../types';
import { OverlayRef } from '../types';
import { MountWrapper } from '../../utils';
import type { MountPoint, OverlayRef } from '@kbn/core-mount-utils-browser';
import { MountWrapper } from '@kbn/core-mount-utils-browser-internal';
import type { OverlayFlyoutOpenOptions, OverlayFlyoutStart } from '@kbn/core-overlays-browser';
/**
* A FlyoutRef is a reference to an opened flyout panel. It offers methods to
@ -59,44 +59,6 @@ class FlyoutRef implements OverlayRef {
}
}
/**
* APIs to open and manage fly-out dialogs.
*
* @public
*/
export interface OverlayFlyoutStart {
/**
* Opens a flyout panel with the given mount point inside. You can use
* `close()` on the returned FlyoutRef to close the flyout.
*
* @param mount {@link MountPoint} - Mounts the children inside a flyout panel
* @param options {@link OverlayFlyoutOpenOptions} - options for the flyout
* @return {@link OverlayRef} A reference to the opened flyout panel.
*/
open(mount: MountPoint, options?: OverlayFlyoutOpenOptions): OverlayRef;
}
/**
* @public
*/
export interface OverlayFlyoutOpenOptions {
className?: string;
closeButtonAriaLabel?: string;
ownFocus?: boolean;
'data-test-subj'?: string;
'aria-label'?: string;
size?: EuiFlyoutSize;
maxWidth?: boolean | number | string;
hideCloseButton?: boolean;
outsideClickCloses?: boolean;
maskProps?: EuiOverlayMaskProps;
/**
* EuiFlyout onClose handler.
* If provided the consumer is responsible for calling flyout.close() to close the flyout;
*/
onClose?: (flyout: OverlayRef) => void;
}
interface StartDeps {
i18n: I18nStart;
theme: ThemeServiceStart;

View file

@ -7,4 +7,3 @@
*/
export { FlyoutService } from './flyout_service';
export type { OverlayFlyoutStart, OverlayFlyoutOpenOptions } from './flyout_service';

View file

@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 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.
*/
export { OverlayService } from './overlay_service';
export {
OverlayBannersService,
type InternalOverlayBannersStart,
type OverlayBanner,
} from './banners';
export { FlyoutService } from './flyout';
export { ModalService } from './modal';

View file

@ -7,9 +7,3 @@
*/
export { ModalService } from './modal_service';
export type {
OverlayModalStart,
OverlayModalOpenOptions,
OverlayModalConfirmOptions,
} from './modal_service';

View file

@ -12,9 +12,10 @@ import React from 'react';
import { mount } from 'enzyme';
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { ModalService, OverlayModalStart } from './modal_service';
import { mountReactNode } from '../../utils';
import { OverlayRef } from '../types';
import { ModalService } from './modal_service';
import type { OverlayModalStart } from '@kbn/core-overlays-browser';
import { mountReactNode } from '@kbn/core-mount-utils-browser-internal';
import type { OverlayRef } from '@kbn/core-mount-utils-browser';
const i18nMock = i18nServiceMock.createStartContract();
const themeMock = themeServiceMock.createStartContract();

View file

@ -9,16 +9,20 @@
/* eslint-disable max-classes-per-file */
import { i18n as t } from '@kbn/i18n';
import { EuiModal, EuiConfirmModal, EuiConfirmModalProps } from '@elastic/eui';
import { EuiModal, EuiConfirmModal } from '@elastic/eui';
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Subject } from 'rxjs';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import { CoreContextProvider } from '@kbn/core-theme-browser-internal';
import { MountPoint } from '../../types';
import { OverlayRef } from '../types';
import { MountWrapper } from '../../utils';
import type { MountPoint, OverlayRef } from '@kbn/core-mount-utils-browser';
import { MountWrapper } from '@kbn/core-mount-utils-browser-internal';
import type {
OverlayModalConfirmOptions,
OverlayModalOpenOptions,
OverlayModalStart,
} from '@kbn/core-overlays-browser';
/**
* A ModalRef is a reference to an opened modal. It offers methods to
@ -49,64 +53,6 @@ class ModalRef implements OverlayRef {
}
}
/**
* @public
*/
export interface OverlayModalConfirmOptions {
title?: string;
cancelButtonText?: string;
confirmButtonText?: string;
className?: string;
closeButtonAriaLabel?: string;
'data-test-subj'?: string;
defaultFocusedButton?: EuiConfirmModalProps['defaultFocusedButton'];
buttonColor?: EuiConfirmModalProps['buttonColor'];
/**
* Sets the max-width of the modal.
* Set to `true` to use the default (`euiBreakpoints 'm'`),
* set to `false` to not restrict the width,
* set to a number for a custom width in px,
* set to a string for a custom width in custom measurement.
*/
maxWidth?: boolean | number | string;
}
/**
* APIs to open and manage modal dialogs.
*
* @public
*/
export interface OverlayModalStart {
/**
* Opens a modal panel with the given mount point inside. You can use
* `close()` on the returned OverlayRef to close the modal.
*
* @param mount {@link MountPoint} - Mounts the children inside the modal
* @param options {@link OverlayModalOpenOptions} - options for the modal
* @return {@link OverlayRef} A reference to the opened modal.
*/
open(mount: MountPoint, options?: OverlayModalOpenOptions): OverlayRef;
/**
* Opens a confirmation modal with the given text or mountpoint as a message.
* Returns a Promise resolving to `true` if user confirmed or `false` otherwise.
*
* @param message {@link MountPoint} - string or mountpoint to be used a the confirm message body
* @param options {@link OverlayModalConfirmOptions} - options for the confirm modal
*/
openConfirm(message: MountPoint | string, options?: OverlayModalConfirmOptions): Promise<boolean>;
}
/**
* @public
*/
export interface OverlayModalOpenOptions {
className?: string;
closeButtonAriaLabel?: string;
'data-test-subj'?: string;
maxWidth?: boolean | number | string;
}
interface StartDeps {
i18n: I18nStart;
theme: ThemeServiceStart;

View file

@ -9,9 +9,10 @@
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import { OverlayBannersStart, OverlayBannersService } from './banners';
import { FlyoutService, OverlayFlyoutStart } from './flyout';
import { ModalService, OverlayModalStart } from './modal';
import type { OverlayStart } from '@kbn/core-overlays-browser';
import { OverlayBannersService } from './banners';
import { FlyoutService } from './flyout';
import { ModalService } from './modal';
interface StartDeps {
i18n: I18nStart;
@ -45,15 +46,3 @@ export class OverlayService {
};
}
}
/** @public */
export interface OverlayStart {
/** {@link OverlayBannersStart} */
banners: OverlayBannersStart;
/** {@link OverlayFlyoutStart#open} */
openFlyout: OverlayFlyoutStart['open'];
/** {@link OverlayModalStart#open} */
openModal: OverlayModalStart['open'];
/** {@link OverlayModalStart#openConfirm} */
openConfirm: OverlayModalStart['openConfirm'];
}

View file

@ -0,0 +1,19 @@
{
"extends": "../../../../tsconfig.bazel.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"stripInternal": false,
"types": [
"jest",
"node",
"react"
]
},
"include": [
"src/**/*"
]
}

View file

@ -0,0 +1,102 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
PKG_DIRNAME = "core-overlays-browser-mocks"
PKG_REQUIRE_NAME = "@kbn/core-overlays-browser-mocks"
SOURCE_FILES = glob(
[
"src/**/*.ts",
],
exclude = [
"**/*.test.*",
"**/*.stories.*",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
]
RUNTIME_DEPS = [
"//packages/core/overlays/core-overlays-browser-internal",
]
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"//packages/kbn-utility-types:npm_module_types",
"//packages/kbn-utility-types-jest:npm_module_types",
"//packages/core/overlays/core-overlays-browser:npm_module_types",
"//packages/core/overlays/core-overlays-browser-internal:npm_module_types"
]
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)
ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
emit_declaration_only = True,
out_dir = "target_types",
root_dir = "src",
tsconfig = ":tsconfig",
)
js_library(
name = PKG_DIRNAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
pkg_npm(
name = "npm_module",
deps = [":" + PKG_DIRNAME],
)
filegroup(
name = "build",
srcs = [":npm_module"],
visibility = ["//visibility:public"],
)
pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)
filegroup(
name = "build_types",
srcs = [":npm_module_types"],
visibility = ["//visibility:public"],
)

View file

@ -0,0 +1,3 @@
# @kbn/core-overlays-browser-mocks
This package contains the mock for Core's browser-side Overlays service.

View file

@ -0,0 +1,13 @@
/*
* 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.
*/
module.exports = {
preset: '@kbn/test/jest_node',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/overlays/core-overlays-browser-mocks'],
};

View file

@ -0,0 +1,7 @@
{
"name": "@kbn/core-overlays-browser-mocks",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"license": "SSPL-1.0 OR Elastic License 2.0"
}

View file

@ -7,10 +7,13 @@
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { OverlayBannersStart, OverlayBannersService } from './banners_service';
import {
type InternalOverlayBannersStart,
type OverlayBannersService,
} from '@kbn/core-overlays-browser-internal';
const createStartContractMock = () => {
const startContract: jest.Mocked<OverlayBannersStart> = {
const startContract: jest.Mocked<InternalOverlayBannersStart> = {
add: jest.fn(),
remove: jest.fn(),
replace: jest.fn(),

View file

@ -7,7 +7,8 @@
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { FlyoutService, OverlayFlyoutStart } from './flyout_service';
import type { OverlayFlyoutStart } from '@kbn/core-overlays-browser';
import type { FlyoutService } from '@kbn/core-overlays-browser-internal';
const createStartContractMock = () => {
const startContract: jest.Mocked<OverlayFlyoutStart> = {

View file

@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 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.
*/
export { overlayServiceMock } from './overlay_service.mock';

View file

@ -7,7 +7,8 @@
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { ModalService, OverlayModalStart } from './modal_service';
import type { OverlayModalStart } from '@kbn/core-overlays-browser';
import type { ModalService } from '@kbn/core-overlays-browser-internal';
const createStartContractMock = () => {
const startContract: jest.Mocked<OverlayModalStart> = {

View file

@ -8,10 +8,11 @@
import type { PublicMethodsOf } from '@kbn/utility-types';
import type { DeeplyMockedKeys } from '@kbn/utility-types-jest';
import { OverlayService, OverlayStart } from './overlay_service';
import { overlayBannersServiceMock } from './banners/banners_service.mock';
import { overlayFlyoutServiceMock } from './flyout/flyout_service.mock';
import { overlayModalServiceMock } from './modal/modal_service.mock';
import type { OverlayService } from '@kbn/core-overlays-browser-internal';
import type { OverlayStart } from '@kbn/core-overlays-browser';
import { overlayBannersServiceMock } from './banners_service.mock';
import { overlayFlyoutServiceMock } from './flyout_service.mock';
import { overlayModalServiceMock } from './modal_service.mock';
const createStartContractMock = () => {
const overlayStart = overlayModalServiceMock.createStartContract();

View file

@ -0,0 +1,18 @@
{
"extends": "../../../../tsconfig.bazel.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"stripInternal": false,
"types": [
"jest",
"node"
]
},
"include": [
"src/**/*"
]
}

View file

@ -0,0 +1,108 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
PKG_DIRNAME = "core-overlays-browser"
PKG_REQUIRE_NAME = "@kbn/core-overlays-browser"
SOURCE_FILES = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
],
exclude = [
"**/*.test.*",
"**/*.stories.*",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
]
RUNTIME_DEPS = [
]
TYPES_DEPS = [
"@npm//rxjs",
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@elastic/eui",
"//packages/core/mount-utils/core-mount-utils-browser:npm_module_types"
]
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)
jsts_transpiler(
name = "target_web",
srcs = SRCS,
build_pkg_name = package_name(),
web = True,
)
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)
ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
emit_declaration_only = True,
out_dir = "target_types",
root_dir = "src",
tsconfig = ":tsconfig",
)
js_library(
name = PKG_DIRNAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":target_web"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
pkg_npm(
name = "npm_module",
deps = [":" + PKG_DIRNAME],
)
filegroup(
name = "build",
srcs = [":npm_module"],
visibility = ["//visibility:public"],
)
pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)
filegroup(
name = "build_types",
srcs = [":npm_module_types"],
visibility = ["//visibility:public"],
)

View file

@ -0,0 +1,3 @@
# @kbn/core-overlays-browser
This package contains the public types for Core's browser-side Overlays service.

View file

@ -0,0 +1,13 @@
/*
* 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.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/overlays/core-overlays-browser'],
};

View file

@ -0,0 +1,8 @@
{
"name": "@kbn/core-overlays-browser",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"browser": "./target_web/index.js",
"license": "SSPL-1.0 OR Elastic License 2.0"
}

View file

@ -0,0 +1,42 @@
/*
* 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 { MountPoint } from '@kbn/core-mount-utils-browser';
/** @public */
export interface OverlayBannersStart {
/**
* Add a new banner
*
* @param mount {@link MountPoint}
* @param priority optional priority order to display this banner. Higher priority values are shown first.
* @returns a unique identifier for the given banner to be used with {@link OverlayBannersStart.remove} and
* {@link OverlayBannersStart.replace}
*/
add(mount: MountPoint, priority?: number): string;
/**
* Remove a banner
*
* @param id the unique identifier for the banner returned by {@link OverlayBannersStart.add}
* @returns if the banner was found or not
*/
remove(id: string): boolean;
/**
* Replace a banner in place
*
* @param id the unique identifier for the banner returned by {@link OverlayBannersStart.add}
* @param mount {@link MountPoint}
* @param priority optional priority order to display this banner. Higher priority values are shown first.
* @returns a new identifier for the given banner to be used with {@link OverlayBannersStart.remove} and
* {@link OverlayBannersStart.replace}
*/
replace(id: string | undefined, mount: MountPoint, priority?: number): string;
getComponent(): JSX.Element;
}

View file

@ -0,0 +1,47 @@
/*
* 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 { EuiFlyoutSize, EuiOverlayMaskProps } from '@elastic/eui';
import type { MountPoint, OverlayRef } from '@kbn/core-mount-utils-browser';
/**
* APIs to open and manage fly-out dialogs.
*
* @public
*/
export interface OverlayFlyoutStart {
/**
* Opens a flyout panel with the given mount point inside. You can use
* `close()` on the returned FlyoutRef to close the flyout.
*
* @param mount {@link MountPoint} - Mounts the children inside a flyout panel
* @param options {@link OverlayFlyoutOpenOptions} - options for the flyout
* @return {@link OverlayRef} A reference to the opened flyout panel.
*/
open(mount: MountPoint, options?: OverlayFlyoutOpenOptions): OverlayRef;
}
/**
* @public
*/
export interface OverlayFlyoutOpenOptions {
className?: string;
closeButtonAriaLabel?: string;
ownFocus?: boolean;
'data-test-subj'?: string;
'aria-label'?: string;
size?: EuiFlyoutSize;
maxWidth?: boolean | number | string;
hideCloseButton?: boolean;
outsideClickCloses?: boolean;
maskProps?: EuiOverlayMaskProps;
/**
* EuiFlyout onClose handler.
* If provided the consumer is responsible for calling flyout.close() to close the flyout;
*/
onClose?: (flyout: OverlayRef) => void;
}

View file

@ -5,9 +5,8 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export { OverlayService } from './overlay_service';
export type { OverlayRef } from './types';
export type { OverlayStart } from './overlays';
export type { OverlayBannersStart } from './banners';
export type { OverlayFlyoutStart, OverlayFlyoutOpenOptions } from './flyout';
export type {
@ -15,4 +14,3 @@ export type {
OverlayModalOpenOptions,
OverlayModalConfirmOptions,
} from './modal';
export type { OverlayStart } from './overlay_service';

View file

@ -0,0 +1,68 @@
/*
* 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 { EuiConfirmModalProps } from '@elastic/eui';
import type { MountPoint, OverlayRef } from '@kbn/core-mount-utils-browser';
/**
* @public
*/
export interface OverlayModalConfirmOptions {
title?: string;
cancelButtonText?: string;
confirmButtonText?: string;
className?: string;
closeButtonAriaLabel?: string;
'data-test-subj'?: string;
defaultFocusedButton?: EuiConfirmModalProps['defaultFocusedButton'];
buttonColor?: EuiConfirmModalProps['buttonColor'];
/**
* Sets the max-width of the modal.
* Set to `true` to use the default (`euiBreakpoints 'm'`),
* set to `false` to not restrict the width,
* set to a number for a custom width in px,
* set to a string for a custom width in custom measurement.
*/
maxWidth?: boolean | number | string;
}
/**
* APIs to open and manage modal dialogs.
*
* @public
*/
export interface OverlayModalStart {
/**
* Opens a modal panel with the given mount point inside. You can use
* `close()` on the returned OverlayRef to close the modal.
*
* @param mount {@link MountPoint} - Mounts the children inside the modal
* @param options {@link OverlayModalOpenOptions} - options for the modal
* @return {@link OverlayRef} A reference to the opened modal.
*/
open(mount: MountPoint, options?: OverlayModalOpenOptions): OverlayRef;
/**
* Opens a confirmation modal with the given text or mountpoint as a message.
* Returns a Promise resolving to `true` if user confirmed or `false` otherwise.
*
* @param message {@link MountPoint} - string or mountpoint to be used a the confirm message body
* @param options {@link OverlayModalConfirmOptions} - options for the confirm modal
*/
openConfirm(message: MountPoint | string, options?: OverlayModalConfirmOptions): Promise<boolean>;
}
/**
* @public
*/
export interface OverlayModalOpenOptions {
className?: string;
closeButtonAriaLabel?: string;
'data-test-subj'?: string;
maxWidth?: boolean | number | string;
}

View file

@ -0,0 +1,22 @@
/*
* 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 { OverlayBannersStart } from './banners';
import type { OverlayFlyoutStart } from './flyout';
import type { OverlayModalStart } from './modal';
/** @public */
export interface OverlayStart {
/** {@link OverlayBannersStart} */
banners: OverlayBannersStart;
/** {@link OverlayFlyoutStart#open} */
openFlyout: OverlayFlyoutStart['open'];
/** {@link OverlayModalStart#open} */
openModal: OverlayModalStart['open'];
/** {@link OverlayModalStart#openConfirm} */
openConfirm: OverlayModalStart['openConfirm'];
}

View file

@ -0,0 +1,19 @@
{
"extends": "../../../../tsconfig.bazel.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"stripInternal": false,
"types": [
"jest",
"node",
"react"
]
},
"include": [
"src/**/*"
]
}

View file

@ -0,0 +1,3 @@
.kbnGlobalBannerList__item + .kbnGlobalBannerList__item {
margin-top: $euiSizeS;
}

View file

@ -0,0 +1,5 @@
.kbnOverlayMountWrapper {
display: flex;
flex-direction: column;
height: 100%;
}

View file

@ -9,7 +9,7 @@
import { History } from 'history';
import { BehaviorSubject, Subject } from 'rxjs';
import type { MountPoint } from '../types';
import type { MountPoint } from '@kbn/core-mount-utils-browser';
import { capabilitiesServiceMock } from './capabilities/capabilities_service.mock';
import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { scopedHistoryMock } from './scoped_history.mock';

View file

@ -19,7 +19,7 @@ import { mount, shallow } from 'enzyme';
import { httpServiceMock } from '@kbn/core-http-browser-mocks';
import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { overlayServiceMock } from '../overlays/overlay_service.mock';
import { overlayServiceMock } from '@kbn/core-overlays-browser-mocks';
import { MockLifecycle } from './test_types';
import { ApplicationService } from './application_service';
import { App, AppDeepLink, AppNavLinkStatus, AppStatus, AppUpdater, PublicAppInfo } from './types';

View file

@ -15,8 +15,8 @@ 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 { Capabilities } from '@kbn/core-capabilities-common';
import type { MountPoint } from '../types';
import type { OverlayStart } from '../overlays';
import type { MountPoint } from '@kbn/core-mount-utils-browser';
import type { OverlayStart } from '@kbn/core-overlays-browser';
import { AppRouter } from './ui';
import { CapabilitiesService } from './capabilities';
import type {

View file

@ -16,9 +16,9 @@ import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { createRenderer } from './utils';
import { ApplicationService } from '../application_service';
import type { MockLifecycle } from '../test_types';
import { overlayServiceMock } from '../../overlays/overlay_service.mock';
import { overlayServiceMock } from '@kbn/core-overlays-browser-mocks';
import type { AppMountParameters, AppUpdater } from '../types';
import type { MountPoint } from '../..';
import type { MountPoint } from '@kbn/core-mount-utils-browser';
const flushPromises = () => new Promise((resolve) => setImmediate(resolve));

View file

@ -6,8 +6,8 @@
* Side Public License, v 1.
*/
import { OverlayStart } from '../overlays';
import { overlayServiceMock } from '../overlays/overlay_service.mock';
import type { OverlayStart } from '@kbn/core-overlays-browser';
import { overlayServiceMock } from '@kbn/core-overlays-browser-mocks';
import { getUserConfirmationHandler, ConfirmHandler } from './navigation_confirm';
const nextTick = () => new Promise((resolve) => setImmediate(resolve));

View file

@ -13,7 +13,7 @@ import { RecursiveReadonly } from '@kbn/utility-types';
import type { CoreTheme } from '@kbn/core-theme-browser';
import type { Capabilities } from '@kbn/core-capabilities-common';
import { MountPoint } from '../types';
import type { MountPoint } from '@kbn/core-mount-utils-browser';
import { PluginOpaqueId } from '../plugins';
import { AppCategory } from '../../types';
import { ScopedHistory } from './scoped_history';

View file

@ -13,7 +13,7 @@ import { EuiLoadingElastic } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import type { CoreTheme } from '@kbn/core-theme-browser';
import type { MountPoint } from '../../types';
import type { MountPoint } from '@kbn/core-mount-utils-browser';
import { AppLeaveHandler, AppStatus, AppUnmount, Mounter } from '../types';
import { AppNotFound } from './app_not_found_screen';
import { ScopedHistory } from '../scoped_history';

View file

@ -13,7 +13,7 @@ import { Observable } from 'rxjs';
import useObservable from 'react-use/lib/useObservable';
import type { CoreTheme } from '@kbn/core-theme-browser';
import type { MountPoint } from '../../types';
import type { MountPoint } from '@kbn/core-mount-utils-browser';
import { AppLeaveHandler, AppStatus, Mounter } from '../types';
import { AppContainer } from './app_container';
import { ScopedHistory } from '../scoped_history';

View file

@ -15,7 +15,7 @@ import { EuiLink } from '@elastic/eui';
import type { InternalInjectedMetadataStart } from '@kbn/core-injected-metadata-browser-internal';
import type { DocLinksStart } from '@kbn/core-doc-links-browser';
import type { HttpStart } from '@kbn/core-http-browser';
import { mountReactNode } from '../utils/mount';
import { mountReactNode } from '@kbn/core-mount-utils-browser-internal';
import type { InternalApplicationStart } from '../application';
import type { NotificationsStart } from '../notifications';
import { KIBANA_ASK_ELASTIC_LINK } from './constants';

View file

@ -9,7 +9,7 @@
import { sortBy } from 'lodash';
import { BehaviorSubject, ReplaySubject, Observable } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { MountPoint } from '../../types';
import type { MountPoint } from '@kbn/core-mount-utils-browser';
/** @public */
export interface ChromeNavControl {

View file

@ -8,7 +8,7 @@
import { EuiBreadcrumb, IconType } from '@elastic/eui';
import { Observable } from 'rxjs';
import { MountPoint } from '../types';
import type { MountPoint } from '@kbn/core-mount-utils-browser';
import { ChromeDocTitle } from './doc_title';
import { ChromeNavControls } from './nav_controls';
import { ChromeNavLinks, ChromeNavLink } from './nav_links';

View file

@ -11,7 +11,7 @@ import { mount, ReactWrapper } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { BehaviorSubject } from 'rxjs';
import { HeaderActionMenu } from './header_action_menu';
import { MountPoint, UnmountCallback } from '../../../types';
import type { MountPoint, UnmountCallback } from '@kbn/core-mount-utils-browser';
type MockedUnmount = jest.MockedFunction<UnmountCallback>;

View file

@ -8,7 +8,7 @@
import React, { FC, useRef, useLayoutEffect, useState } from 'react';
import { Observable } from 'rxjs';
import { MountPoint, UnmountCallback } from '../../../types';
import type { MountPoint, UnmountCallback } from '@kbn/core-mount-utils-browser';
interface HeaderActionMenuProps {
actionMenu$: Observable<MountPoint | undefined>;

View file

@ -7,7 +7,7 @@
*/
import React from 'react';
import { MountPoint } from '../../../types';
import type { MountPoint } from '@kbn/core-mount-utils-browser';
interface Props {
extension?: MountPoint<HTMLDivElement>;

View file

@ -12,8 +12,8 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import type { DocLinksStart } from '@kbn/core-doc-links-browser';
import { mountReactNode } from '@kbn/core-mount-utils-browser-internal';
import type { HttpStart, NotificationsStart } from '../..';
import { mountReactNode } from '../../utils';
/** Only exported for tests */
export const MISSING_CONFIG_STORAGE_KEY = `core.warnings.publicBaseUrlMissingDismissed`;

View file

@ -14,7 +14,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import type { IBasePath } from '@kbn/core-http-browser';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import { mountReactNode } from '../../utils';
import { mountReactNode } from '@kbn/core-mount-utils-browser-internal';
import { IToasts } from '../../notifications';
const IE_REGEX = /(; ?MSIE |Edge\/\d|Trident\/[\d+\.]+;.*rv:*11\.\d+)/;

View file

@ -16,7 +16,7 @@ import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
import { httpServiceMock } from '@kbn/core-http-browser-mocks';
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { notificationServiceMock } from './notifications/notifications_service.mock';
import { overlayServiceMock } from './overlays/overlay_service.mock';
import { overlayServiceMock } from '@kbn/core-overlays-browser-mocks';
import { pluginsServiceMock } from './plugins/plugins_service.mock';
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
import { renderingServiceMock } from './rendering/rendering_service.mock';
@ -88,7 +88,7 @@ jest.doMock('./chrome', () => ({
export const MockOverlayService = overlayServiceMock.create();
export const OverlayServiceConstructor = jest.fn().mockImplementation(() => MockOverlayService);
jest.doMock('./overlays', () => ({
jest.doMock('@kbn/core-overlays-browser-internal', () => ({
OverlayService: OverlayServiceConstructor,
}));

View file

@ -26,10 +26,11 @@ import { HttpService } from '@kbn/core-http-browser-internal';
import { UiSettingsService } from '@kbn/core-ui-settings-browser-internal';
import { DeprecationsService } from '@kbn/core-deprecations-browser-internal';
import { IntegrationsService } from '@kbn/core-integrations-browser-internal';
import { OverlayService } from '@kbn/core-overlays-browser-internal';
import { KBN_LOAD_MARKS } from '@kbn/core-mount-utils-browser-internal';
import { CoreSetup, CoreStart } from '.';
import { ChromeService } from './chrome';
import { NotificationsService } from './notifications';
import { OverlayService } from './overlays';
import { PluginsService } from './plugins';
import { ApplicationService } from './application';
import { RenderingService } from './rendering';
@ -37,7 +38,6 @@ import { SavedObjectsService } from './saved_objects';
import { CoreApp } from './core_app';
import type { InternalApplicationSetup, InternalApplicationStart } from './application/types';
import { fetchOptionalMemoryInfo } from './fetch_optional_memory_info';
import { KBN_LOAD_MARKS } from './utils';
interface Params {
rootDomElement: HTMLElement;

View file

@ -2,6 +2,7 @@
@import './mixins';
@import './core';
@import './chrome/index';
@import './overlays/index';
@import './banners_list';
@import './mount_wrapper';
@import './rendering/index';
@import './styles/index';

View file

@ -45,6 +45,7 @@ import type {
import type { UiSettingsState, IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import type { DeprecationsServiceStart } from '@kbn/core-deprecations-browser';
import type { Capabilities } from '@kbn/core-capabilities-common';
import type { OverlayStart } from '@kbn/core-overlays-browser';
import type {
ChromeBadge,
ChromeBreadcrumb,
@ -68,7 +69,6 @@ import type {
ChromeHelpMenuActions,
} from './chrome';
import type { NotificationsSetup, NotificationsStart } from './notifications';
import type { OverlayStart } from './overlays';
import type {
Plugin,
PluginInitializer,
@ -86,6 +86,7 @@ export { DEFAULT_APP_CATEGORIES, APP_WRAPPER_CLASS } from '../utils';
export type { AppCategory } from '../types';
export type {
UiSettingsParams,
PublicUiSettingsParams,
UserProvidedValues,
UiSettingsType,
} from '@kbn/core-ui-settings-common';
@ -194,13 +195,12 @@ export type { IHttpFetchError } from '@kbn/core-http-browser';
export type {
OverlayStart,
OverlayBannersStart,
OverlayRef,
OverlayFlyoutStart,
OverlayFlyoutOpenOptions,
OverlayModalOpenOptions,
OverlayModalConfirmOptions,
OverlayModalStart,
} from './overlays';
} from '@kbn/core-overlays-browser';
export type {
Toast,
@ -221,7 +221,7 @@ export type {
ResolveDeprecationResponse,
} from '@kbn/core-deprecations-browser';
export type { MountPoint, UnmountCallback, PublicUiSettingsParams } from './types';
export type { MountPoint, UnmountCallback, OverlayRef } from '@kbn/core-mount-utils-browser';
export { URL_MAX_LENGTH } from './core_app';

View file

@ -7,9 +7,9 @@
*/
import { i18n } from '@kbn/i18n';
import { KBN_LOAD_MARKS } from '@kbn/core-mount-utils-browser-internal';
import { CoreSystem } from './core_system';
import { ApmSystem } from './apm_system';
import { KBN_LOAD_MARKS } from './utils';
/** @internal */
export async function __kbnBootstrap__() {

View file

@ -19,13 +19,13 @@ import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
import { httpServiceMock } from '@kbn/core-http-browser-mocks';
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
import { deprecationsServiceMock } from '@kbn/core-deprecations-browser-mocks';
import { overlayServiceMock } from '@kbn/core-overlays-browser-mocks';
import type { PluginInitializerContext, AppMountParameters } from '.';
// Import values from their individual modules instead.
import { ScopedHistory } from './application';
import { applicationServiceMock } from './application/application_service.mock';
import { chromeServiceMock } from './chrome/chrome_service.mock';
import { notificationServiceMock } from './notifications/notifications_service.mock';
import { overlayServiceMock } from './overlays/overlay_service.mock';
import { savedObjectsServiceMock } from './saved_objects/saved_objects_service.mock';
export { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks';
@ -38,7 +38,7 @@ export { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
export { httpServiceMock } from '@kbn/core-http-browser-mocks';
export { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
export { notificationServiceMock } from './notifications/notifications_service.mock';
export { overlayServiceMock } from './overlays/overlay_service.mock';
export { overlayServiceMock } from '@kbn/core-overlays-browser-mocks';
export { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
export { savedObjectsServiceMock } from './saved_objects/saved_objects_service.mock';
export { scopedHistoryMock } from './application/scoped_history.mock';

View file

@ -12,8 +12,8 @@ import { Subscription } from 'rxjs';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import type { OverlayStart } from '@kbn/core-overlays-browser';
import { ToastsService, ToastsSetup, ToastsStart } from './toasts';
import { OverlayStart } from '../overlays';
export interface SetupDeps {
uiSettings: IUiSettingsClient;

View file

@ -13,10 +13,10 @@ import { omitBy, isUndefined } from 'lodash';
import type { I18nStart } from '@kbn/core-i18n-browser';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import type { MountPoint } from '@kbn/core-mount-utils-browser';
import type { OverlayStart } from '@kbn/core-overlays-browser';
import { mountReactNode } from '@kbn/core-mount-utils-browser-internal';
import { ErrorToast } from './error_toast';
import { MountPoint } from '../../types';
import { mountReactNode } from '../../utils';
import { OverlayStart } from '../../overlays';
/**
* Allowed fields for {@link ToastInput}.

View file

@ -10,7 +10,7 @@ import { mockReactDomRender, mockReactDomUnmount } from './toasts_service.test.m
import { ToastsService } from './toasts_service';
import { ToastsApi } from './toasts_api';
import { overlayServiceMock } from '../../overlays/overlay_service.mock';
import { overlayServiceMock } from '@kbn/core-overlays-browser-mocks';
import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';

View file

@ -13,9 +13,9 @@ import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import { CoreContextProvider } from '@kbn/core-theme-browser-internal';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import type { OverlayStart } from '@kbn/core-overlays-browser';
import { GlobalToastList } from './global_toast_list';
import { ToastsApi, IToasts } from './toasts_api';
import { OverlayStart } from '../../overlays';
interface SetupDeps {
uiSettings: IUiSettingsClient;

View file

@ -31,7 +31,7 @@ import {
import type { InjectedMetadataPlugin } from '@kbn/core-injected-metadata-common-internal';
import { notificationServiceMock } from '../notifications/notifications_service.mock';
import { applicationServiceMock } from '../application/application_service.mock';
import { overlayServiceMock } from '../overlays/overlay_service.mock';
import { overlayServiceMock } from '@kbn/core-overlays-browser-mocks';
import { chromeServiceMock } from '../chrome/chrome_service.mock';
import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';

View file

@ -12,7 +12,7 @@ import { act } from 'react-dom/test-utils';
import { RenderingService } from './rendering_service';
import { applicationServiceMock } from '../application/application_service.mock';
import { chromeServiceMock } from '../chrome/chrome_service.mock';
import { overlayServiceMock } from '../overlays/overlay_service.mock';
import { overlayServiceMock } from '@kbn/core-overlays-browser-mocks';
import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { BehaviorSubject } from 'rxjs';

View file

@ -13,9 +13,9 @@ import { pairwise, startWith } from 'rxjs/operators';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import { CoreContextProvider } from '@kbn/core-theme-browser-internal';
import type { OverlayStart } from '@kbn/core-overlays-browser';
import type { InternalChromeStart } from '../chrome';
import type { InternalApplicationStart } from '../application';
import type { OverlayStart } from '../overlays';
import { AppWrapper } from './app_containers';
export interface StartDeps {

Some files were not shown because too many files have changed in this diff Show more