Skip to content

Commit

Permalink
Merge branch 'main' into cases-user-suggestions-be
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Aug 1, 2022
2 parents 9ec9d21 + a8ebf5a commit 0add79c
Show file tree
Hide file tree
Showing 109 changed files with 1,386 additions and 490 deletions.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@
"@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-notifications-browser": "link:bazel-bin/packages/core/notifications/core-notifications-browser",
"@kbn/core-notifications-browser-internal": "link:bazel-bin/packages/core/notifications/core-notifications-browser-internal",
"@kbn/core-notifications-browser-mocks": "link:bazel-bin/packages/core/notifications/core-notifications-browser-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",
Expand Down Expand Up @@ -850,6 +853,9 @@
"@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-notifications-browser": "link:bazel-bin/packages/core/notifications/core-notifications-browser/npm_module_types",
"@types/kbn__core-notifications-browser-internal": "link:bazel-bin/packages/core/notifications/core-notifications-browser-internal/npm_module_types",
"@types/kbn__core-notifications-browser-mocks": "link:bazel-bin/packages/core/notifications/core-notifications-browser-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",
Expand Down Expand Up @@ -1039,7 +1045,7 @@
"@types/resolve": "^1.20.1",
"@types/rrule": "^2.2.9",
"@types/seedrandom": ">=2.0.0 <4.0.0",
"@types/selenium-webdriver": "^4.1.1",
"@types/selenium-webdriver": "^4.1.2",
"@types/semver": "^7",
"@types/set-value": "^2.0.0",
"@types/sinon": "^7.0.13",
Expand Down
6 changes: 6 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ filegroup(
"//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/notifications/core-notifications-browser-internal:build",
"//packages/core/notifications/core-notifications-browser-mocks:build",
"//packages/core/notifications/core-notifications-browser:build",
"//packages/core/overlays/core-overlays-browser-internal:build",
"//packages/core/overlays/core-overlays-browser-mocks:build",
"//packages/core/overlays/core-overlays-browser:build",
Expand Down Expand Up @@ -343,6 +346,9 @@ filegroup(
"//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/notifications/core-notifications-browser-internal:build_types",
"//packages/core/notifications/core-notifications-browser-mocks:build_types",
"//packages/core/notifications/core-notifications-browser: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",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
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-notifications-browser-internal"
PKG_REQUIRE_NAME = "@kbn/core-notifications-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//rxjs",
"@npm//lodash",
"@npm//@elastic/eui",
"@npm//enzyme",
"//packages/kbn-i18n",
"//packages/kbn-i18n-react",
"//packages/core/theme/core-theme-browser-internal",
"//packages/core/overlays/core-overlays-browser-mocks",
"//packages/core/theme/core-theme-browser-mocks",
"//packages/core/ui-settings/core-ui-settings-browser-mocks",
"//packages/core/mount-utils/core-mount-utils-browser-internal",
]

TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/react",
"@npm//@types/react-dom",
"@npm//rxjs",
"@npm//lodash",
"@npm//@elastic/eui",
"@npm//enzyme",
"//packages/kbn-i18n-react:npm_module_types",
"//packages/kbn-i18n:npm_module_types",
"//packages/kbn-utility-types:npm_module_types",
"//packages/core/theme/core-theme-browser:npm_module_types",
"//packages/core/theme/core-theme-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",
"//packages/core/notifications/core-notifications-browser:npm_module_types",
"//packages/core/mount-utils/core-mount-utils-browser-internal: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"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/core-notifications-browser-internal

This package contains the implementation and internal types for core's browser-side notifications service.
Original file line number Diff line number Diff line change
@@ -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/notifications/core-notifications-browser-internal'],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@kbn/core-notifications-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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,5 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export { NotificationsService } from './notifications_service';
export type {
ErrorToastOptions,
ToastOptions,
Toast,
ToastInput,
IToasts,
ToastsApi,
ToastInputFields,
ToastsSetup,
ToastsStart,
} from './toasts';
export type { NotificationsSetup, NotificationsStart } from './notifications_service';
export { NotificationsService, type NotificationsServiceContract } from './notifications_service';
export type { ToastsApi } from './toasts';
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ 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 type { NotificationsSetup, NotificationsStart } from '@kbn/core-notifications-browser';
import type { PublicMethodsOf } from '@kbn/utility-types';
import { ToastsService } from './toasts';

export interface SetupDeps {
uiSettings: IUiSettingsClient;
Expand Down Expand Up @@ -84,14 +86,7 @@ export class NotificationsService {
}
}

/** @public */
export interface NotificationsSetup {
/** {@link ToastsSetup} */
toasts: ToastsSetup;
}

/** @public */
export interface NotificationsStart {
/** {@link ToastsStart} */
toasts: ToastsStart;
}
/**
* @public {@link NotificationsService}
*/
export type NotificationsServiceContract = PublicMethodsOf<NotificationsService>;
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import type { I18nStart } from '@kbn/core-i18n-browser';
import { OverlayStart } from '../..';
import type { OverlayStart } from '@kbn/core-overlays-browser';

interface ErrorToastProps {
title: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import { EuiGlobalToastList } from '@elastic/eui';
import { shallow } from 'enzyme';
import React from 'react';
import * as Rx from 'rxjs';
import { Observable, from, EMPTY } from 'rxjs';

import { GlobalToastList } from './global_toast_list';

function render(props: Partial<GlobalToastList['props']> = {}) {
return <GlobalToastList dismissToast={jest.fn()} toasts$={Rx.EMPTY} {...props} />;
return <GlobalToastList dismissToast={jest.fn()} toasts$={EMPTY} {...props} />;
}

it('renders matching snapshot', () => {
Expand All @@ -29,7 +29,7 @@ it('subscribes to toasts$ on mount and unsubscribes on unmount', () => {
});

const component = render({
toasts$: new Rx.Observable<any>(subscribeSpy),
toasts$: new Observable<any>(subscribeSpy),
});

expect(subscribeSpy).not.toHaveBeenCalled();
Expand All @@ -46,7 +46,7 @@ it('subscribes to toasts$ on mount and unsubscribes on unmount', () => {
it('passes latest value from toasts$ to <EuiGlobalToastList />', () => {
const el = shallow(
render({
toasts$: Rx.from([[], [{ id: '1' }], [{ id: '1' }, { id: '2' }]]) as any,
toasts$: from([[], [{ id: '1' }], [{ id: '1' }, { id: '2' }]]) as any,
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

import { EuiGlobalToastList, EuiGlobalToastListToast as EuiToast } from '@elastic/eui';
import React from 'react';
import * as Rx from 'rxjs';
import { Observable, type Subscription } from 'rxjs';
import { i18n } from '@kbn/i18n';

import { MountWrapper } from '../../utils';
import { Toast } from './toasts_api';
import type { Toast } from '@kbn/core-notifications-browser';
import { MountWrapper } from '@kbn/core-mount-utils-browser-internal';

interface Props {
toasts$: Rx.Observable<Toast[]>;
toasts$: Observable<Toast[]>;
dismissToast: (toastId: string) => void;
}

Expand All @@ -34,7 +34,7 @@ export class GlobalToastList extends React.Component<Props, State> {
toasts: [],
};

private subscription?: Rx.Subscription;
private subscription?: Subscription;

public componentDidMount() {
this.subscription = this.props.toasts$.subscribe((toasts) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 { ToastsService } from './toasts_service';
export type { ToastsApi } from './toasts_api';
Loading

0 comments on commit 0add79c

Please sign in to comment.