* feat: 🎸 add ROW_CLICK_TRIGGER * feat: 🎸 wire row click event to UI Actions trigger in Lens * feat: 🎸 add row click trigger to url drilldown * feat: 🎸 add datatable to row click context * feat: 🎸 pass in row index in row click trigger context * feat: 🎸 add columns to row click trigger context * feat: 🎸 fill values and keys event scope array * feat: 🎸 generate correct row scope variables * fix: 🐛 report triggers from lens embeddable * feat: 🎸 add sample preview for row click trigger * feat: 🎸 remove url drilldown preview box * chore: 🤖 remove mock variable generation functions * feat: 🎸 generate context and global variable lists * feat: 🎸 preview event variable list * feat: 🎸 show empty url error on blur * feat: 🎸 add ability to always show popup for executed actions * refactor: 💡 rename multiple action execution method * fix: 🐛 don't add separator befor group on no main items * feat: 🎸 wire in uiActions service into datatable renderer * feat: 🎸 check each row if it has compatible row click actions * feat: 🎸 allow passing data to expression renderer * feat: 🎸 add isEmbeddable helper * feat: 🎸 pass embeddable to lens table renderer * feat: 🎸 hide lens table row actions which are empty * feat: 🎸 re-render lens embeddable when dynamic actions chagne * feat: 🎸 hide actions column if there are no row actions * feat: 🎸 re-render lens embeddable on view mode chagne * fix: 🐛 fix TypeScript errors * chore: 🤖 fix TypeScript errors * docs: ✏️ update auto-generated docs * feat: 🎸 add hasCompatibleActions to expression layer * feat: 🎸 remove "data" from expression renderer handlers * fix: 🐛 fix TypeScript errors * test: 💍 fix Jest tests * docs: ✏️ update autogenerated docs * fix: 🐛 wrap event payload into data * test: 💍 add "alwaysShowPopup" test * chore: 🤖 add comment requested in review https://github.com/elastic/kibana/pull/83167#discussion_r537340216 * test: 💍 add hasCompatibleActions test * test: 💍 add datatable renderer test * test: 💍 add Lens embeddable input change tests * test: 💍 add embeddable row click test * fix: 🐛 add url validation * test: 💍 add url drilldown tests * docs: ✏️ remove url drilldown preview from docs * docs: ✏️ remove preview from url templating * docs: ✏️ add row click description * chore: 🤖 move 36.5 KB bundle balance to url_drilldown * test: 💍 simplify test case * style: 💄 change types places * refactor: 💡 clean up panel variable generation * test: 💍 add getPanelVariables() tests * fix: 🐛 generate runtime variables correctly * fix: 🐛 improve getVariableList() and add tests for it * feat: 🎸 add translation, improve types
105 lines
3.2 KiB
TypeScript
105 lines
3.2 KiB
TypeScript
/*
|
|
* 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 { Capabilities, HttpSetup } from 'kibana/public';
|
|
import { i18n } from '@kbn/i18n';
|
|
import { RecursiveReadonly } from '@kbn/utility-types';
|
|
import { Ast } from '@kbn/interpreter/target/common';
|
|
import {
|
|
IndexPatternsContract,
|
|
TimefilterContract,
|
|
} from '../../../../../../src/plugins/data/public';
|
|
import { ReactExpressionRendererType } from '../../../../../../src/plugins/expressions/public';
|
|
import {
|
|
EmbeddableFactoryDefinition,
|
|
IContainer,
|
|
} from '../../../../../../src/plugins/embeddable/public';
|
|
import { LensByReferenceInput, LensEmbeddableInput } from './embeddable';
|
|
import { UiActionsStart } from '../../../../../../src/plugins/ui_actions/public';
|
|
import { Document } from '../../persistence/saved_object_store';
|
|
import { LensAttributeService } from '../../lens_attribute_service';
|
|
import { DOC_TYPE } from '../../../common';
|
|
|
|
export interface LensEmbeddableStartServices {
|
|
timefilter: TimefilterContract;
|
|
coreHttp: HttpSetup;
|
|
attributeService: LensAttributeService;
|
|
capabilities: RecursiveReadonly<Capabilities>;
|
|
expressionRenderer: ReactExpressionRendererType;
|
|
indexPatternService: IndexPatternsContract;
|
|
uiActions?: UiActionsStart;
|
|
documentToExpression: (doc: Document) => Promise<Ast | null>;
|
|
}
|
|
|
|
export class EmbeddableFactory implements EmbeddableFactoryDefinition {
|
|
type = DOC_TYPE;
|
|
savedObjectMetaData = {
|
|
name: i18n.translate('xpack.lens.lensSavedObjectLabel', {
|
|
defaultMessage: 'Lens Visualization',
|
|
}),
|
|
type: DOC_TYPE,
|
|
getIconForSavedObject: () => 'lensApp',
|
|
};
|
|
|
|
constructor(private getStartServices: () => Promise<LensEmbeddableStartServices>) {}
|
|
|
|
public isEditable = async () => {
|
|
const { capabilities } = await this.getStartServices();
|
|
return capabilities.visualize.save as boolean;
|
|
};
|
|
|
|
canCreateNew() {
|
|
return false;
|
|
}
|
|
|
|
getDisplayName() {
|
|
return i18n.translate('xpack.lens.embeddableDisplayName', {
|
|
defaultMessage: 'lens',
|
|
});
|
|
}
|
|
|
|
createFromSavedObject = async (
|
|
savedObjectId: string,
|
|
input: LensEmbeddableInput,
|
|
parent?: IContainer
|
|
) => {
|
|
if (!(input as LensByReferenceInput).savedObjectId) {
|
|
(input as LensByReferenceInput).savedObjectId = savedObjectId;
|
|
}
|
|
return this.create(input, parent);
|
|
};
|
|
|
|
async create(input: LensEmbeddableInput, parent?: IContainer) {
|
|
const {
|
|
timefilter,
|
|
expressionRenderer,
|
|
documentToExpression,
|
|
uiActions,
|
|
coreHttp,
|
|
attributeService,
|
|
indexPatternService,
|
|
} = await this.getStartServices();
|
|
|
|
const { Embeddable } = await import('../../async_services');
|
|
|
|
return new Embeddable(
|
|
{
|
|
attributeService,
|
|
indexPatternService,
|
|
timefilter,
|
|
expressionRenderer,
|
|
editable: await this.isEditable(),
|
|
basePath: coreHttp.basePath,
|
|
getTrigger: uiActions?.getTrigger,
|
|
getTriggerCompatibleActions: uiActions?.getTriggerCompatibleActions,
|
|
documentToExpression,
|
|
},
|
|
input,
|
|
parent
|
|
);
|
|
}
|
|
}
|