From ee8c38384b6a329c12238a6acb9aaa93799805aa Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Fri, 21 Aug 2020 16:04:11 +0200 Subject: [PATCH 1/5] =?UTF-8?q?add=20support=20for=20=E2=80=9Cbeta?= =?UTF-8?q?=E2=80=9D=20in=20drilldowns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../public/dashboard_to_url_drilldown/index.tsx | 2 ++ .../action_wizard/action_wizard.test.tsx | 12 ++++++++++++ .../components/action_wizard/action_wizard.tsx | 11 ++++++++++- .../public/components/action_wizard/i18n.ts | 7 +++++++ .../public/drilldowns/drilldown_definition.ts | 6 ++++++ .../public/dynamic_actions/action_factory.test.ts | 14 ++++++++++++++ .../public/dynamic_actions/action_factory.ts | 1 + .../dynamic_actions/action_factory_definition.ts | 6 ++++++ .../services/ui_actions_service_enhancements.ts | 2 ++ 9 files changed, 60 insertions(+), 1 deletion(-) diff --git a/x-pack/examples/ui_actions_enhanced_examples/public/dashboard_to_url_drilldown/index.tsx b/x-pack/examples/ui_actions_enhanced_examples/public/dashboard_to_url_drilldown/index.tsx index 7d915ea23c66f..3b02b93237f1f 100644 --- a/x-pack/examples/ui_actions_enhanced_examples/public/dashboard_to_url_drilldown/index.tsx +++ b/x-pack/examples/ui_actions_enhanced_examples/public/dashboard_to_url_drilldown/index.tsx @@ -41,6 +41,8 @@ const SAMPLE_DASHBOARD_TO_URL_DRILLDOWN = 'SAMPLE_DASHBOARD_TO_URL_DRILLDOWN'; export class DashboardToUrlDrilldown implements Drilldown { public readonly id = SAMPLE_DASHBOARD_TO_URL_DRILLDOWN; + public readonly isBeta = true; + public readonly order = 8; readonly minimalLicense = 'gold'; // example of minimal license support diff --git a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.test.tsx b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.test.tsx index 78252dccd20d2..633433323899d 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.test.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.test.tsx @@ -78,3 +78,15 @@ test('If not enough license, button is disabled', () => { expect(screen.getByText(/Go to URL/i)).toBeDisabled(); }); + +test('if action is beta, beta badge is shown', () => { + const betaUrl = new ActionFactory( + { + ...urlDrilldownActionFactory, + isBeta: true, + }, + () => licenseMock.createLicense() + ); + const screen = render(); + expect(screen.getByText(/Beta/i)).toBeVisible(); +}); diff --git a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx index 7e4fe1de8be8d..e863e0561dd80 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx @@ -21,7 +21,12 @@ import { EuiLink, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { txtChangeButton, txtTriggerPickerHelpText, txtTriggerPickerLabel } from './i18n'; +import { + txtBetaActionFactoryTooltip, + txtChangeButton, + txtTriggerPickerHelpText, + txtTriggerPickerLabel, +} from './i18n'; import './action_wizard.scss'; import { ActionFactory, BaseActionFactoryContext } from '../../dynamic_actions'; import { Trigger, TriggerId } from '../../../../../../src/plugins/ui_actions/public'; @@ -342,6 +347,10 @@ const ActionFactorySelector: React.FC = ({ data-test-subj={`${TEST_SUBJ_ACTION_FACTORY_ITEM}-${actionFactory.id}`} onClick={() => onActionFactorySelected(actionFactory)} disabled={!actionFactory.isCompatibleLicence()} + betaBadgeLabel={actionFactory.isBeta ? 'Beta' : undefined} + betaBadgeTooltipContent={ + actionFactory.isBeta ? txtBetaActionFactoryTooltip : undefined + } > {actionFactory.getIconType(context) && ( diff --git a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts index 678457f9794f3..d6ac7e1cb4d79 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts @@ -26,3 +26,10 @@ export const txtTriggerPickerHelpText = i18n.translate( defaultMessage: "What's this?", } ); + +export const txtBetaActionFactoryTooltip = i18n.translate( + 'xpack.uiActionsEnhanced.components.actionWizard.betaActionTooltip', + { + defaultMessage: `This action is not GA. Please help us by reporting any bugs.`, + } +); diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/drilldown_definition.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/drilldown_definition.ts index ff455c6ae45b6..35e4a4bde5b73 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/drilldown_definition.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/drilldown_definition.ts @@ -36,6 +36,12 @@ export interface DrilldownDefinition< */ id: string; + /** + * Is this action factory not GA? + * Adds a beta badge on a list item representing this ActionFactory + */ + readonly isBeta?: boolean; + /** * Minimal licence level * Empty means no restrictions diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.test.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.test.ts index a07fed8486438..095c921ecb69e 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.test.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.test.ts @@ -53,3 +53,17 @@ describe('License & ActionFactory', () => { expect(factory.isCompatibleLicence()).toBe(true); }); }); + +describe('isBeta', () => { + test('false by default', async () => { + const factory = new ActionFactory(def, () => licensingMock.createLicense()); + expect(factory.isBeta).toBe(false); + }); + + test('true', async () => { + const factory = new ActionFactory({ ...def, isBeta: true }, () => + licensingMock.createLicense() + ); + expect(factory.isBeta).toBe(true); + }); +}); diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.ts index 35e06ab036fc9..b3753921a73ee 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.ts @@ -35,6 +35,7 @@ export class ActionFactory< ) {} public readonly id = this.def.id; + public readonly isBeta = this.def.isBeta ?? false; public readonly minimalLicense = this.def.minimalLicense; public readonly order = this.def.order || 0; public readonly MenuItem? = this.def.MenuItem; diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory_definition.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory_definition.ts index 0acd3ea3e51a7..4c17ead97e45e 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory_definition.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory_definition.ts @@ -40,6 +40,12 @@ export interface ActionFactoryDefinition< */ readonly minimalLicense?: LicenseType; + /** + * Is this action factory not GA? + * Adds a beta badge on a list item representing this ActionFactory + */ + readonly isBeta?: boolean; + /** * This method should return a definition of a new action, normally used to * register it in `ui_actions` registry. 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 9575329514835..3db42ef7fcbd2 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 @@ -85,6 +85,7 @@ export class UiActionsServiceEnhancements { ExecutionContext extends TriggerContextMapping[SupportedTriggers] = TriggerContextMapping[SupportedTriggers] >({ id: factoryId, + isBeta, order, CollectConfig, createConfig, @@ -104,6 +105,7 @@ export class UiActionsServiceEnhancements { ExecutionContext > = { id: factoryId, + isBeta, minimalLicense, order, CollectConfig, From 5c6d68d9fbdce0be8e06c72df95576e6651ae80a Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Fri, 21 Aug 2020 16:21:37 +0200 Subject: [PATCH 2/5] improve --- .../public/components/action_wizard/action_wizard.tsx | 3 ++- .../public/components/action_wizard/i18n.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx index e863e0561dd80..895b1be07e5dd 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx @@ -22,6 +22,7 @@ import { } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { + txtBetaActionFactoryLabel, txtBetaActionFactoryTooltip, txtChangeButton, txtTriggerPickerHelpText, @@ -347,7 +348,7 @@ const ActionFactorySelector: React.FC = ({ data-test-subj={`${TEST_SUBJ_ACTION_FACTORY_ITEM}-${actionFactory.id}`} onClick={() => onActionFactorySelected(actionFactory)} disabled={!actionFactory.isCompatibleLicence()} - betaBadgeLabel={actionFactory.isBeta ? 'Beta' : undefined} + betaBadgeLabel={actionFactory.isBeta ? txtBetaActionFactoryLabel : undefined} betaBadgeTooltipContent={ actionFactory.isBeta ? txtBetaActionFactoryTooltip : undefined } diff --git a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts index d6ac7e1cb4d79..777809dfb0ec1 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts @@ -27,6 +27,13 @@ export const txtTriggerPickerHelpText = i18n.translate( } ); +export const txtBetaActionFactoryLabel = i18n.translate( + 'xpack.uiActionsEnhanced.components.actionWizard.betaActionLabel', + { + defaultMessage: `Beta`, + } +); + export const txtBetaActionFactoryTooltip = i18n.translate( 'xpack.uiActionsEnhanced.components.actionWizard.betaActionTooltip', { From ac28d8fb58e9090c54919c046937aae429e8f928 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Thu, 17 Sep 2020 14:24:04 +0200 Subject: [PATCH 3/5] improve --- docs/user/dashboard/drilldowns.asciidoc | 1 + docs/user/dashboard/url-drilldown.asciidoc | 2 ++ .../public/drilldowns/url_drilldown/url_drilldown.tsx | 1 + .../components/action_wizard/action_wizard.test.tsx | 5 ++++- .../public/components/action_wizard/action_wizard.tsx | 11 ++++++++++- .../public/components/action_wizard/i18n.ts | 2 +- 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/user/dashboard/drilldowns.asciidoc b/docs/user/dashboard/drilldowns.asciidoc index 85230f1b6f70d..e3d0e16630c5c 100644 --- a/docs/user/dashboard/drilldowns.asciidoc +++ b/docs/user/dashboard/drilldowns.asciidoc @@ -1,3 +1,4 @@ +[role="xpack"] [[drilldowns]] == Use drilldowns for dashboard actions diff --git a/docs/user/dashboard/url-drilldown.asciidoc b/docs/user/dashboard/url-drilldown.asciidoc index 16f82477756b7..8893d0ecb4d4d 100644 --- a/docs/user/dashboard/url-drilldown.asciidoc +++ b/docs/user/dashboard/url-drilldown.asciidoc @@ -1,6 +1,8 @@ [[url-drilldown]] === URL drilldown +beta[] + The URL drilldown allows you to navigate from a dashboard to an internal or external URL. The destination URL can be dynamic, depending on the dashboard context or user’s interaction with a visualization. diff --git a/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown.tsx b/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown.tsx index 80478e6490b8f..4280ea637ceba 100644 --- a/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown.tsx +++ b/x-pack/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown.tsx @@ -53,6 +53,7 @@ export class UrlDrilldown implements Drilldown txtUrlDrilldownDisplayName; diff --git a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.test.tsx b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.test.tsx index 05754a89ba1ef..fcea8caf9090e 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.test.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.test.tsx @@ -89,7 +89,10 @@ test('if action is beta, beta badge is shown', () => { ...urlDrilldownActionFactory, isBeta: true, }, - () => licenseMock.createLicense() + { + getLicense: () => licensingMock.createLicense(), + getFeatureUsageStart: () => licensingMock.createStart().featureUsage, + } ); const screen = render(); expect(screen.getByText(/Beta/i)).toBeVisible(); diff --git a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx index cc7fd33f8f1c1..a3f6cac3ba1b4 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx @@ -19,6 +19,7 @@ import { EuiTextColor, EuiTitle, EuiLink, + EuiBetaBadge, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { @@ -257,7 +258,15 @@ const SelectedActionFactory: React.FC = ({ )} -

{actionFactory.getDisplayName(context)}

+

+ {actionFactory.getDisplayName(context)}{' '} + {actionFactory.isBeta && ( + + )} +

{showDeselect && ( diff --git a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts index 9f52b7b4e809a..43a3bd01daf37 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts @@ -44,6 +44,6 @@ export const txtBetaActionFactoryLabel = i18n.translate( export const txtBetaActionFactoryTooltip = i18n.translate( 'xpack.uiActionsEnhanced.components.actionWizard.betaActionTooltip', { - defaultMessage: `This action is not GA. Please help us by reporting any bugs.`, + defaultMessage: `This action is in beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features. Please help us by reporting any bugs or providing other feedback.`, } ); From 1821a579b476dfaef818ddf7090a84d95d7a0a3e Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Thu, 17 Sep 2020 14:55:06 +0200 Subject: [PATCH 4/5] improve help text --- .../components/url_drilldown_collect_config/i18n.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/url_drilldown/components/url_drilldown_collect_config/i18n.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/url_drilldown/components/url_drilldown_collect_config/i18n.ts index 78f7218dce22e..500ef21b61dc4 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/url_drilldown/components/url_drilldown_collect_config/i18n.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/url_drilldown/components/url_drilldown_collect_config/i18n.ts @@ -19,7 +19,8 @@ export const txtUrlTemplatePlaceholder = i18n.translate( export const txtUrlPreviewHelpText = i18n.translate( 'xpack.uiActionsEnhanced.drilldowns.urlDrilldownCollectConfig.urlPreviewHelpText', { - defaultMessage: 'Please note that \\{\\{event.*\\}\\} variables replaced by dummy values.', + defaultMessage: + 'Please note that in preview \\{\\{event.*\\}\\} variables are substituted with dummy values.', } ); From a823e4e08e40d11a0d977dc17ff4fb481ebac5e7 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Thu, 17 Sep 2020 15:15:13 +0200 Subject: [PATCH 5/5] fix tests --- .../public/dynamic_actions/action_factory.test.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.test.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.test.ts index d038167fabb8b..66a876bdbab85 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.test.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.test.ts @@ -117,14 +117,12 @@ describe('License & ActionFactory', () => { describe('isBeta', () => { test('false by default', async () => { - const factory = new ActionFactory(def, () => licensingMock.createLicense()); + const factory = createActionFactory(); expect(factory.isBeta).toBe(false); }); test('true', async () => { - const factory = new ActionFactory({ ...def, isBeta: true }, () => - licensingMock.createLicense() - ); + const factory = createActionFactory({ isBeta: true }); expect(factory.isBeta).toBe(true); }); });