Skip to content

Commit

Permalink
[Actions] Support system actions in the sub actions framework (#178068)
Browse files Browse the repository at this point in the history
## Summary

This PR adds support for system actions to the sub-actions framework.


### Checklist

- [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

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
  • Loading branch information
cnasikas authored Mar 6, 2024
1 parent ca429ab commit 4953a9b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,25 @@ describe('Registration', () => {
expect(mockRenderParameterTemplates).toHaveBeenCalledWith(logger, params, variables, actionId);
expect(rendered).toBe(renderedVariables);
});

it('registers a system connector correctly', async () => {
register<TestConfig, TestSecrets>({
actionTypeRegistry,
connector: { ...connector, isSystemActionType: true },
configurationUtilities: mockedActionsConfig,
logger,
});

expect(actionTypeRegistry.register).toHaveBeenCalledTimes(1);
expect(actionTypeRegistry.register).toHaveBeenCalledWith({
id: connector.id,
name: connector.name,
minimumLicenseRequired: connector.minimumLicenseRequired,
supportedFeatureIds: connector.supportedFeatureIds,
validate: expect.anything(),
executor: expect.any(Function),
renderParameterTemplates: expect.any(Function),
isSystemActionType: true,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ export const register = <Config extends ActionTypeConfig, Secrets extends Action
validate: validators,
executor,
renderParameterTemplates: connector.renderParameterTemplates,
isSystemActionType: connector.isSystemActionType,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export interface SubActionConnectorType<Config, Secrets> {
validators?: Array<ConfigValidator<Config> | SecretsValidator<Secrets>>;
getService: (params: ServiceParams<Config, Secrets>) => SubActionConnector<Config, Secrets>;
renderParameterTemplates?: RenderParameterTemplates<ExecutorParams>;
isSystemActionType?: boolean;
}

export interface ExecutorParams extends ActionTypeParams {
Expand Down

0 comments on commit 4953a9b

Please sign in to comment.