mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[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:
parent
6829f07fdb
commit
83f787ac24
2 changed files with 46 additions and 1 deletions
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue