From c5e0097106f6e11e0afd81e10eeab49ab75a23a8 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Fri, 18 Sep 2020 14:27:17 +0200 Subject: [PATCH 1/9] config to disable url drilldown --- docs/user/dashboard/url-drilldown.asciidoc | 11 ++++ .../public/service/ui_actions_service.ts | 4 ++ .../url_drilldown/README.asciidoc} | 17 +++--- .../drilldowns/url_drilldown/kibana.json | 8 +++ .../url_drilldown/public}/index.ts | 7 ++- .../url_drilldown/public/lib}/i18n.ts | 2 +- .../url_drilldown/public/lib}/index.ts | 0 .../public/lib}/url_drilldown.test.ts | 0 .../public/lib}/url_drilldown.tsx | 0 .../public/lib}/url_drilldown_scope.test.ts | 0 .../public/lib}/url_drilldown_scope.ts | 0 .../drilldowns/url_drilldown/public/plugin.ts | 59 +++++++++++++++++++ .../plugins/embeddable_enhanced/kibana.json | 3 +- .../embeddable_enhanced/public/plugin.ts | 16 ----- .../dynamic_action_manager.test.ts | 17 +++++- .../dynamic_actions/dynamic_action_manager.ts | 31 +++++++++- .../ui_actions_enhanced/public/plugin.ts | 5 +- .../ui_actions_service_enhancements.ts | 4 ++ 18 files changed, 151 insertions(+), 33 deletions(-) rename x-pack/plugins/{embeddable_enhanced/public/drilldowns/url_drilldown/README.md => drilldowns/url_drilldown/README.asciidoc} (74%) create mode 100644 x-pack/plugins/drilldowns/url_drilldown/kibana.json rename x-pack/plugins/{embeddable_enhanced/public/drilldowns => drilldowns/url_drilldown/public}/index.ts (53%) rename x-pack/plugins/{embeddable_enhanced/public/drilldowns/url_drilldown => drilldowns/url_drilldown/public/lib}/i18n.ts (85%) rename x-pack/plugins/{embeddable_enhanced/public/drilldowns/url_drilldown => drilldowns/url_drilldown/public/lib}/index.ts (100%) rename x-pack/plugins/{embeddable_enhanced/public/drilldowns/url_drilldown => drilldowns/url_drilldown/public/lib}/url_drilldown.test.ts (100%) rename x-pack/plugins/{embeddable_enhanced/public/drilldowns/url_drilldown => drilldowns/url_drilldown/public/lib}/url_drilldown.tsx (100%) rename x-pack/plugins/{embeddable_enhanced/public/drilldowns/url_drilldown => drilldowns/url_drilldown/public/lib}/url_drilldown_scope.test.ts (100%) rename x-pack/plugins/{embeddable_enhanced/public/drilldowns/url_drilldown => drilldowns/url_drilldown/public/lib}/url_drilldown_scope.ts (100%) create mode 100644 x-pack/plugins/drilldowns/url_drilldown/public/plugin.ts diff --git a/docs/user/dashboard/url-drilldown.asciidoc b/docs/user/dashboard/url-drilldown.asciidoc index e6daf89d727183..801fef1649511a 100644 --- a/docs/user/dashboard/url-drilldown.asciidoc +++ b/docs/user/dashboard/url-drilldown.asciidoc @@ -238,3 +238,14 @@ Tip: Consider using <> helper for date formatting. | Aggregation field behind the selected range, if available. |=== + +[float] +[[variables]] +==== Disable URL drilldown + +You can disable URL drilldown feature on your {kib} instance by disabling `urlDrilldown` plugin: + +["source","yml"] +----------- +url_drilldown.enabled: false +----------- diff --git a/src/plugins/ui_actions/public/service/ui_actions_service.ts b/src/plugins/ui_actions/public/service/ui_actions_service.ts index 6028177964fb77..ec5f3afa19c943 100644 --- a/src/plugins/ui_actions/public/service/ui_actions_service.ts +++ b/src/plugins/ui_actions/public/service/ui_actions_service.ts @@ -99,6 +99,10 @@ export class UiActionsService { this.actions.delete(actionId); }; + public readonly hasAction = (actionId: string): boolean => { + return this.actions.has(actionId); + }; + public readonly attachAction = (triggerId: T, actionId: string): void => { const trigger = this.triggers.get(triggerId); diff --git a/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/README.md b/x-pack/plugins/drilldowns/url_drilldown/README.asciidoc similarity index 74% rename from x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/README.md rename to x-pack/plugins/drilldowns/url_drilldown/README.asciidoc index 996723ccb914d9..d33fc3cb141db8 100644 --- a/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/README.md +++ b/x-pack/plugins/drilldowns/url_drilldown/README.asciidoc @@ -1,24 +1,27 @@ -# Basic url drilldown implementation +[[url-drilldown]] +== URL drilldown + +NOTE: This plugin contains implementation of URL drilldown. For drilldowns infrastructure code refer to `ui_actions_enhanced` plugin. Url drilldown allows navigating to external URL or to internal kibana URL. By using variables in url template result url can be dynamic and depend on user's interaction. URL drilldown has 3 sources for variables: -- Global static variables like, for example, `kibanaUrl`. Such variables won’t change depending on a place where url drilldown is used. -- Context variables are dynamic and different depending on where drilldown is created and used. -- Event variables depend on a trigger context. These variables are dynamically extracted from the action context when drilldown is executed. +* Global static variables like, for example, `kibanaUrl`. Such variables won’t change depending on a place where url drilldown is used. +* Context variables are dynamic and different depending on where drilldown is created and used. +* Event variables depend on a trigger context. These variables are dynamically extracted from the action context when drilldown is executed. Difference between `event` and `context` variables, is that real `context` variables are available during drilldown creation (e.g. embeddable panel), but `event` variables mapped from trigger context. Since there is no trigger context during drilldown creation, we have to provide some _mock_ variables for validating and previewing the URL. In current implementation url drilldown has to be used inside the embeddable and with `ValueClickTrigger` or `RangeSelectTrigger`. -- `context` variables extracted from `embeddable` -- `event` variables extracted from `trigger` context +* `context` variables extracted from `embeddable` +* `event` variables extracted from `trigger` context In future this basic url drilldown implementation would allow injecting more variables into `context` (e.g. `dashboard` app specific variables) and would allow providing support for new trigger types from outside. This extensibility improvements are tracked here: https://github.com/elastic/kibana/issues/55324 In case a solution app has a use case for url drilldown that has to be different from current basic implementation and -just extending variables list is not enough, then recommendation is to create own custom url drilldown and reuse building blocks from `ui_actions_enhanced`. +just extending variables list is not enough, then recommendation is to create own custom url drilldown and reuse building blocks from `ui_actions_enhanced`. \ No newline at end of file diff --git a/x-pack/plugins/drilldowns/url_drilldown/kibana.json b/x-pack/plugins/drilldowns/url_drilldown/kibana.json new file mode 100644 index 00000000000000..9bdd13fbfea26d --- /dev/null +++ b/x-pack/plugins/drilldowns/url_drilldown/kibana.json @@ -0,0 +1,8 @@ +{ + "id": "urlDrilldown", + "version": "kibana", + "server": false, + "ui": true, + "requiredPlugins": ["embeddable", "uiActions", "uiActionsEnhanced"], + "requiredBundles": ["kibanaUtils", "kibanaReact"] +} diff --git a/x-pack/plugins/embeddable_enhanced/public/drilldowns/index.ts b/x-pack/plugins/drilldowns/url_drilldown/public/index.ts similarity index 53% rename from x-pack/plugins/embeddable_enhanced/public/drilldowns/index.ts rename to x-pack/plugins/drilldowns/url_drilldown/public/index.ts index a8d5a179dbac1f..b040ef625bc1f2 100644 --- a/x-pack/plugins/embeddable_enhanced/public/drilldowns/index.ts +++ b/x-pack/plugins/drilldowns/url_drilldown/public/index.ts @@ -4,4 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -export * from './url_drilldown'; +import { PluginInitializerContext } from 'src/core/public'; +import { UrlDrilldownPlugin } from './plugin'; + +export function plugin(context: PluginInitializerContext) { + return new UrlDrilldownPlugin(context); +} diff --git a/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/i18n.ts b/x-pack/plugins/drilldowns/url_drilldown/public/lib/i18n.ts similarity index 85% rename from x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/i18n.ts rename to x-pack/plugins/drilldowns/url_drilldown/public/lib/i18n.ts index 748f6f4cecedd5..b0279a598f2f74 100644 --- a/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/i18n.ts +++ b/x-pack/plugins/drilldowns/url_drilldown/public/lib/i18n.ts @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; export const txtUrlDrilldownDisplayName = i18n.translate( - 'xpack.embeddableEnhanced.drilldowns.urlDrilldownDisplayName', + 'xpack.drilldowns.urlDrilldown.DisplayName', { defaultMessage: 'Go to URL', } diff --git a/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/index.ts b/x-pack/plugins/drilldowns/url_drilldown/public/lib/index.ts similarity index 100% rename from x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/index.ts rename to x-pack/plugins/drilldowns/url_drilldown/public/lib/index.ts diff --git a/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown.test.ts b/x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown.test.ts similarity index 100% rename from x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown.test.ts rename to x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown.test.ts diff --git a/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown.tsx b/x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown.tsx similarity index 100% rename from x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown.tsx rename to x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown.tsx diff --git a/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown_scope.test.ts b/x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown_scope.test.ts similarity index 100% rename from x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown_scope.test.ts rename to x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown_scope.test.ts diff --git a/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown_scope.ts b/x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown_scope.ts similarity index 100% rename from x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown_scope.ts rename to x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown_scope.ts diff --git a/x-pack/plugins/drilldowns/url_drilldown/public/plugin.ts b/x-pack/plugins/drilldowns/url_drilldown/public/plugin.ts new file mode 100644 index 00000000000000..82ce7a129f4976 --- /dev/null +++ b/x-pack/plugins/drilldowns/url_drilldown/public/plugin.ts @@ -0,0 +1,59 @@ +/* + * 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 { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core/public'; +import { EmbeddableSetup, EmbeddableStart } from '../../../../../src/plugins/embeddable/public'; +import { + AdvancedUiActionsSetup, + AdvancedUiActionsStart, + urlDrilldownGlobalScopeProvider, +} from '../../../ui_actions_enhanced/public'; +import { UrlDrilldown } from './lib'; +import { createStartServicesGetter } from '../../../../../src/plugins/kibana_utils/public'; + +export interface SetupDependencies { + embeddable: EmbeddableSetup; + uiActionsEnhanced: AdvancedUiActionsSetup; +} + +export interface StartDependencies { + embeddable: EmbeddableStart; + uiActionsEnhanced: AdvancedUiActionsStart; +} + +// eslint-disable-next-line +export interface SetupContract {} + +// eslint-disable-next-line +export interface StartContract {} + +export class UrlDrilldownPlugin + implements Plugin { + constructor(protected readonly context: PluginInitializerContext) {} + + public setup(core: CoreSetup, plugins: SetupDependencies): SetupContract { + const startServices = createStartServicesGetter(core.getStartServices); + plugins.uiActionsEnhanced.registerDrilldown( + new UrlDrilldown({ + getGlobalScope: urlDrilldownGlobalScopeProvider({ core }), + navigateToUrl: (url: string) => + core.getStartServices().then(([{ application }]) => application.navigateToUrl(url)), + getSyntaxHelpDocsLink: () => + startServices().core.docLinks.links.dashboard.urlDrilldownTemplateSyntax, + getVariablesHelpDocsLink: () => + startServices().core.docLinks.links.dashboard.urlDrilldownVariables, + }) + ); + + return {}; + } + + public start(core: CoreStart, plugins: StartDependencies): StartContract { + return {}; + } + + public stop() {} +} diff --git a/x-pack/plugins/embeddable_enhanced/kibana.json b/x-pack/plugins/embeddable_enhanced/kibana.json index acada946fe0d17..8d49e3e26eb7be 100644 --- a/x-pack/plugins/embeddable_enhanced/kibana.json +++ b/x-pack/plugins/embeddable_enhanced/kibana.json @@ -3,6 +3,5 @@ "version": "kibana", "server": false, "ui": true, - "requiredPlugins": ["embeddable", "kibanaReact", "uiActions", "uiActionsEnhanced"], - "requiredBundles": ["kibanaUtils"] + "requiredPlugins": ["embeddable", "kibanaReact", "uiActions", "uiActionsEnhanced"] } diff --git a/x-pack/plugins/embeddable_enhanced/public/plugin.ts b/x-pack/plugins/embeddable_enhanced/public/plugin.ts index 2138a372523b78..5d5ad852839d4e 100644 --- a/x-pack/plugins/embeddable_enhanced/public/plugin.ts +++ b/x-pack/plugins/embeddable_enhanced/public/plugin.ts @@ -28,11 +28,8 @@ import { UiActionsEnhancedDynamicActionManager as DynamicActionManager, AdvancedUiActionsSetup, AdvancedUiActionsStart, - urlDrilldownGlobalScopeProvider, } from '../../ui_actions_enhanced/public'; import { PanelNotificationsAction, ACTION_PANEL_NOTIFICATIONS } from './actions'; -import { UrlDrilldown } from './drilldowns'; -import { createStartServicesGetter } from '../../../../src/plugins/kibana_utils/public'; declare module '../../../../src/plugins/ui_actions/public' { export interface ActionContextMapping { @@ -64,23 +61,10 @@ export class EmbeddableEnhancedPlugin public setup(core: CoreSetup, plugins: SetupDependencies): SetupContract { this.setCustomEmbeddableFactoryProvider(plugins); - const startServices = createStartServicesGetter(core.getStartServices); const panelNotificationAction = new PanelNotificationsAction(); plugins.uiActionsEnhanced.registerAction(panelNotificationAction); plugins.uiActionsEnhanced.attachAction(PANEL_NOTIFICATION_TRIGGER, panelNotificationAction.id); - plugins.uiActionsEnhanced.registerDrilldown( - new UrlDrilldown({ - getGlobalScope: urlDrilldownGlobalScopeProvider({ core }), - navigateToUrl: (url: string) => - core.getStartServices().then(([{ application }]) => application.navigateToUrl(url)), - getSyntaxHelpDocsLink: () => - startServices().core.docLinks.links.dashboard.urlDrilldownTemplateSyntax, - getVariablesHelpDocsLink: () => - startServices().core.docLinks.links.dashboard.urlDrilldownVariables, - }) - ); - return {}; } diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.test.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.test.ts index 39d9dfeca2fd6c..311cb45c7ec71d 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.test.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.test.ts @@ -437,8 +437,7 @@ describe('DynamicActionManager', () => { name: 'foo', config: {}, }; - - await expect(manager.createEvent(action, ['SELECT_RANGE_TRIGGER'])).rejects; + await expect(manager.createEvent(action, ['SELECT_RANGE_TRIGGER'])).rejects.toThrow(); }); }); }); @@ -704,4 +703,18 @@ describe('DynamicActionManager', () => { expect(basicAndGoldActions).toHaveLength(2); }); + + test("failing to revive/kill an action doesn't fail action manager", async () => { + const { manager, uiActions, storage } = setup([event1, event3, event2]); + + uiActions.registerActionFactory(actionFactoryDefinition1); + + await manager.start(); + + expect(uiActions.getTriggerActions('VALUE_CLICK_TRIGGER')).toHaveLength(2); + expect(await storage.list()).toEqual([event1, event3, event2]); + + await manager.stop(); + expect(uiActions.getTriggerActions('VALUE_CLICK_TRIGGER')).toHaveLength(0); + }); }); diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts index 6ca388281ad769..c2bdd9277b696f 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts @@ -34,7 +34,13 @@ export interface DynamicActionManagerParams { storage: ActionStorage; uiActions: Pick< StartContract, - 'registerAction' | 'attachAction' | 'unregisterAction' | 'detachAction' | 'getActionFactory' + | 'registerAction' + | 'attachAction' + | 'unregisterAction' + | 'detachAction' + | 'hasAction' + | 'getActionFactory' + | 'hasActionFactory' >; isCompatible: (context: C) => Promise; } @@ -73,7 +79,16 @@ export class DynamicActionManager { const actionId = this.generateActionId(eventId); - const factory = uiActions.getActionFactory(event.action.factoryId); + if (!uiActions.hasActionFactory(action.factoryId)) { + // eslint-disable-next-line no-console + console.warn( + `Action factory for action [action.factoryId = ${action.factoryId}] doesn't exist. Skipping action [action.name = ${action.name}] revive.` + ); + return; + } + + const factory = uiActions.getActionFactory(action.factoryId); + const actionDefinition: ActionDefinition = factory.create(action as SerializedAction); uiActions.registerAction({ ...actionDefinition, @@ -100,6 +115,7 @@ export class DynamicActionManager { protected killAction({ eventId, triggers }: SerializedEvent) { const { uiActions } = this.params; const actionId = this.generateActionId(eventId); + if (!uiActions.hasAction(actionId)) return; for (const trigger of triggers) uiActions.detachAction(trigger as any, actionId); uiActions.unregisterAction(actionId); @@ -156,7 +172,16 @@ export class DynamicActionManager { this.ui.transitions.startFetching(); try { const events = await this.params.storage.list(); - for (const event of events) this.reviveAction(event); + + for (const event of events) { + try { + this.reviveAction(event); + } catch (e) { + // eslint-disable-next-line no-console + console.error(`Failed to revive action [event.eventId = ${event.eventId}]`); + } + } + this.ui.transitions.finishFetching(events); } catch (error) { this.ui.transitions.failFetching(error instanceof Error ? error : { message: String(error) }); diff --git a/x-pack/plugins/ui_actions_enhanced/public/plugin.ts b/x-pack/plugins/ui_actions_enhanced/public/plugin.ts index b38bc44abe2b06..1beb5d30a341bf 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/plugin.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/plugin.ts @@ -58,7 +58,10 @@ export interface SetupContract export interface StartContract extends UiActionsStart, - Pick { + Pick< + UiActionsServiceEnhancements, + 'getActionFactory' | 'hasActionFactory' | 'getActionFactories' + > { FlyoutManageDrilldowns: ReturnType; } diff --git a/x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts b/x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts index ab0aa1200f5a78..d63b5dda3f66fe 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts @@ -70,6 +70,10 @@ export class UiActionsServiceEnhancements { return actionFactory; }; + public readonly hasActionFactory = (actionFactoryId: string): boolean => { + return this.actionFactories.has(actionFactoryId); + }; + /** * Returns an array of all action factories. */ From 38872c91c81a8c74bd89d635d25ea727c0e0764d Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Fri, 18 Sep 2020 14:36:12 +0200 Subject: [PATCH 2/9] fix wording --- docs/user/dashboard/url-drilldown.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user/dashboard/url-drilldown.asciidoc b/docs/user/dashboard/url-drilldown.asciidoc index 801fef1649511a..a70b7cd2a1a704 100644 --- a/docs/user/dashboard/url-drilldown.asciidoc +++ b/docs/user/dashboard/url-drilldown.asciidoc @@ -243,7 +243,7 @@ Tip: Consider using <> helper for date formatting. [[variables]] ==== Disable URL drilldown -You can disable URL drilldown feature on your {kib} instance by disabling `urlDrilldown` plugin: +You can disable URL drilldown feature on your {kib} instance by disabling the plugin: ["source","yml"] ----------- From 6150463c523a486fb8cc2be6573f73cf9e82377e Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Fri, 18 Sep 2020 14:38:33 +0200 Subject: [PATCH 3/9] improve --- .../public/dynamic_actions/dynamic_action_manager.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts index c2bdd9277b696f..d5e4ba5b187b9d 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts @@ -172,15 +172,7 @@ export class DynamicActionManager { this.ui.transitions.startFetching(); try { const events = await this.params.storage.list(); - - for (const event of events) { - try { - this.reviveAction(event); - } catch (e) { - // eslint-disable-next-line no-console - console.error(`Failed to revive action [event.eventId = ${event.eventId}]`); - } - } + for (const event of events) this.reviveAction(event); this.ui.transitions.finishFetching(events); } catch (error) { From 7a1ff8e0aa3c37fb6db80abe6bf48b0945fb0804 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Fri, 18 Sep 2020 14:53:57 +0200 Subject: [PATCH 4/9] fix duplicate id --- x-pack/plugins/drilldowns/url_drilldown/README.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/drilldowns/url_drilldown/README.asciidoc b/x-pack/plugins/drilldowns/url_drilldown/README.asciidoc index d33fc3cb141db8..60f1744cb2661f 100644 --- a/x-pack/plugins/drilldowns/url_drilldown/README.asciidoc +++ b/x-pack/plugins/drilldowns/url_drilldown/README.asciidoc @@ -1,5 +1,5 @@ -[[url-drilldown]] -== URL drilldown +[[url-drilldown-plugin]] +== URL drilldown plugin NOTE: This plugin contains implementation of URL drilldown. For drilldowns infrastructure code refer to `ui_actions_enhanced` plugin. From 06f51e42f4c49a9d8363fe78926b94d16bb20fb5 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Fri, 18 Sep 2020 15:01:48 +0200 Subject: [PATCH 5/9] fix doc --- docs/user/dashboard/url-drilldown.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user/dashboard/url-drilldown.asciidoc b/docs/user/dashboard/url-drilldown.asciidoc index a70b7cd2a1a704..ee879256a1fae4 100644 --- a/docs/user/dashboard/url-drilldown.asciidoc +++ b/docs/user/dashboard/url-drilldown.asciidoc @@ -240,7 +240,7 @@ Tip: Consider using <> helper for date formatting. |=== [float] -[[variables]] +[[disable]] ==== Disable URL drilldown You can disable URL drilldown feature on your {kib} instance by disabling the plugin: From d35e770030a401c09f9ee23fe88b969f9bbd1a05 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Fri, 18 Sep 2020 15:11:32 +0200 Subject: [PATCH 6/9] fix readme --- .../url_drilldown/{README.asciidoc => README.md} | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) rename x-pack/plugins/drilldowns/url_drilldown/{README.asciidoc => README.md} (71%) diff --git a/x-pack/plugins/drilldowns/url_drilldown/README.asciidoc b/x-pack/plugins/drilldowns/url_drilldown/README.md similarity index 71% rename from x-pack/plugins/drilldowns/url_drilldown/README.asciidoc rename to x-pack/plugins/drilldowns/url_drilldown/README.md index 60f1744cb2661f..8eedc44ca35aeb 100644 --- a/x-pack/plugins/drilldowns/url_drilldown/README.asciidoc +++ b/x-pack/plugins/drilldowns/url_drilldown/README.md @@ -1,16 +1,15 @@ -[[url-drilldown-plugin]] -== URL drilldown plugin +## URL drilldown -NOTE: This plugin contains implementation of URL drilldown. For drilldowns infrastructure code refer to `ui_actions_enhanced` plugin. +> NOTE: This plugin contains implementation of URL drilldown. For drilldowns infrastructure code refer to `ui_actions_enhanced` plugin. Url drilldown allows navigating to external URL or to internal kibana URL. By using variables in url template result url can be dynamic and depend on user's interaction. URL drilldown has 3 sources for variables: -* Global static variables like, for example, `kibanaUrl`. Such variables won’t change depending on a place where url drilldown is used. -* Context variables are dynamic and different depending on where drilldown is created and used. -* Event variables depend on a trigger context. These variables are dynamically extracted from the action context when drilldown is executed. +1. Global static variables like, for example, `kibanaUrl`. Such variables won’t change depending on a place where url drilldown is used. +2. Context variables are dynamic and different depending on where drilldown is created and used. +3. Event variables depend on a trigger context. These variables are dynamically extracted from the action context when drilldown is executed. Difference between `event` and `context` variables, is that real `context` variables are available during drilldown creation (e.g. embeddable panel), but `event` variables mapped from trigger context. Since there is no trigger context during drilldown creation, we have to provide some _mock_ variables for validating and previewing the URL. From 0a6c9826f83d1a9f48a03e978da662348bfb79df Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Fri, 18 Sep 2020 15:44:42 +0200 Subject: [PATCH 7/9] docs --- docs/developer/plugin-list.asciidoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 501a3698d07d91..a3d24dddcb3ce5 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -498,6 +498,10 @@ in their infrastructure. |Contains HTTP endpoints and UiSettings that are slated for removal. +|{kib-repo}blob/{branch}/x-pack/plugins/drilldowns/url_drilldown/README.md[urlDrilldown] +|NOTE: This plugin contains implementation of URL drilldown. For drilldowns infrastructure code refer to ui_actions_enhanced plugin. + + |=== include::{kibana-root}/src/plugins/dashboard/README.asciidoc[leveloffset=+1] From 5d0f8765216e8f877267d49e2b72fa5a9e134384 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Fri, 18 Sep 2020 16:40:52 +0200 Subject: [PATCH 8/9] fix ts & i18n --- src/plugins/ui_actions/public/mocks.ts | 1 + x-pack/.i18nrc.json | 1 + .../plugins/drilldowns/url_drilldown/public/lib/i18n.ts | 9 +++------ x-pack/plugins/ui_actions_enhanced/public/mocks.ts | 1 + 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/ui_actions/public/mocks.ts b/src/plugins/ui_actions/public/mocks.ts index 3522ac4941ba0a..759430169b6131 100644 --- a/src/plugins/ui_actions/public/mocks.ts +++ b/src/plugins/ui_actions/public/mocks.ts @@ -48,6 +48,7 @@ const createStartContract = (): Start => { executeTriggerActions: jest.fn(), fork: jest.fn(), getAction: jest.fn(), + hasAction: jest.fn(), getTrigger: jest.fn(), getTriggerActions: jest.fn((id: TriggerId) => []), getTriggerCompatibleActions: jest.fn(), diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index bdd0fbea35fa83..e86b00a65a3cc9 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -55,6 +55,7 @@ "xpack.triggersActionsUI": "plugins/triggers_actions_ui", "xpack.upgradeAssistant": "plugins/upgrade_assistant", "xpack.uptime": ["plugins/uptime"], + "xpack.urlDrilldown": "plugins/drilldowns/url_drilldown", "xpack.watcher": "plugins/watcher", "xpack.observability": "plugins/observability" }, diff --git a/x-pack/plugins/drilldowns/url_drilldown/public/lib/i18n.ts b/x-pack/plugins/drilldowns/url_drilldown/public/lib/i18n.ts index b0279a598f2f74..7e91c6b8490358 100644 --- a/x-pack/plugins/drilldowns/url_drilldown/public/lib/i18n.ts +++ b/x-pack/plugins/drilldowns/url_drilldown/public/lib/i18n.ts @@ -6,9 +6,6 @@ import { i18n } from '@kbn/i18n'; -export const txtUrlDrilldownDisplayName = i18n.translate( - 'xpack.drilldowns.urlDrilldown.DisplayName', - { - defaultMessage: 'Go to URL', - } -); +export const txtUrlDrilldownDisplayName = i18n.translate('xpack.urlDrilldown.DisplayName', { + defaultMessage: 'Go to URL', +}); diff --git a/x-pack/plugins/ui_actions_enhanced/public/mocks.ts b/x-pack/plugins/ui_actions_enhanced/public/mocks.ts index 17a6fc1b955dff..e5c757b50df1aa 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/mocks.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/mocks.ts @@ -29,6 +29,7 @@ const createStartContract = (): Start => { ...uiActionsPluginMock.createStartContract(), getActionFactories: jest.fn(), getActionFactory: jest.fn(), + hasActionFactory: jest.fn(), FlyoutManageDrilldowns: jest.fn(), }; From 64ab2d06dc84d7042e12e02cb6f524066a4c5755 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Tue, 22 Sep 2020 09:51:42 +0200 Subject: [PATCH 9/9] fix eslint --- .../public/dynamic_actions/dynamic_action_manager.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts index 9cf10886031c1d..b414296690c9e2 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts @@ -79,7 +79,6 @@ export class DynamicActionManager { const actionId = this.generateActionId(eventId); - if (!uiActions.hasActionFactory(action.factoryId)) { // eslint-disable-next-line no-console console.warn(