Skip to content

Commit

Permalink
pr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Jul 27, 2022
1 parent 63c4f32 commit 751615e
Show file tree
Hide file tree
Showing 8 changed files with 255 additions and 283 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
EuiLink,
} from '@elastic/eui';
import { ActionGroup, RuleActionParam } from '@kbn/alerting-plugin/common';
import { betaBadgeProps } from './beta_badge_props';
import { loadActionTypes, loadAllActions as loadConnectors } from '../../lib/action_connector_api';
import {
ActionTypeModel,
Expand Down Expand Up @@ -256,6 +257,10 @@ export const ActionForm = ({
isDisabled={!checkEnabledResult.isEnabled}
data-test-subj={`${item.id}-${featureId}-ActionTypeSelectOption`}
label={actionTypesIndex[item.id].name}
betaBadgeLabel={item.isExperimental ? betaBadgeProps.label : undefined}
betaBadgeTooltipContent={
item.isExperimental ? betaBadgeProps.tooltipContent : undefined
}
onClick={() => addActionType(item)}
>
<EuiIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ export const ActionTypeForm = ({
{actionTypeRegistered && actionTypeRegistered.isExperimental && (
<EuiFlexItem grow={false}>
<EuiBetaBadge
data-test-subj="action-type-form-beta-badge"
label={betaBadgeProps.label}
tooltipContent={betaBadgeProps.tooltipContent}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,46 @@ describe('connector_add_flyout', () => {
});

describe('beta badge', () => {
it(`does not render beta badge when isExperimental=undefined`, async () => {
const onActionTypeChange = jest.fn();
const actionType = actionTypeRegistryMock.createMockActionTypeModel({
id: 'my-action-type',
iconClass: 'test',
selectMessage: 'test',
validateParams: (): Promise<GenericValidationResult<unknown>> => {
const validationResult = { errors: {} };
return Promise.resolve(validationResult);
},
actionConnectorFields: null,
});
actionTypeRegistry.get.mockReturnValueOnce(actionType);
loadActionTypes.mockResolvedValueOnce([
{
id: actionType.id,
enabled: false,
name: 'Test',
enabledInConfig: true,
enabledInLicense: false,
minimumLicenseRequired: 'gold',
supportedFeatureIds: ['alerting'],
},
]);

const wrapper = mountWithIntl(
<ActionTypeMenu
onActionTypeChange={onActionTypeChange}
actionTypeRegistry={actionTypeRegistry}
/>
);
await act(async () => {
await nextTick();
wrapper.update();
});

expect(
wrapper.find('EuiToolTip [data-test-subj="my-action-type-card"] EuiBetaBadge').exists()
).toBeFalsy();
});
it(`does not render beta badge when isExperimental=false`, async () => {
const onActionTypeChange = jest.fn();
const actionType = actionTypeRegistryMock.createMockActionTypeModel({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
.euiComboBoxOptionsList {
z-index: 9001;
}
.betaBadgeFlexItem.euiFlexItem.euiFlexItem--flexGrowZero {
margin-top: 10px;
margin-bottom: 3px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const ConnectorAddModal = ({
</EuiTitle>
</EuiFlexItem>
{actionTypeModel && actionTypeModel.isExperimental && (
<EuiFlexItem grow={false}>
<EuiFlexItem className="betaBadgeFlexItem" grow={false}>
<EuiBetaBadge
label={betaBadgeProps.label}
tooltipContent={betaBadgeProps.tooltipContent}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,21 @@ describe('CreateConnectorFlyout', () => {
expect(getByText(`selectMessage-${actionTypeModel.id}`)).toBeInTheDocument();
});

it('does not show beta badge when isExperimental is undefined', async () => {
const { queryByText } = appMockRenderer.render(
<CreateConnectorFlyout
actionTypeRegistry={actionTypeRegistry}
onClose={onClose}
onConnectorCreated={onConnectorCreated}
onTestConnector={onTestConnector}
/>
);
await act(() => Promise.resolve());
expect(queryByText(betaBadgeProps.label)).not.toBeInTheDocument();
});

it('does not show beta badge when isExperimental is false', async () => {
actionTypeRegistry.get.mockReturnValue({ ...actionTypeModel, isExperimental: false });
const { queryByText } = appMockRenderer.render(
<CreateConnectorFlyout
actionTypeRegistry={actionTypeRegistry}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const CreateConnectorFlyoutComponent: React.FC<CreateConnectorFlyoutProps> = ({
isMounted.current = false;
};
}, []);

return (
<EuiFlyout onClose={onClose} data-test-subj="create-connector-flyout">
<FlyoutHeader
Expand Down

0 comments on commit 751615e

Please sign in to comment.