Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Drilldowns] Beta badge support. Mark URL Drilldown as Beta #75654

Merged
merged 9 commits into from
Sep 18, 2020
1 change: 1 addition & 0 deletions docs/user/dashboard/drilldowns.asciidoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[role="xpack"]
[[drilldowns]]
== Use drilldowns for dashboard actions

Expand Down
2 changes: 2 additions & 0 deletions docs/user/dashboard/url-drilldown.asciidoc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class UrlDrilldown implements Drilldown<Config, UrlTrigger, ActionFactory

readonly minimalLicense = 'gold';
readonly licenseFeatureName = 'URL drilldown';
readonly isBeta = true;

public readonly getDisplayName = () => txtUrlDrilldownDisplayName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,18 @@ 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,
},
{
getLicense: () => licensingMock.createLicense(),
getFeatureUsageStart: () => licensingMock.createStart().featureUsage,
}
);
const screen = render(<Demo actionFactories={[dashboardFactory, betaUrl]} />);
expect(screen.getByText(/Beta/i)).toBeVisible();
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ import {
EuiTextColor,
EuiTitle,
EuiLink,
EuiBetaBadge,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import {
txtBetaActionFactoryLabel,
txtBetaActionFactoryTooltip,
txtChangeButton,
txtTriggerPickerHelpText,
txtTriggerPickerLabel,
Expand Down Expand Up @@ -255,7 +258,15 @@ const SelectedActionFactory: React.FC<SelectedActionFactoryProps> = ({
)}
<EuiFlexItem grow={true}>
<EuiText>
<h4>{actionFactory.getDisplayName(context)}</h4>
<h4>
{actionFactory.getDisplayName(context)}{' '}
{actionFactory.isBeta && (
<EuiBetaBadge
label={txtBetaActionFactoryLabel}
tooltipContent={txtBetaActionFactoryTooltip}
/>
)}
</h4>
</EuiText>
</EuiFlexItem>
{showDeselect && (
Expand Down Expand Up @@ -350,6 +361,10 @@ const ActionFactorySelector: React.FC<ActionFactorySelectorProps> = ({
data-test-subj={`${TEST_SUBJ_ACTION_FACTORY_ITEM}-${actionFactory.id}`}
onClick={() => onActionFactorySelected(actionFactory)}
disabled={!actionFactory.isCompatibleLicense()}
betaBadgeLabel={actionFactory.isBeta ? txtBetaActionFactoryLabel : undefined}
betaBadgeTooltipContent={
actionFactory.isBeta ? txtBetaActionFactoryTooltip : undefined
}
>
{actionFactory.getIconType(context) && (
<EuiIcon type={actionFactory.getIconType(context)!} size="m" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,17 @@ export const txtTriggerPickerHelpTooltip = i18n.translate(
defaultMessage: 'Determines when the drilldown appears in context menu',
}
);

export const txtBetaActionFactoryLabel = i18n.translate(
'xpack.uiActionsEnhanced.components.actionWizard.betaActionLabel',
{
defaultMessage: `Beta`,
}
);

export const txtBetaActionFactoryTooltip = i18n.translate(
'xpack.uiActionsEnhanced.components.actionWizard.betaActionTooltip',
{
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.`,
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -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 license level
* Empty means no restrictions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,15 @@ describe('License & ActionFactory', () => {
});
});
});

describe('isBeta', () => {
test('false by default', async () => {
const factory = createActionFactory();
expect(factory.isBeta).toBe(false);
});

test('true', async () => {
const factory = createActionFactory({ isBeta: true });
expect(factory.isBeta).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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 licenseFeatureName = this.def.licenseFeatureName;
public readonly order = this.def.order || 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export interface ActionFactoryDefinition<
*/
licenseFeatureName?: string;

/**
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class UiActionsServiceEnhancements {
ExecutionContext extends TriggerContextMapping[SupportedTriggers] = TriggerContextMapping[SupportedTriggers]
>({
id: factoryId,
isBeta,
order,
CollectConfig,
createConfig,
Expand All @@ -109,6 +110,7 @@ export class UiActionsServiceEnhancements {
ExecutionContext
> = {
id: factoryId,
isBeta,
minimalLicense,
licenseFeatureName,
order,
Expand Down