Skip to content

Commit

Permalink
Merge remote-tracking branch 'elastic' into tech-debt/rename_examples
Browse files Browse the repository at this point in the history
  • Loading branch information
clintandrewhall committed Aug 1, 2020
2 parents 1907c11 + 4f18f1d commit fdfcb0c
Show file tree
Hide file tree
Showing 51 changed files with 1,331 additions and 794 deletions.
1 change: 0 additions & 1 deletion src/plugins/embeddable/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"server": false,
"ui": true,
"requiredPlugins": [
"data",
"inspector",
"uiActions"
],
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/embeddable/public/mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ const createStartContract = (): Start => {
getAttributeService: jest.fn(),
getEmbeddablePanel: jest.fn(),
getStateTransfer: jest.fn(() => createEmbeddableStateTransferMock() as EmbeddableStateTransfer),
filtersAndTimeRangeFromContext: jest.fn(),
filtersFromContext: jest.fn(),
};
return startContract;
};
Expand Down
60 changes: 1 addition & 59 deletions src/plugins/embeddable/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
* under the License.
*/
import React from 'react';
import {
DataPublicPluginSetup,
DataPublicPluginStart,
Filter,
TimeRange,
esFilters,
} from '../../data/public';
import { DataPublicPluginSetup, DataPublicPluginStart } from '../../data/public';
import { getSavedObjectFinder } from '../../saved_objects/public';
import { UiActionsSetup, UiActionsStart } from '../../ui_actions/public';
import { Start as InspectorStart } from '../../inspector/public';
Expand All @@ -44,9 +38,6 @@ import {
IEmbeddable,
EmbeddablePanel,
SavedObjectEmbeddableInput,
ChartActionContext,
isRangeSelectTriggerContext,
isValueClickTriggerContext,
} from './lib';
import { EmbeddableFactoryDefinition } from './lib/embeddables/embeddable_factory_definition';
import { AttributeService } from './lib/embeddables/attribute_service';
Expand Down Expand Up @@ -92,18 +83,6 @@ export interface EmbeddableStart {
type: string
) => AttributeService<A, V, R>;

/**
* Given {@link ChartActionContext} returns a list of `data` plugin {@link Filter} entries.
*/
filtersFromContext: (context: ChartActionContext) => Promise<Filter[]>;

/**
* Returns possible time range and filters that can be constructed from {@link ChartActionContext} object.
*/
filtersAndTimeRangeFromContext: (
context: ChartActionContext
) => Promise<{ filters: Filter[]; timeRange?: TimeRange }>;

EmbeddablePanel: EmbeddablePanelHOC;
getEmbeddablePanel: (stateTransfer?: EmbeddableStateTransfer) => EmbeddablePanelHOC;
getStateTransfer: (history?: ScopedHistory) => EmbeddableStateTransfer;
Expand Down Expand Up @@ -155,41 +134,6 @@ export class EmbeddablePublicPlugin implements Plugin<EmbeddableSetup, Embeddabl
this.outgoingOnlyStateTransfer = new EmbeddableStateTransfer(core.application.navigateToApp);
this.isRegistryReady = true;

const filtersFromContext: EmbeddableStart['filtersFromContext'] = async (context) => {
try {
if (isRangeSelectTriggerContext(context))
return await data.actions.createFiltersFromRangeSelectAction(context.data);
if (isValueClickTriggerContext(context))
return await data.actions.createFiltersFromValueClickAction(context.data);
// eslint-disable-next-line no-console
console.warn("Can't extract filters from action.", context);
} catch (error) {
// eslint-disable-next-line no-console
console.warn('Error extracting filters from action. Returning empty filter list.', error);
}
return [];
};

const filtersAndTimeRangeFromContext: EmbeddableStart['filtersAndTimeRangeFromContext'] = async (
context
) => {
const filters = await filtersFromContext(context);

if (!context.data.timeFieldName) return { filters };

const { timeRangeFilter, restOfFilters } = esFilters.extractTimeFilter(
context.data.timeFieldName,
filters
);

return {
filters: restOfFilters,
timeRange: timeRangeFilter
? esFilters.convertRangeFilterToTimeRangeString(timeRangeFilter)
: undefined,
};
};

