Skip to content

Commit

Permalink
[shared-ux][packages] 2. Create Storybook Package (#127548)
Browse files Browse the repository at this point in the history
* [shared-ux][packages] 2. Create Storybook Package

* [shared-ux][packages] 3. Create Utility Package (#127549)

* [shared-ux][packages] 3. Create Utility Package

* [shared-ux][packages] 4. Create Components Package (#127551)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
clintandrewhall and kibanamachine authored Mar 14, 2022
1 parent dddafc0 commit 2976de7
Show file tree
Hide file tree
Showing 77 changed files with 749 additions and 65 deletions.
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"server": "src/legacy/server",
"share": "src/plugins/share",
"sharedUX": "src/plugins/shared_ux",
"sharedUXComponents": "packages/kbn-shared-ux-components/src",
"statusPage": "src/legacy/core_plugins/status_page",
"telemetry": ["src/plugins/telemetry", "src/plugins/telemetry_management_section"],
"timelion": ["src/plugins/vis_types/timelion"],
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@
"@kbn/securitysolution-utils": "link:bazel-bin/packages/kbn-securitysolution-utils",
"@kbn/server-http-tools": "link:bazel-bin/packages/kbn-server-http-tools",
"@kbn/server-route-repository": "link:bazel-bin/packages/kbn-server-route-repository",
"@kbn/shared-ux-components": "link:bazel-bin/packages/kbn-shared-ux-components",
"@kbn/shared-ux-services": "link:bazel-bin/packages/kbn-shared-ux-services",
"@kbn/shared-ux-storybook": "link:bazel-bin/packages/kbn-shared-ux-storybook",
"@kbn/shared-ux-utility": "link:bazel-bin/packages/kbn-shared-ux-utility",
"@kbn/std": "link:bazel-bin/packages/kbn-std",
"@kbn/timelion-grammar": "link:bazel-bin/packages/kbn-timelion-grammar",
"@kbn/tinymath": "link:bazel-bin/packages/kbn-tinymath",
Expand Down Expand Up @@ -197,7 +200,10 @@
"@turf/helpers": "6.0.1",
"@turf/length": "^6.0.2",
"@types/jsonwebtoken": "^8.5.6",
"@types/kbn__shared-ux-components": "link:bazel-bin/packages/kbn-shared-ux-components/npm_module_types",
"@types/kbn__shared-ux-services": "link:bazel-bin/packages/kbn-shared-ux-services/npm_module_types",
"@types/kbn__shared-ux-storybook": "link:bazel-bin/packages/kbn-shared-ux-storybook/npm_module_types",
"@types/kbn__shared-ux-utility": "link:bazel-bin/packages/kbn-shared-ux-utility/npm_module_types",
"@types/moment-duration-format": "^2.2.3",
"JSONStream": "1.3.5",
"abort-controller": "^3.0.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ filegroup(
"//packages/kbn-securitysolution-utils:build",
"//packages/kbn-server-http-tools:build",
"//packages/kbn-server-route-repository:build",
"//packages/kbn-shared-ux-components:build",
"//packages/kbn-shared-ux-services:build",
"//packages/kbn-shared-ux-storybook:build",
"//packages/kbn-shared-ux-utility:build",
"//packages/kbn-spec-to-console:build",
"//packages/kbn-std:build",
"//packages/kbn-storybook:build",
Expand Down Expand Up @@ -139,7 +142,10 @@ filegroup(
"//packages/kbn-securitysolution-utils:build_types",
"//packages/kbn-server-http-tools:build_types",
"//packages/kbn-server-route-repository:build_types",
"//packages/kbn-shared-ux-components:build_types",
"//packages/kbn-shared-ux-services:build_types",
"//packages/kbn-shared-ux-storybook:build_types",
"//packages/kbn-shared-ux-utility:build_types",
"//packages/kbn-std:build_types",
"//packages/kbn-storybook:build_types",
"//packages/kbn-telemetry-tools:build_types",
Expand Down
150 changes: 150 additions & 0 deletions packages/kbn-shared-ux-components/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
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 = "kbn-shared-ux-components"
PKG_REQUIRE_NAME = "@kbn/shared-ux-components"

SOURCE_FILES = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.scss",
"src/**/*.mdx",
],
exclude = [
"**/*.test.*",
],
)

SRCS = SOURCE_FILES

filegroup(
name = "srcs",
srcs = SRCS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
]

# In this array place runtime dependencies, including other packages and NPM packages
# which must be available for this code to run.
#
# To reference other packages use:
# "//repo/relative/path/to/package"
# eg. "//packages/kbn-utils"
#
# To reference a NPM package use:
# "@npm//name-of-package"
# eg. "@npm//lodash"
RUNTIME_DEPS = [
"//packages/kbn-i18n",
"//packages/kbn-i18n-react",
"//packages/kbn-shared-ux-services",
"//packages/kbn-shared-ux-storybook",
"//packages/kbn-shared-ux-utility",
"@npm//react",
"@npm//@elastic/eui",
"@npm//@emotion/react",
"@npm//@emotion/css",
"@npm//classnames",
"@npm//@storybook/addon-actions",
]

# In this array place dependencies necessary to build the types, which will include the
# :npm_module_types target of other packages and packages from NPM, including @types/*
# packages.
#
# To reference the types for another package use:
# "//repo/relative/path/to/package:npm_module_types"
# eg. "//packages/kbn-utils:npm_module_types"
#
# References to NPM packages work the same as RUNTIME_DEPS
TYPES_DEPS = [
"//packages/kbn-i18n:npm_module_types",
"//packages/kbn-i18n-react:npm_module_types",
"//packages/kbn-shared-ux-services:npm_module_types",
"//packages/kbn-shared-ux-storybook:npm_module_types",
"//packages/kbn-shared-ux-utility:npm_module_types",
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/react",
"@npm//@elastic/eui",
"@npm//@emotion/react",
"@npm//@emotion/css",
"@npm//@storybook/addon-actions",
"@npm//@types/classnames",
]

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,
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"],
)
10 changes: 10 additions & 0 deletions packages/kbn-shared-ux-components/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
id: kibSharedUXComponents
slug: /kibana-dev-docs/shared-ux/packages/kbn-shared-ux-components
title: Shared UX Components
summary:
date: 2022-03-11
tags: ['kibana', 'dev', 'sharedUX']
---

> TODO
13 changes: 13 additions & 0 deletions packages/kbn-shared-ux-components/jest.config.js
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/kbn-shared-ux-components'],
};
8 changes: 8 additions & 0 deletions packages/kbn-shared-ux-components/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@kbn/shared-ux-components",
"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 @@ -10,7 +10,7 @@ import React from 'react';

