[ResponseOps][Rules] Do not show connector not registered in action connectors modal (#212660)

## Summary

Resolves https://github.com/elastic/kibana/issues/212584
Resolves https://github.com/elastic/kibana/issues/207185

<img width="1917" alt="image"
src="https://github.com/user-attachments/assets/0b50f829-60a2-435e-9b76-74231d0bb54c"
/>

### Checklist

Check the PR satisfies following conditions. 

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
This commit is contained in:
Janki Salvi 2025-02-28 13:56:35 +00:00 committed by GitHub
parent 6829f07fdb
commit 83f787ac24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 46 additions and 1 deletions

View file

@ -97,4 +97,44 @@ describe('ruleActionsConnectorsBody', () => {
})
);
});
test('filters out when no connector matched action type id', async () => {
const actionTypeRegistry = new TypeRegistry<ActionTypeModel>();
actionTypeRegistry.register(getActionTypeModel('1', { id: 'actionType-1' }));
useRuleFormState.mockReturnValue({
plugins: {
actionTypeRegistry,
},
formData: {
actions: [],
},
connectors: [
...mockConnectors,
{
id: `connector-foobar-1`,
secrets: { secret: 'secret' },
actionTypeId: `actionType-foobar`,
name: `connector-foobar`,
config: { config: `config-foobar-1` },
isPreconfigured: true,
isSystemAction: false,
isDeprecated: false,
},
],
connectorTypes: mockActionTypes,
aadTemplateFields: [],
selectedRuleType: {
defaultActionGroupId: 'default',
},
});
useRuleFormDispatch.mockReturnValue(mockOnChange);
render(<RuleActionsConnectorsBody onSelectConnector={mockOnSelectConnector} />);
expect(screen.queryByText('connector-foobar')).not.toBeInTheDocument();
expect(screen.queryByText('connector-2')).not.toBeInTheDocument();
expect(await screen.findAllByTestId('ruleActionsConnectorsModalCard')).toHaveLength(1);
expect(await screen.findByText('connector-1')).toBeInTheDocument();
});
});

View file

@ -126,13 +126,18 @@ export const RuleActionsConnectorsBody = ({
const availableConnectors = useMemo(() => {
return connectors.filter(({ actionTypeId }) => {
const actionType = connectorTypes.find(({ id }) => id === actionTypeId);
if (!actionTypeRegistry.has(actionTypeId)) {
return false;
}
const actionTypeModel = actionTypeRegistry.get(actionTypeId);
if (!actionType) {
return false;
}
if (!actionTypeModel.actionParamsFields) {
if (!actionTypeModel?.actionParamsFields) {
return false;
}