Skip to content

Commit

Permalink
drilldowns
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Aug 5, 2020
1 parent c9c1372 commit 9192a0a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/plugins/embeddable/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface EnhancementRegistryItem {
input: Serializable;
references: SavedObjectReference[];
};
inject: (input: Serializable, references: SavedObjectReference[]) => Serializable;
inject: (input: any, references: SavedObjectReference[]) => Serializable;
}

export type EmbeddableFactoryProvider = <
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import {
} from '../../../../../../../src/plugins/dashboard/public';
import { CollectConfigContainer } from './components';
import { DASHBOARD_TO_DASHBOARD_DRILLDOWN } from './constants';
import { UiActionsEnhancedDrilldownDefinition as Drilldown } from '../../../../../ui_actions_enhanced/public';
import {
UiActionsEnhancedDrilldownDefinition as Drilldown,
SerializedEvent,
} from '../../../../../ui_actions_enhanced/public';
import { txtGoToDashboard } from './i18n';
import {
ApplyGlobalFilterActionContext,
Expand All @@ -24,6 +27,7 @@ import {
import { StartServicesGetter } from '../../../../../../../src/plugins/kibana_utils/public';
import { StartDependencies } from '../../../plugin';
import { Config } from './types';
import { SavedObjectReference } from '../../../../../../../src/core/types';

export interface Params {
start: StartServicesGetter<Pick<StartDependencies, 'data' | 'uiActionsEnhanced'>>;
Expand Down Expand Up @@ -116,4 +120,29 @@ export class DashboardToDashboardDrilldown

return this.params.getDashboardUrlGenerator().createUrl(state);
};

public migrate = (state: SerializedEvent) => state;

public extract = (state: SerializedEvent) => {
return {
references: [
{
id: `${state.id}-dashboardId`,
type: 'dashboard',
value: state.dashboardId,
},
],
state: {
...state,
dashboardId: `${state.id}-dashboardId`,
},
};
};

public inject = (state: SerializedEvent, references: SavedObjectReference[]) => {
return {
...state,
dashboardId: references.find((r) => r.id === `${state.id}-dashboardId`).value,
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { ActionFactoryDefinition } from '../dynamic_actions';
import { ActionFactoryDefinition, SerializedEvent } from '../dynamic_actions';
import { LicenseType } from '../../../licensing/public';
import { SavedObjectReference } from '../../../../../src/core/types';

/**
* This is a convenience interface to register a drilldown. Drilldown has
Expand Down Expand Up @@ -99,4 +100,8 @@ export interface DrilldownDefinition<
* A link where drilldown should navigate on middle click or Ctrl + click.
*/
getHref?(config: Config, context: ExecutionContext): Promise<string | undefined>;

migrate?(state: unknown): SerializedEvent;
extract?(state: SerializedEvent): { state: SerializedEvent; references: SavedObjectReference[] };
inject?(state: SerializedEvent, references: SavedObjectReference[]): SerializedEvent;
}

0 comments on commit 9192a0a

Please sign in to comment.