import { EuiLoadingSpinner } from '@elastic/eui';

import { withSuspense } from '../../utility';
import { withSuspense } from '@kbn/shared-ux-utility';

export const LazyDataViewIllustration = React.lazy(() =>
import('../assets/data_view_illustration').then(({ DataViewIllustration }) => ({
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function DocumentationLink({ href }: Props) {
<EuiTitle size="xxs">
<dt className="eui-displayInline">
<FormattedMessage
id="sharedUX.noDataViews.learnMore"
id="sharedUXComponents.noDataViews.learnMore"
defaultMessage="Want to learn more?"
/>
</dt>
Expand All @@ -29,7 +29,7 @@ export function DocumentationLink({ href }: Props) {
<dd className="eui-displayInline">
<EuiLink href={href} target="_blank" external>
<FormattedMessage
id="sharedUX.noDataViews.readDocumentation"
id="sharedUXComponents.noDataViews.readDocumentation"
defaultMessage="Read the docs"
/>
</EuiLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface Props {
emptyPromptColor?: EuiEmptyPromptProps['color'];
}

const createDataViewText = i18n.translate('sharedUX.noDataViewsPage.addDataViewText', {
const createDataViewText = i18n.translate('sharedUXComponents.noDataViewsPage.addDataViewText', {
defaultMessage: 'Create Data View',
});

Expand Down Expand Up @@ -62,20 +62,20 @@ export const NoDataViews = ({
title={
<h2>
<FormattedMessage
id="sharedUX.noDataViews.youHaveData"
id="sharedUXComponents.noDataViews.youHaveData"
defaultMessage="You have data in Elasticsearch."
/>
<br />
<FormattedMessage
id="sharedUX.noDataViews.nowCreate"
id="sharedUXComponents.noDataViews.nowCreate"
defaultMessage="Now, create a data view."
/>
</h2>
}
body={
<p>
<FormattedMessage
id="sharedUX.noDataViews.dataViewExplanation"
id="sharedUXComponents.noDataViews.dataViewExplanation"
defaultMessage="Kibana requires a data view to identify which data streams,
indices, and index aliases you want to explore. A data view can point to a
specific index, for example, your log data from yesterday, or all indices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import React, { useCallback, useEffect, useRef } from 'react';
import { useEditors, usePermissions, useDocLinks } from '@kbn/shared-ux-services';
import type { SharedUxEditorsService } from '@kbn/shared-ux-services';

import { DataView } from '../../../../../data_views/public';

import { NoDataViews as NoDataViewsComponent } from './no_data_views.component';

export interface Props {
onDataViewCreated: (dataView: DataView) => void;
onDataViewCreated: (dataView: unknown) => void;
}

type CloseDataViewEditorFn = ReturnType<SharedUxEditorsService['openDataViewEditor']>;
Expand Down Expand Up @@ -60,7 +58,7 @@ export const NoDataViews = ({ onDataViewCreated }: Props) => {

const ref = openDataViewEditor({
onSave: (dataView) => {
onDataViewCreated(dataView as DataView);
onDataViewCreated(dataView);
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ import cx from 'classnames';

import './exit_full_screen_button.scss';

const text = i18n.translate('sharedUX.exitFullScreenButton.exitFullScreenModeButtonText', {
defaultMessage: 'Exit full screen',
});
const text = i18n.translate(
'sharedUXComponents.exitFullScreenButton.exitFullScreenModeButtonText',
{
defaultMessage: 'Exit full screen',
}
);

const description = i18n.translate('sharedUX.exitFullScreenButton.fullScreenModeDescription', {
defaultMessage: 'In full screen mode, press ESC to exit.',
});
const description = i18n.translate(
'sharedUXComponents.exitFullScreenButton.fullScreenModeDescription',
{
defaultMessage: 'In full screen mode, press ESC to exit.',
}
);

/**
* Props for the Exit Full Screen button component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React from 'react';
import { withSuspense } from './utility';
import { withSuspense } from '@kbn/shared-ux-utility';

/**
* The Lazily-loaded `ExitFullScreenButton` component. Consumers should use `React.Suspennse` or the
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* Side Public License, v 1.
*/

export { NoDataCard } from './no_data_page/no_data_card';
export { NoDataCard } from './no_data_page';
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@
* Side Public License, v 1.
*/

import { defaultConfig } from '@kbn/storybook';

module.exports = defaultConfig;
export { NoDataCard } from './no_data_card';
Loading

0 comments on commit 2976de7

Please sign in to comment.