const getEmbeddablePanelHoc = (stateTransfer?: EmbeddableStateTransfer) => ({
embeddable,
hideHeader,
Expand All @@ -216,8 +160,6 @@ export class EmbeddablePublicPlugin implements Plugin<EmbeddableSetup, Embeddabl
getEmbeddableFactory: this.getEmbeddableFactory,
getEmbeddableFactories: this.getEmbeddableFactories,
getAttributeService: (type: string) => new AttributeService(type, core.savedObjects.client),
filtersFromContext,
filtersAndTimeRangeFromContext,
getStateTransfer: (history?: ScopedHistory) => {
return history
? new EmbeddableStateTransfer(core.application.navigateToApp, history)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ import { Trigger } from '.';
export const APPLY_FILTER_TRIGGER = 'FILTER_TRIGGER';
export const applyFilterTrigger: Trigger<'FILTER_TRIGGER'> = {
id: APPLY_FILTER_TRIGGER,
title: 'Filter click',
title: 'Apply filter',
description: 'Triggered when user applies filter to an embeddable.',
};
5 changes: 4 additions & 1 deletion x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@types/hoist-non-react-statics": "^3.3.1",
"@types/history": "^4.7.3",
"@types/jest": "^25.2.3",
"@types/jest-specific-snapshot": "^0.5.4",
"@types/joi": "^13.4.2",
"@types/js-search": "^1.4.0",
"@types/js-yaml": "^3.11.1",
Expand Down Expand Up @@ -119,6 +120,7 @@
"@types/xml2js": "^0.4.5",
"@types/stats-lite": "^2.2.0",
"@types/pretty-ms": "^5.0.0",
"@types/webpack-env": "^1.15.2",
"@welldone-software/why-did-you-render": "^4.0.0",
"abab": "^1.0.4",
"autoprefixer": "^9.7.4",
Expand Down Expand Up @@ -158,6 +160,7 @@
"jest-cli": "^25.5.4",
"jest-styled-components": "^7.0.2",
"jsdom": "13.1.0",
"jsondiffpatch": "0.4.1",
"loader-utils": "^1.2.3",
"madge": "3.4.4",
"marge": "^1.0.1",
Expand Down Expand Up @@ -394,4 +397,4 @@
"cypress-multi-reporters"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react';
import React from 'react';
import { reduxDecorator, getAddonPanelParameters } from '../../../../storybook';
import { Asset, AssetComponent } from '../';
import { AIRPLANE, MARKER, assets } from './assets';

storiesOf('components/Assets/Asset', module)
.addDecorator((story) => <div style={{ width: '215px' }}>{story()}</div>)
.addDecorator(reduxDecorator({ assets }))
.addParameters(getAddonPanelParameters())
.add('redux: Asset', () => {
return <Asset asset={AIRPLANE} />;
})
.add('airplane', () => (
<AssetComponent asset={AIRPLANE} onCreate={action('onCreate')} onDelete={action('onDelete')} />
))
.add('marker', () => (
<AssetComponent asset={MARKER} onCreate={action('onCreate')} onDelete={action('onDelete')} />
));
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,29 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react';
import React from 'react';
import { reduxDecorator, getAddonPanelParameters } from '../../../../storybook';

import { AssetManager, AssetManagerComponent } from '../';

import { Provider, AIRPLANE, MARKER } from './provider';
import { assets } from './assets';

storiesOf('components/Assets/AssetManager', module)
.add('redux: AssetManager', () => (
<Provider>
<AssetManager onClose={action('onClose')} />
</Provider>
))
.addDecorator(reduxDecorator({ assets }))
.addParameters(getAddonPanelParameters())
.add('redux: AssetManager', () => <AssetManager onClose={action('onClose')} />)
.add('no assets', () => (
<Provider>
<AssetManagerComponent
assets={[]}
onClose={action('onClose')}
onAddAsset={action('onAddAsset')}
/>
</Provider>
<AssetManagerComponent
assets={[]}
onClose={action('onClose')}
onAddAsset={action('onAddAsset')}
/>
))
.add('two assets', () => (
<Provider>
<AssetManagerComponent
assets={[AIRPLANE, MARKER]}
onClose={action('onClose')}
onAddAsset={action('onAddAsset')}
/>
</Provider>
<AssetManagerComponent
assets={assets}
onClose={action('onClose')}
onAddAsset={action('onAddAsset')}
/>
));
Original file line number Diff line number Diff line change
@@ -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;
* you may not use this file except in compliance with the Elastic License.
*/

import { AssetType } from '../../../../types';

export const AIRPLANE: AssetType = {
'@created': '2018-10-13T16:44:44.648Z',
id: 'airplane',
type: 'dataurl',
value:
'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1Ni4zMSA1Ni4zMSI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7c3Ryb2tlOiMwMDc4YTA7c3Ryb2tlLW1pdGVybGltaXQ6MTA7c3Ryb2tlLXdpZHRoOjJweDt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlBsYW5lIEljb248L3RpdGxlPjxnIGlkPSJMYXllcl8yIiBkYXRhLW5hbWU9IkxheWVyIDIiPjxnIGlkPSJMYXllcl8xLTIiIGRhdGEtbmFtZT0iTGF5ZXIgMSI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDkuNTEsNDguOTMsNDEuMjYsMjIuNTIsNTMuNzYsMTBhNS4yOSw1LjI5LDAsMCwwLTcuNDgtNy40N2wtMTIuNSwxMi41TDcuMzgsNi43OUEuNy43LDAsMCwwLDYuNjksN0wxLjIsMTIuNDVhLjcuNywwLDAsMCwwLDFMMTkuODUsMjlsLTcuMjQsNy4yNC03Ljc0LS42YS43MS43MSwwLDAsMC0uNTMuMkwxLjIxLDM5YS42Ny42NywwLDAsMCwuMDgsMUw5LjQ1LDQ2bC4wNywwYy4xMS4xMy4yMi4yNi4zNC4zOHMuMjUuMjMuMzguMzRhLjM2LjM2LDAsMCwwLDAsLjA3TDE2LjMzLDU1YS42OC42OCwwLDAsMCwxLC4wN0wyMC40OSw1MmEuNjcuNjcsMCwwLDAsLjE5LS41NGwtLjU5LTcuNzQsNy4yNC03LjI0TDQyLjg1LDU1LjA2YS42OC42OCwwLDAsMCwxLDBsNS41LTUuNUEuNjYuNjYsMCwwLDAsNDkuNTEsNDguOTNaIi8+PC9nPjwvZz48L3N2Zz4=',
};

export const MARKER: AssetType = {
'@created': '2018-10-13T16:44:44.648Z',
id: 'marker',
type: 'dataurl',
value:
'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOC4zOSA1Ny41NyI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7c3Ryb2tlOiMwMTliOGY7c3Ryb2tlLW1pdGVybGltaXQ6MTA7c3Ryb2tlLXdpZHRoOjJweDt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkxvY2F0aW9uIEljb248L3RpdGxlPjxnIGlkPSJMYXllcl8yIiBkYXRhLW5hbWU9IkxheWVyIDIiPjxnIGlkPSJMYXllcl8xLTIiIGRhdGEtbmFtZT0iTGF5ZXIgMSI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMTkuMTksMUExOC4xOSwxOC4xOSwwLDAsMCwyLjk0LDI3LjM2aDBhMTkuNTEsMTkuNTEsMCwwLDAsMSwxLjc4TDE5LjE5LDU1LjU3LDM0LjM4LDI5LjIxQTE4LjE5LDE4LjE5LDAsMCwwLDE5LjE5LDFabTAsMjMuMjlhNS41Myw1LjUzLDAsMSwxLDUuNTMtNS41M0E1LjUzLDUuNTMsMCwwLDEsMTkuMTksMjQuMjlaIi8+PC9nPjwvZz48L3N2Zz4=',
};

export const assets = [AIRPLANE, MARKER];

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
EuiToolTip,
} from '@elastic/eui';

import { useKibana } from '../../../../../../src/plugins/kibana_react/public';
import { useNotifyService } from '../../services';

import { ConfirmModal } from '../confirm_modal';
import { Clipboard } from '../clipboard';
Expand All @@ -38,11 +38,10 @@ interface Props {
}

export const Asset: FC<Props> = ({ asset, onCreate, onDelete }) => {
const { services } = useKibana();
const { success } = useNotifyService();
const [isConfirmModalVisible, setIsConfirmModalVisible] = useState(false);

const onCopy = (result: boolean) =>
result && services.canvas.notify.success(`Copied '${asset.id}' to clipboard`);
const onCopy = (result: boolean) => result && success(`Copied '${asset.id}' to clipboard`);

const confirmModal = (
<ConfirmModal
Expand Down
6 changes: 1 addition & 5 deletions x-pack/plugins/canvas/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,4 @@ export interface WithKibanaProps {
};
}

export interface UseKibanaProps {
canvas: CanvasServices;
}

export const plugin = (initializerContext: PluginInitializerContext) => new CanvasPlugin();
export const plugin = (_initializerContext: PluginInitializerContext) => new CanvasPlugin();
Loading

0 comments on commit fdfcb0c

Please sign in to comment.