-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Response Ops][Connectors] Allow connectors to explicitly register wh…
…ich features they will be available in (#136331) * Adding feature config to connector type and checking for validity on registration * Updating actions APIs to filter by feature id if provided * Fixing types * Renaming allowedFeatureIds to featureConfig * Adding siem feature config. Returning feature config to client. Showing availability in connector list * Fixing types * Showing availability in create connector flyout header * Passing feature id into action form used by rule creators. * Renaming some stuff * Finishing triggers_actions_uis. Starting cases * Fixing cases * fixing types * Fixing types and adding uptime feature * Cleanup * fixing tests * Updating README * Filtering action type filter on rule list * Update x-pack/plugins/actions/common/connector_feature_config.ts Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co> * Fixing tests * Renaming featureConfig to supportedFeatureIds * PR feedback * fixing i18n * Updating docs Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
676be86
commit 3c24511
Showing
86 changed files
with
1,159 additions
and
516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/actions/common/connector_feature_config.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { areValidFeatures, getConnectorFeatureName } from './connector_feature_config'; | ||
|
||
describe('areValidFeatures', () => { | ||
it('returns true when all inputs are valid features', () => { | ||
expect(areValidFeatures(['alerting', 'cases'])).toBeTruthy(); | ||
}); | ||
|
||
it('returns true when only one input and it is a valid feature', () => { | ||
expect(areValidFeatures(['alerting'])).toBeTruthy(); | ||
expect(areValidFeatures(['cases'])).toBeTruthy(); | ||
}); | ||
|
||
it('returns false when one item in input is invalid', () => { | ||
expect(areValidFeatures(['alerting', 'nope'])).toBeFalsy(); | ||
}); | ||
|
||
it('returns false when all items in input are invalid', () => { | ||
expect(areValidFeatures(['alerts', 'nope'])).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('getConnectorFeatureName', () => { | ||
it('returns the feature name for valid feature ids', () => { | ||
expect(getConnectorFeatureName('siem')).toEqual('Security Solution'); | ||
}); | ||
|
||
it('returns the id for invalid feature ids', () => { | ||
expect(getConnectorFeatureName('foo')).toEqual('foo'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
interface ConnectorFeatureConfig { | ||
/** | ||
* Unique identifier for this feature. | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* Display name for this feature. | ||
* This will be displayed to end-users, so a translatable string is advised for i18n. | ||
*/ | ||
name: string; | ||
} | ||
|
||
export const AlertingConnectorFeatureId = 'alerting'; | ||
export const CasesConnectorFeatureId = 'cases'; | ||
export const UptimeConnectorFeatureId = 'uptime'; | ||
export const SecurityConnectorFeatureId = 'siem'; | ||
|
||
export const AlertingConnectorFeature: ConnectorFeatureConfig = { | ||
id: AlertingConnectorFeatureId, | ||
name: i18n.translate('xpack.actions.availableConnectorFeatures.alerting', { | ||
defaultMessage: 'Alerting', | ||
}), | ||
}; | ||
|
||
export const CasesConnectorFeature: ConnectorFeatureConfig = { | ||
id: CasesConnectorFeatureId, | ||
name: i18n.translate('xpack.actions.availableConnectorFeatures.cases', { | ||
defaultMessage: 'Cases', | ||
}), | ||
}; | ||
|
||
export const UptimeConnectorFeature: ConnectorFeatureConfig = { | ||
id: UptimeConnectorFeatureId, | ||
name: i18n.translate('xpack.actions.availableConnectorFeatures.uptime', { | ||
defaultMessage: 'Uptime', | ||
}), | ||
}; | ||
|
||
export const SecuritySolutionFeature: ConnectorFeatureConfig = { | ||
id: SecurityConnectorFeatureId, | ||
name: i18n.translate('xpack.actions.availableConnectorFeatures.securitySolution', { | ||
defaultMessage: 'Security Solution', | ||
}), | ||
}; | ||
|
||
const AllAvailableConnectorFeatures: ConnectorFeatureConfig[] = [ | ||
AlertingConnectorFeature, | ||
CasesConnectorFeature, | ||
UptimeConnectorFeature, | ||
SecuritySolutionFeature, | ||
]; | ||
|
||
export function areValidFeatures(ids: string[]) { | ||
return ids.every( | ||
(id: string) => | ||
!!AllAvailableConnectorFeatures.find((config: ConnectorFeatureConfig) => config.id === id) | ||
); | ||
} | ||
|
||
export function getConnectorFeatureName(id: string) { | ||
const featureConfig = AllAvailableConnectorFeatures.find((config) => config.id === id); | ||
return featureConfig ? featureConfig.name : id; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.