Skip to content

Commit ee8c383

Browse files
committed
add support for “beta” in drilldowns
1 parent ee75e57 commit ee8c383

File tree

9 files changed

+60
-1
lines changed

9 files changed

+60
-1
lines changed

x-pack/examples/ui_actions_enhanced_examples/public/dashboard_to_url_drilldown/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const SAMPLE_DASHBOARD_TO_URL_DRILLDOWN = 'SAMPLE_DASHBOARD_TO_URL_DRILLDOWN';
4141
export class DashboardToUrlDrilldown implements Drilldown<Config, UrlTrigger> {
4242
public readonly id = SAMPLE_DASHBOARD_TO_URL_DRILLDOWN;
4343

44+
public readonly isBeta = true;
45+
4446
public readonly order = 8;
4547

4648
readonly minimalLicense = 'gold'; // example of minimal license support

x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.test.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,15 @@ test('If not enough license, button is disabled', () => {
7878

7979
expect(screen.getByText(/Go to URL/i)).toBeDisabled();
8080
});
81+
82+
test('if action is beta, beta badge is shown', () => {
83+
const betaUrl = new ActionFactory(
84+
{
85+
...urlDrilldownActionFactory,
86+
isBeta: true,
87+
},
88+
() => licenseMock.createLicense()
89+
);
90+
const screen = render(<Demo actionFactories={[dashboardFactory, betaUrl]} />);
91+
expect(screen.getByText(/Beta/i)).toBeVisible();
92+
});

x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ import {
2121
EuiLink,
2222
} from '@elastic/eui';
2323
import { FormattedMessage } from '@kbn/i18n/react';
24-
import { txtChangeButton, txtTriggerPickerHelpText, txtTriggerPickerLabel } from './i18n';
24+
import {
25+
txtBetaActionFactoryTooltip,
26+
txtChangeButton,
27+
txtTriggerPickerHelpText,
28+
txtTriggerPickerLabel,
29+
} from './i18n';
2530
import './action_wizard.scss';
2631
import { ActionFactory, BaseActionFactoryContext } from '../../dynamic_actions';
2732
import { Trigger, TriggerId } from '../../../../../../src/plugins/ui_actions/public';
@@ -342,6 +347,10 @@ const ActionFactorySelector: React.FC<ActionFactorySelectorProps> = ({
342347
data-test-subj={`${TEST_SUBJ_ACTION_FACTORY_ITEM}-${actionFactory.id}`}
343348
onClick={() => onActionFactorySelected(actionFactory)}
344349
disabled={!actionFactory.isCompatibleLicence()}
350+
betaBadgeLabel={actionFactory.isBeta ? 'Beta' : undefined}
351+
betaBadgeTooltipContent={
352+
actionFactory.isBeta ? txtBetaActionFactoryTooltip : undefined
353+
}
345354
>
346355
{actionFactory.getIconType(context) && (
347356
<EuiIcon type={actionFactory.getIconType(context)!} size="m" />

x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/i18n.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,10 @@ export const txtTriggerPickerHelpText = i18n.translate(
2626
defaultMessage: "What's this?",
2727
}
2828
);
29+
30+
export const txtBetaActionFactoryTooltip = i18n.translate(
31+
'xpack.uiActionsEnhanced.components.actionWizard.betaActionTooltip',
32+
{
33+
defaultMessage: `This action is not GA. Please help us by reporting any bugs.`,
34+
}
35+
);

x-pack/plugins/ui_actions_enhanced/public/drilldowns/drilldown_definition.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export interface DrilldownDefinition<
3636
*/
3737
id: string;
3838

39+
/**
40+
* Is this action factory not GA?
41+
* Adds a beta badge on a list item representing this ActionFactory
42+
*/
43+
readonly isBeta?: boolean;
44+
3945
/**
4046
* Minimal licence level
4147
* Empty means no restrictions

x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,17 @@ describe('License & ActionFactory', () => {
5353
expect(factory.isCompatibleLicence()).toBe(true);
5454
});
5555
});
56+
57+
describe('isBeta', () => {
58+
test('false by default', async () => {
59+
const factory = new ActionFactory(def, () => licensingMock.createLicense());
60+
expect(factory.isBeta).toBe(false);
61+
});
62+
63+
test('true', async () => {
64+
const factory = new ActionFactory({ ...def, isBeta: true }, () =>
65+
licensingMock.createLicense()
66+
);
67+
expect(factory.isBeta).toBe(true);
68+
});
69+
});

x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class ActionFactory<
3535
) {}
3636

3737
public readonly id = this.def.id;
38+
public readonly isBeta = this.def.isBeta ?? false;
3839
public readonly minimalLicense = this.def.minimalLicense;
3940
public readonly order = this.def.order || 0;
4041
public readonly MenuItem? = this.def.MenuItem;

x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory_definition.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ export interface ActionFactoryDefinition<
4040
*/
4141
readonly minimalLicense?: LicenseType;
4242

43+
/**
44+
* Is this action factory not GA?
45+
* Adds a beta badge on a list item representing this ActionFactory
46+
*/
47+
readonly isBeta?: boolean;
48+
4349
/**
4450
* This method should return a definition of a new action, normally used to
4551
* register it in `ui_actions` registry.

x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export class UiActionsServiceEnhancements {
8585
ExecutionContext extends TriggerContextMapping[SupportedTriggers] = TriggerContextMapping[SupportedTriggers]
8686
>({
8787
id: factoryId,
88+
isBeta,
8889
order,
8990
CollectConfig,
9091
createConfig,
@@ -104,6 +105,7 @@ export class UiActionsServiceEnhancements {
104105
ExecutionContext
105106
> = {
106107
id: factoryId,
108+
isBeta,
107109
minimalLicense,
108110
order,
109111
CollectConfig,

0 commit comments

Comments
 (0)