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

[7.x] [Alerting] Fixed issue when connectors dropdown not showing all available connectors (#63636) #63718

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ describe('action_form', () => {
config: {},
isPreconfigured: false,
},
{
secrets: {},
id: 'test2',
actionTypeId: actionType.id,
name: 'Test connector 2',
config: {},
isPreconfigured: true,
},
]);
const mockes = coreMock.createSetup();
deps = {
Expand All @@ -100,6 +108,7 @@ describe('action_form', () => {
disabledByLicenseActionType,
]);
actionTypeRegistry.has.mockReturnValue(true);
actionTypeRegistry.get.mockReturnValue(actionType);

const initialAlert = ({
name: 'test',
Expand Down Expand Up @@ -206,6 +215,29 @@ describe('action_form', () => {
expect(actionOption.exists()).toBeFalsy();
});

it(`renders available connectors for the selected action type`, async () => {
await setup();
const actionOption = wrapper.find(
`[data-test-subj="${actionType.id}-ActionTypeSelectOption"]`
);
actionOption.first().simulate('click');
const combobox = wrapper.find(`[data-test-subj="selectActionConnector"]`);
expect((combobox.first().props() as any).options).toMatchInlineSnapshot(`
Array [
Object {
"id": "test",
"key": "test",
"label": "Test connector ",
},
Object {
"id": "test2",
"key": "test2",
"label": "Test connector 2 (pre-configured)",
},
]
`);
});

it('renders action types disabled by license', async () => {
await setup();
const actionOption = wrapper.find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export const ActionForm = ({
label: optionTitle,
value: optionTitle,
id: actionItemId,
'data-test-subj': 'itemActionConnector',
},
];
};
Expand All @@ -177,13 +178,9 @@ export const ActionForm = ({
index: number
) => {
const optionsList = connectors
.filter(
connectorItem =>
connectorItem.actionTypeId === actionItem.actionTypeId &&
connectorItem.id === actionItem.id
)
.map(({ name, id }) => ({
label: name,
.filter(connectorItem => connectorItem.actionTypeId === actionItem.actionTypeId)
.map(({ name, id, isPreconfigured }) => ({
label: `${name} ${isPreconfigured ? preconfiguredMessage : ''}`,
key: id,
id,
}));
Expand Down Expand Up @@ -231,6 +228,8 @@ export const ActionForm = ({
fullWidth
singleSelection={{ asPlainText: true }}
options={optionsList}
id={`selectActionConnector-${actionItem.id}`}
data-test-subj="selectActionConnector"
selectedOptions={getSelectedOptions(actionItem.id)}
onChange={selectedOptions => {
setActionIdByIndex(selectedOptions[0].id ?? '', index);
Expand Down Expand Up @@ -448,6 +447,7 @@ export const ActionForm = ({
const actionTypeConnectors = connectors.filter(
field => field.actionTypeId === actionTypeModel.id
);

if (actionTypeConnectors.length > 0) {
actions.push({
id: '',
Expand Down