Skip to content

Commit

Permalink
add support for “beta” in drilldowns
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosant committed Aug 21, 2020
1 parent ee75e57 commit ee8c383
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const SAMPLE_DASHBOARD_TO_URL_DRILLDOWN = 'SAMPLE_DASHBOARD_TO_URL_DRILLDOWN';
export class DashboardToUrlDrilldown implements Drilldown<Config, UrlTrigger> {
public readonly id = SAMPLE_DASHBOARD_TO_URL_DRILLDOWN;

public readonly isBeta = true;

public readonly order = 8;

readonly minimalLicense = 'gold'; // example of minimal license support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(<Demo actionFactories={[dashboardFactory, betaUrl]} />);
expect(screen.getByText(/Beta/i)).toBeVisible();
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -342,6 +347,10 @@ const ActionFactorySelector: React.FC<ActionFactorySelectorProps> = ({
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) && (
<EuiIcon type={actionFactory.getIconType(context)!} size="m" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
}
);
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 licence level
* Empty means no restrictions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class UiActionsServiceEnhancements {
ExecutionContext extends TriggerContextMapping[SupportedTriggers] = TriggerContextMapping[SupportedTriggers]
>({
id: factoryId,
isBeta,
order,
CollectConfig,
createConfig,
Expand All @@ -104,6 +105,7 @@ export class UiActionsServiceEnhancements {
ExecutionContext
> = {
id: factoryId,
isBeta,
minimalLicense,
order,
CollectConfig,
Expand Down

0 comments on commit ee8c383

Please sign in to comment.