Skip to content

Commit

Permalink
Merge branch 'main' into cases_webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jul 26, 2022
2 parents 92672bf + 710432a commit b9a23fa
Show file tree
Hide file tree
Showing 66 changed files with 897 additions and 90 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@
"@kbn/flot-charts": "link:bazel-bin/packages/kbn-flot-charts",
"@kbn/handlebars": "link:bazel-bin/packages/kbn-handlebars",
"@kbn/hapi-mocks": "link:bazel-bin/packages/kbn-hapi-mocks",
"@kbn/home-sample-data-cards": "link:bazel-bin/packages/home/sample_data_cards",
"@kbn/home-sample-data-card": "link:bazel-bin/packages/home/sample_data_card",
"@kbn/home-sample-data-tab": "link:bazel-bin/packages/home/sample_data_tab",
"@kbn/home-sample-data-types": "link:bazel-bin/packages/home/sample_data_types",
"@kbn/i18n": "link:bazel-bin/packages/kbn-i18n",
"@kbn/i18n-react": "link:bazel-bin/packages/kbn-i18n-react",
"@kbn/interpreter": "link:bazel-bin/packages/kbn-interpreter",
Expand Down Expand Up @@ -857,7 +859,9 @@
"@types/kbn__get-repo-files": "link:bazel-bin/packages/kbn-get-repo-files/npm_module_types",
"@types/kbn__handlebars": "link:bazel-bin/packages/kbn-handlebars/npm_module_types",
"@types/kbn__hapi-mocks": "link:bazel-bin/packages/kbn-hapi-mocks/npm_module_types",
"@types/kbn__home-sample-data-cards": "link:bazel-bin/packages/home/sample_data_cards/npm_module_types",
"@types/kbn__home-sample-data-card": "link:bazel-bin/packages/home/sample_data_card/npm_module_types",
"@types/kbn__home-sample-data-tab": "link:bazel-bin/packages/home/sample_data_tab/npm_module_types",
"@types/kbn__home-sample-data-types": "link:bazel-bin/packages/home/sample_data_types/npm_module_types",
"@types/kbn__i18n": "link:bazel-bin/packages/kbn-i18n/npm_module_types",
"@types/kbn__i18n-react": "link:bazel-bin/packages/kbn-i18n-react/npm_module_types",
"@types/kbn__import-resolver": "link:bazel-bin/packages/kbn-import-resolver/npm_module_types",
Expand Down
7 changes: 5 additions & 2 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ filegroup(
"//packages/core/ui-settings/core-ui-settings-common:build",
"//packages/elastic-apm-synthtrace:build",
"//packages/elastic-safer-lodash-set:build",
"//packages/home/sample_data_cards:build",
"//packages/home/sample_data_card:build",
"//packages/home/sample_data_tab:build",
"//packages/home/sample_data_types:build",
"//packages/kbn-ace:build",
"//packages/kbn-alerts:build",
"//packages/kbn-ambient-storybook-types:build",
Expand Down Expand Up @@ -330,7 +332,8 @@ filegroup(
"//packages/core/ui-settings/core-ui-settings-common:build_types",
"//packages/elastic-apm-synthtrace:build_types",
"//packages/elastic-safer-lodash-set:build_types",
"//packages/home/sample_data_cards:build_types",
"//packages/home/sample_data_card:build_types",
"//packages/home/sample_data_tab:build_types",
"//packages/kbn-ace:build_types",
"//packages/kbn-alerts:build_types",
"//packages/kbn-analytics:build_types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ 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 = "sample_data_cards"
PKG_REQUIRE_NAME = "@kbn/home-sample-data-cards"
PKG_DIRNAME = "sample_data_card"
PKG_REQUIRE_NAME = "@kbn/home-sample-data-card"

SOURCE_FILES = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.mdx",
"src/**/*.svg",
"src/**/*.png",
],
exclude = [
"**/*.test.*",
Expand Down Expand Up @@ -67,6 +69,7 @@ TYPES_DEPS = [
"@npm//@types/react",
"//packages/kbn-ambient-ui-types",
"//packages/kbn-i18n:npm_module_types",
"//packages/home/sample_data_types",
]

jsts_transpiler(
Expand All @@ -80,6 +83,10 @@ jsts_transpiler(
srcs = SRCS,
build_pkg_name = package_name(),
web = True,
additional_args = [
"--copy-files",
"--quiet"
],
)

ts_config(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ This package contains a pair of components. The first displays a Sample Data Se

| Export | Description |
|---|---|
| `SampleDataCards` | Fetches and displays a grid of Sample Data Sets as `SampleDataCard` components. |
| `SampleDataCard` | Fetches and displays a grid of Sample Data Sets as `SampleDataCard` components. |
| `SampleDataCard` | A card component representing a Sample Data Set, which can install, uninstall and navigate relevant objects from a Sample Data Set. |
| `SampleDataCardsProvider` | Provides contextual services to `KibanaNoDataPage`. |
| `SampleDataCardsKibanaProvider` | Maps Kibana dependencies to provide contextual services to `KibanaNoDataPage`. |
| `SampleDataCardProvider` | Provides contextual services to `KibanaNoDataPage`. |
| `SampleDataCardKibanaProvider` | Maps Kibana dependencies to provide contextual services to `KibanaNoDataPage`. |

## EUI Promotion Status

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/packages/home/sample_data_cards'],
roots: ['<rootDir>/packages/home/sample_data_card'],
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@kbn/home-sample-data-cards",
"name": "@kbn/home-sample-data-card",
"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 { renderWithIntl } from '@kbn/test-jest-helpers';

import { DisabledFooter, Props } from './disabled_footer';
import { SampleDataCardsProvider } from '../services';
import { SampleDataCardProvider } from '../services';
import { getMockServices } from '../mocks';

describe('install footer', () => {
Expand All @@ -22,7 +22,7 @@ describe('install footer', () => {

const render = (element: React.ReactElement) =>
renderWithIntl(
<SampleDataCardsProvider {...getMockServices()}>{element}</SampleDataCardsProvider>
<SampleDataCardProvider {...getMockServices()}>{element}</SampleDataCardProvider>
);

test('should render', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import React from 'react';
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { SampleDataSet } from '../types';
import { SampleDataSet } from '@kbn/home-sample-data-types';

/**
* Props for the `DisabledFooter` component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import React from 'react';
import { ComponentMeta } from '@storybook/react';
import { action } from '@storybook/addon-actions';

import type { SampleDataSet } from '@kbn/home-sample-data-types';
import { Params, getStoryArgTypes, getStoryServices, mockDataSet } from '../mocks';
import { SampleDataCardsProvider } from '../services';
import { SampleDataCardProvider } from '../services';
import { Footer as Component } from '.';

import type { SampleDataSet } from '../types';

import mdx from '../../README.mdx';

export default {
Expand All @@ -41,9 +40,9 @@ export const CardFooter = (params: Params) => {
};

return (
<SampleDataCardsProvider {...getStoryServices(params)}>
<SampleDataCardProvider {...getStoryServices(params)}>
<Component sampleDataSet={sampleDataSet} onAction={action('onAction')} />
</SampleDataCardsProvider>
</SampleDataCardProvider>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/

import React from 'react';
import { SampleDataSet, InstalledStatus } from '@kbn/home-sample-data-types';
import { INSTALLED_STATUS, UNINSTALLED_STATUS } from '../constants';

import { SampleDataSet, InstalledStatus } from '../types';
import { DisabledFooter } from './disabled_footer';
import { InstallFooter } from './install_footer';
import { RemoveFooter } from './remove_footer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { renderWithIntl, mountWithIntl } from '@kbn/test-jest-helpers';
import { act } from 'react-dom/test-utils';

import { InstallFooter, Props } from './install_footer';
import { SampleDataCardsProvider, Services } from '../services';
import { SampleDataCardProvider, Services } from '../services';
import { getMockServices } from '../mocks';

describe('install footer', () => {
Expand All @@ -33,14 +33,14 @@ describe('install footer', () => {

const render = (element: React.ReactElement) =>
renderWithIntl(
<SampleDataCardsProvider {...getMockServices()}>{element}</SampleDataCardsProvider>
<SampleDataCardProvider {...getMockServices()}>{element}</SampleDataCardProvider>
);

const mount = (element: React.ReactElement, params?: Partial<Services>) =>
mountWithIntl(
<SampleDataCardsProvider {...getMockServices({ notifyError, notifySuccess, ...params })}>
<SampleDataCardProvider {...getMockServices({ notifyError, notifySuccess, ...params })}>
{element}
</SampleDataCardsProvider>
</SampleDataCardProvider>
);

test('should render', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import React from 'react';
import { EuiButton, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import type { SampleDataSet } from '@kbn/home-sample-data-types';
import { useInstall } from '../hooks';
import type { SampleDataSet } from '../types';
import type { UseInstallParams } from '../hooks';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { renderWithIntl, mountWithIntl } from '@kbn/test-jest-helpers';
import { act } from 'react-dom/test-utils';

import { RemoveFooter, Props } from './remove_footer';
import { SampleDataCardsProvider, Services } from '../services';
import { SampleDataCardProvider, Services } from '../services';
import { getMockServices } from '../mocks';

describe('install footer', () => {
Expand All @@ -35,14 +35,14 @@ describe('install footer', () => {

const render = (element: React.ReactElement) =>
renderWithIntl(
<SampleDataCardsProvider {...getMockServices()}>{element}</SampleDataCardsProvider>
<SampleDataCardProvider {...getMockServices()}>{element}</SampleDataCardProvider>
);

const mount = (element: React.ReactElement, params?: Partial<Services>) =>
mountWithIntl(
<SampleDataCardsProvider {...getMockServices({ notifyError, notifySuccess, ...params })}>
<SampleDataCardProvider {...getMockServices({ notifyError, notifySuccess, ...params })}>
{element}
</SampleDataCardsProvider>
</SampleDataCardProvider>
);

test('should render', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import React from 'react';
import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import type { SampleDataSet } from '@kbn/home-sample-data-types';
import { useRemove } from '../hooks';
import type { SampleDataSet } from '../types';
import { ViewButton } from './view_button';
import type { UseRemoveParams } from '../hooks';
import type { Props as ViewButtonProps } from './view_button';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import React from 'react';
import { renderWithIntl } from '@kbn/test-jest-helpers';

import { ViewButton } from './view_button';
import { SampleDataCardsProvider } from '../services';
import { SampleDataCardProvider } from '../services';
import { getMockServices } from '../mocks';

const render = (element: React.ReactElement) =>
renderWithIntl(
<SampleDataCardsProvider {...getMockServices()}>{element}</SampleDataCardsProvider>
);
renderWithIntl(<SampleDataCardProvider {...getMockServices()}>{element}</SampleDataCardProvider>);

test('should render simple button when appLinks is empty', () => {
const component = render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import type { SampleDataSet } from '@kbn/home-sample-data-types';
import { useServices } from '../services';
import type { SampleDataSet } from '../types';

/**
* Props for the `ViewButton` component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Side Public License, v 1.
*/

export { useList } from './use_list';

export { useInstall } from './use_install';
export type { Params as UseInstallParams } from './use_install';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import React, { useCallback } from 'react';
import { i18n } from '@kbn/i18n';

import type { SampleDataSet } from '@kbn/home-sample-data-types';
import { useServices } from '../services';
import type { SampleDataSet } from '../types';

/**
* Parameters for the `useInstall` React hook.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import React, { useCallback } from 'react';
import { i18n } from '@kbn/i18n';

import type { SampleDataSet } from '@kbn/home-sample-data-types';
import { useServices } from '../services';
import type { SampleDataSet } from '../types';

/**
* Parameters for the `useRemove` React hook.
Expand Down
24 changes: 24 additions & 0 deletions packages/home/sample_data_card/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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 { SampleDataCard } from './sample_data_card';
export type { Props as SampleDataCardProps } from './sample_data_card';

export { SampleDataCardKibanaProvider, SampleDataCardProvider } from './services';
export type {
Services as SampleDataCardServices,
KibanaDependencies as SampleDataCardKibanaDependencies,
} from './services';

// TODO: clintandrewhall - convert to new Storybook mock when published.
export {
getStoryArgTypes as getSampleDataCardStoryArgTypes,
getStoryServices as getSampleDataCardStoryServices,
getMockDataSet as getSampleDataCardMockDataSet,
} from './mocks';
export type { Params as SampleDataCardStorybookParams } from './mocks';
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

import { action } from '@storybook/addon-actions';

import { SampleDataSet } from '@kbn/home-sample-data-types';
import previewImagePath from './dashboard.png';
import darkPreviewImagePath from './dashboard_dark.png';
import iconPath from './icon.svg';

import { Services } from '../services';
import { SampleDataSet } from '../types';

/**
* A set of e-commerce images for use in Storybook stories.
Expand Down Expand Up @@ -57,7 +57,7 @@ export const getMockDataSet = (params: Partial<SampleDataSet> = {}) => ({
export type Params = Record<keyof ReturnType<typeof getStoryArgTypes>, any>;

/**
* Returns Storybook-compatible service abstractions for the `SampleDataCards` Provider.
* Returns Storybook-compatible service abstractions for the `SampleDataCard` Provider.
*/
export const getStoryServices = (params: Params) => {
const { simulateErrors } = params;
Expand All @@ -67,9 +67,6 @@ export const getStoryServices = (params: Params) => {
action('addBasePath')(path);
return path;
},
fetchSampleDataSets: async () => {
return [];
},
getAppNavigationHandler: (path) => () => action('getAppNavigationHandler')(path),
installSampleDataSet: async (id, defaultIndex) => {
if (simulateErrors) {
Expand All @@ -91,7 +88,7 @@ export const getStoryServices = (params: Params) => {
};

/**
* Returns the Storybook arguments for `SampleDataCards`, for its stories and for
* Returns the Storybook arguments for `SampleDataCard`, for its stories and for
* consuming component stories.
*/
export const getStoryArgTypes = () => ({
Expand Down Expand Up @@ -128,7 +125,6 @@ export const getStoryArgTypes = () => ({
export const getMockServices = (params: Partial<Services> = {}) => {
const services: Services = {
addBasePath: (path) => path,
fetchSampleDataSets: jest.fn(),
getAppNavigationHandler: jest.fn(),
installSampleDataSet: jest.fn(),
notifyError: jest.fn(),
Expand Down
Loading

0 comments on commit b9a23fa

Please sign in to comment.