Skip to content

Commit

Permalink
Merge branch 'master' into incremental-without-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Mar 31, 2021
2 parents e7a00fc + 5f48729 commit d9fdd3f
Show file tree
Hide file tree
Showing 82 changed files with 639 additions and 765 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [AggFunctionsMapping](./kibana-plugin-plugins-data-public.aggfunctionsmapping.md) &gt; [aggSinglePercentile](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsinglepercentile.md)

## AggFunctionsMapping.aggSinglePercentile property

<b>Signature:</b>

```typescript
aggSinglePercentile: ReturnType<typeof aggSinglePercentile>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface AggFunctionsMapping
| [aggRange](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggrange.md) | <code>ReturnType&lt;typeof aggRange&gt;</code> | |
| [aggSerialDiff](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggserialdiff.md) | <code>ReturnType&lt;typeof aggSerialDiff&gt;</code> | |
| [aggSignificantTerms](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsignificantterms.md) | <code>ReturnType&lt;typeof aggSignificantTerms&gt;</code> | |
| [aggSinglePercentile](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsinglepercentile.md) | <code>ReturnType&lt;typeof aggSinglePercentile&gt;</code> | |
| [aggStdDeviation](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggstddeviation.md) | <code>ReturnType&lt;typeof aggStdDeviation&gt;</code> | |
| [aggSum](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggsum.md) | <code>ReturnType&lt;typeof aggSum&gt;</code> | |
| [aggTerms](./kibana-plugin-plugins-data-public.aggfunctionsmapping.aggterms.md) | <code>ReturnType&lt;typeof aggTerms&gt;</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export declare enum METRIC_TYPES
| PERCENTILE\_RANKS | <code>&quot;percentile_ranks&quot;</code> | |
| PERCENTILES | <code>&quot;percentiles&quot;</code> | |
| SERIAL\_DIFF | <code>&quot;serial_diff&quot;</code> | |
| SINGLE\_PERCENTILE | <code>&quot;single_percentile&quot;</code> | |
| STD\_DEV | <code>&quot;std_dev&quot;</code> | |
| SUM | <code>&quot;sum&quot;</code> | |
| SUM\_BUCKET | <code>&quot;sum_bucket&quot;</code> | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) &gt; [aggSinglePercentile](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsinglepercentile.md)

## AggFunctionsMapping.aggSinglePercentile property

<b>Signature:</b>

```typescript
aggSinglePercentile: ReturnType<typeof aggSinglePercentile>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface AggFunctionsMapping
| [aggRange](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggrange.md) | <code>ReturnType&lt;typeof aggRange&gt;</code> | |
| [aggSerialDiff](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggserialdiff.md) | <code>ReturnType&lt;typeof aggSerialDiff&gt;</code> | |
| [aggSignificantTerms](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsignificantterms.md) | <code>ReturnType&lt;typeof aggSignificantTerms&gt;</code> | |
| [aggSinglePercentile](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsinglepercentile.md) | <code>ReturnType&lt;typeof aggSinglePercentile&gt;</code> | |
| [aggStdDeviation](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggstddeviation.md) | <code>ReturnType&lt;typeof aggStdDeviation&gt;</code> | |
| [aggSum](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggsum.md) | <code>ReturnType&lt;typeof aggSum&gt;</code> | |
| [aggTerms](./kibana-plugin-plugins-data-server.aggfunctionsmapping.aggterms.md) | <code>ReturnType&lt;typeof aggTerms&gt;</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export declare enum METRIC_TYPES
| PERCENTILE\_RANKS | <code>&quot;percentile_ranks&quot;</code> | |
| PERCENTILES | <code>&quot;percentiles&quot;</code> | |
| SERIAL\_DIFF | <code>&quot;serial_diff&quot;</code> | |
| SINGLE\_PERCENTILE | <code>&quot;single_percentile&quot;</code> | |
| STD\_DEV | <code>&quot;std_dev&quot;</code> | |
| SUM | <code>&quot;sum&quot;</code> | |
| SUM\_BUCKET | <code>&quot;sum_bucket&quot;</code> | |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"dependencies": {
"@elastic/apm-rum": "^5.6.1",
"@elastic/apm-rum-react": "^1.2.5",
"@elastic/charts": "26.0.0",
"@elastic/charts": "26.1.0",
"@elastic/datemath": "link:packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.4",
"@elastic/ems-client": "7.12.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,8 @@ const start = doStart();
let container: DashboardContainer;
let embeddable: ContactCardEmbeddable & ReferenceOrValueEmbeddable;
let coreStart: CoreStart;
let capabilities: CoreStart['application']['capabilities'];

beforeEach(async () => {
coreStart = coreMock.createStart();
capabilities = {
...coreStart.application.capabilities,
visualize: { save: true },
maps: { save: true },
};

const containerOptions = {
ExitFullScreenButton: () => null,
Expand Down Expand Up @@ -90,10 +83,7 @@ beforeEach(async () => {
});

test('Add to library is incompatible with Error Embeddables', async () => {
const action = new AddToLibraryAction({
toasts: coreStart.notifications.toasts,
capabilities,
});
const action = new AddToLibraryAction({ toasts: coreStart.notifications.toasts });
const errorEmbeddable = new ErrorEmbeddable(
'Wow what an awful error',
{ id: ' 404' },
Expand All @@ -102,37 +92,20 @@ test('Add to library is incompatible with Error Embeddables', async () => {
expect(await action.isCompatible({ embeddable: errorEmbeddable })).toBe(false);
});

test('Add to library is incompatible on visualize embeddable without visualize save permissions', async () => {
const action = new AddToLibraryAction({
toasts: coreStart.notifications.toasts,
capabilities: { ...capabilities, visualize: { save: false } },
});
expect(await action.isCompatible({ embeddable })).toBe(false);
});

test('Add to library is compatible when embeddable on dashboard has value type input', async () => {
const action = new AddToLibraryAction({
toasts: coreStart.notifications.toasts,
capabilities,
});
const action = new AddToLibraryAction({ toasts: coreStart.notifications.toasts });
embeddable.updateInput(await embeddable.getInputAsValueType());
expect(await action.isCompatible({ embeddable })).toBe(true);
});

test('Add to library is not compatible when embeddable input is by reference', async () => {
const action = new AddToLibraryAction({
toasts: coreStart.notifications.toasts,
capabilities,
});
const action = new AddToLibraryAction({ toasts: coreStart.notifications.toasts });
embeddable.updateInput(await embeddable.getInputAsRefType());
expect(await action.isCompatible({ embeddable })).toBe(false);
});

test('Add to library is not compatible when view mode is set to view', async () => {
const action = new AddToLibraryAction({
toasts: coreStart.notifications.toasts,
capabilities,
});
const action = new AddToLibraryAction({ toasts: coreStart.notifications.toasts });
embeddable.updateInput(await embeddable.getInputAsRefType());
embeddable.updateInput({ viewMode: ViewMode.VIEW });
expect(await action.isCompatible({ embeddable })).toBe(false);
Expand All @@ -153,10 +126,7 @@ test('Add to library is not compatible when embeddable is not in a dashboard con
mockedByReferenceInput: { savedObjectId: 'test', id: orphanContactCard.id },
mockedByValueInput: { firstName: 'Kibanana', id: orphanContactCard.id },
});
const action = new AddToLibraryAction({
toasts: coreStart.notifications.toasts,
capabilities,
});
const action = new AddToLibraryAction({ toasts: coreStart.notifications.toasts });
expect(await action.isCompatible({ embeddable: orphanContactCard })).toBe(false);
});

Expand All @@ -165,10 +135,7 @@ test('Add to library replaces embeddableId and retains panel count', async () =>
const originalPanelCount = Object.keys(dashboard.getInput().panels).length;
const originalPanelKeySet = new Set(Object.keys(dashboard.getInput().panels));

const action = new AddToLibraryAction({
toasts: coreStart.notifications.toasts,
capabilities,
});
const action = new AddToLibraryAction({ toasts: coreStart.notifications.toasts });
await action.execute({ embeddable });
expect(Object.keys(container.getInput().panels).length).toEqual(originalPanelCount);

Expand All @@ -194,10 +161,7 @@ test('Add to library returns reference type input', async () => {
});
const dashboard = embeddable.getRoot() as IContainer;
const originalPanelKeySet = new Set(Object.keys(dashboard.getInput().panels));
const action = new AddToLibraryAction({
toasts: coreStart.notifications.toasts,
capabilities,
});
const action = new AddToLibraryAction({ toasts: coreStart.notifications.toasts });
await action.execute({ embeddable });
const newPanelId = Object.keys(container.getInput().panels).find(
(key) => !originalPanelKeySet.has(key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
isReferenceOrValueEmbeddable,
isErrorEmbeddable,
} from '../../services/embeddable';
import { ApplicationStart, NotificationsStart } from '../../services/core';
import { NotificationsStart } from '../../services/core';
import { dashboardAddToLibraryAction } from '../../dashboard_strings';
import { DashboardPanelState, DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '..';

Expand All @@ -33,12 +33,7 @@ export class AddToLibraryAction implements Action<AddToLibraryActionContext> {
public readonly id = ACTION_ADD_TO_LIBRARY;
public order = 15;

constructor(
private deps: {
toasts: NotificationsStart['toasts'];
capabilities: ApplicationStart['capabilities'];
}
) {}
constructor(private deps: { toasts: NotificationsStart['toasts'] }) {}

public getDisplayName({ embeddable }: AddToLibraryActionContext) {
if (!embeddable.getRoot() || !embeddable.getRoot().isContainer) {
Expand All @@ -55,15 +50,8 @@ export class AddToLibraryAction implements Action<AddToLibraryActionContext> {
}

public async isCompatible({ embeddable }: AddToLibraryActionContext) {
// TODO: Fix this, potentially by adding a 'canSave' function to embeddable interface
const canSave =
embeddable.type === 'map'
? this.deps.capabilities.maps?.save
: this.deps.capabilities.visualize.save;

return Boolean(
canSave &&
!isErrorEmbeddable(embeddable) &&
!isErrorEmbeddable(embeddable) &&
embeddable.getInput()?.viewMode !== ViewMode.VIEW &&
embeddable.getRoot() &&
embeddable.getRoot().isContainer &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export class ClonePanelAction implements Action<ClonePanelActionContext> {
embeddable.getInput()?.viewMode !== ViewMode.VIEW &&
embeddable.getRoot() &&
embeddable.getRoot().isContainer &&
embeddable.getRoot().type === DASHBOARD_CONTAINER_TYPE &&
embeddable.getOutput().editable
embeddable.getRoot().type === DASHBOARD_CONTAINER_TYPE
);
}

Expand Down
11 changes: 4 additions & 7 deletions src/plugins/dashboard/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export class DashboardPlugin
}

public start(core: CoreStart, plugins: DashboardStartDependencies): DashboardStart {
const { notifications, overlays, application } = core;
const { notifications, overlays } = core;
const { uiActions, data, share, presentationUtil, embeddable } = plugins;

const SavedObjectFinder = getSavedObjectFinder(core.savedObjects, core.uiSettings);
Expand Down Expand Up @@ -370,10 +370,7 @@ export class DashboardPlugin
}

if (this.dashboardFeatureFlagConfig?.allowByValueEmbeddables) {
const addToLibraryAction = new AddToLibraryAction({
toasts: notifications.toasts,
capabilities: application.capabilities,
});
const addToLibraryAction = new AddToLibraryAction({ toasts: notifications.toasts });
uiActions.registerAction(addToLibraryAction);
uiActions.attachAction(CONTEXT_MENU_TRIGGER, addToLibraryAction.id);

Expand All @@ -389,8 +386,8 @@ export class DashboardPlugin
overlays,
embeddable.getStateTransfer(),
{
canCreateNew: Boolean(application.capabilities.dashboard.createNew),
canEditExisting: !Boolean(application.capabilities.dashboard.hideWriteControls),
canCreateNew: Boolean(core.application.capabilities.dashboard.createNew),
canEditExisting: !Boolean(core.application.capabilities.dashboard.hideWriteControls),
},
presentationUtil.ContextProvider
);
Expand Down
1 change: 0 additions & 1 deletion src/plugins/dashboard/public/services/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ export {
PluginInitializerContext,
ScopedHistory,
NotificationsStart,
ApplicationStart,
} from '../../../../core/public';
2 changes: 2 additions & 0 deletions src/plugins/data/common/search/aggs/agg_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const getAggTypes = () => ({
{ name: METRIC_TYPES.AVG, fn: metrics.getAvgMetricAgg },
{ name: METRIC_TYPES.SUM, fn: metrics.getSumMetricAgg },
{ name: METRIC_TYPES.MEDIAN, fn: metrics.getMedianMetricAgg },
{ name: METRIC_TYPES.SINGLE_PERCENTILE, fn: metrics.getSinglePercentileMetricAgg },
{ name: METRIC_TYPES.MIN, fn: metrics.getMinMetricAgg },
{ name: METRIC_TYPES.MAX, fn: metrics.getMaxMetricAgg },
{ name: METRIC_TYPES.STD_DEV, fn: metrics.getStdDeviationMetricAgg },
Expand Down Expand Up @@ -90,6 +91,7 @@ export const getAggTypesFunctions = () => [
metrics.aggGeoCentroid,
metrics.aggMax,
metrics.aggMedian,
metrics.aggSinglePercentile,
metrics.aggMin,
metrics.aggMovingAvg,
metrics.aggPercentileRanks,
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data/common/search/aggs/aggs_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ describe('Aggs service', () => {
"avg",
"sum",
"median",
"single_percentile",
"min",
"max",
"std_dev",
Expand Down Expand Up @@ -128,6 +129,7 @@ describe('Aggs service', () => {
"avg",
"sum",
"median",
"single_percentile",
"min",
"max",
"std_dev",
Expand Down

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

2 changes: 2 additions & 0 deletions src/plugins/data/common/search/aggs/metrics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export * from './max_fn';
export * from './max';
export * from './median_fn';
export * from './median';
export * from './single_percentile_fn';
export * from './single_percentile';
export * from './metric_agg_type';
export * from './metric_agg_types';
export * from './min_fn';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const metricAggFilter = [
'!geo_bounds',
'!geo_centroid',
'!filtered_metric',
'!single_percentile',
];

export const parentPipelineType = i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const metricAggFilter: string[] = [
'!geo_bounds',
'!geo_centroid',
'!filtered_metric',
'!single_percentile',
];
const bucketAggFilter: string[] = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum METRIC_TYPES {
GEO_BOUNDS = 'geo_bounds',
GEO_CENTROID = 'geo_centroid',
MEDIAN = 'median',
SINGLE_PERCENTILE = 'single_percentile',
MIN = 'min',
MAX = 'max',
MOVING_FN = 'moving_avg',
Expand Down
Loading

0 comments on commit d9fdd3f

Please sign in to comment.