-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Connectors] Split ServiceNow connector type (#141961)
* Splitting public servicenow files * Splitting server servicenow files * Fixing checks * Fixing checks * Moving xmatters to stack Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
c9af639
commit bb8a3c3
Showing
107 changed files
with
2,020 additions
and
547 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
169 changes: 0 additions & 169 deletions
169
x-pack/plugins/stack_connectors/public/connector_types/cases/servicenow/servicenow.tsx
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
52 changes: 52 additions & 0 deletions
52
...ns/stack_connectors/public/connector_types/cases/servicenow_itsm/servicenow_itsm.test.tsx
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,52 @@ | ||
/* | ||
* 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 { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; | ||
import { registerConnectorTypes } from '../..'; | ||
import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; | ||
import { registrationServicesMock } from '../../../mocks'; | ||
|
||
const SERVICENOW_ITSM_CONNECTOR_TYPE_ID = '.servicenow'; | ||
let connectorTypeRegistry: TypeRegistry<ConnectorTypeModel>; | ||
|
||
beforeAll(() => { | ||
connectorTypeRegistry = new TypeRegistry<ConnectorTypeModel>(); | ||
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); | ||
}); | ||
|
||
describe('connectorTypeRegistry.get() works', () => { | ||
test(`${SERVICENOW_ITSM_CONNECTOR_TYPE_ID}: connector type static data is as expected`, () => { | ||
const connectorTypeModel = connectorTypeRegistry.get(SERVICENOW_ITSM_CONNECTOR_TYPE_ID); | ||
expect(connectorTypeModel.id).toEqual(SERVICENOW_ITSM_CONNECTOR_TYPE_ID); | ||
}); | ||
}); | ||
|
||
describe('servicenow action params validation', () => { | ||
test(`${SERVICENOW_ITSM_CONNECTOR_TYPE_ID}: action params validation succeeds when action params is valid`, async () => { | ||
const connectorTypeModel = connectorTypeRegistry.get(SERVICENOW_ITSM_CONNECTOR_TYPE_ID); | ||
const actionParams = { | ||
subActionParams: { incident: { short_description: 'some title {{test}}' }, comments: [] }, | ||
}; | ||
|
||
expect(await connectorTypeModel.validateParams(actionParams)).toEqual({ | ||
errors: { ['subActionParams.incident.short_description']: [] }, | ||
}); | ||
}); | ||
|
||
test(`${SERVICENOW_ITSM_CONNECTOR_TYPE_ID}: params validation fails when short_description is not valid`, async () => { | ||
const connectorTypeModel = connectorTypeRegistry.get(SERVICENOW_ITSM_CONNECTOR_TYPE_ID); | ||
const actionParams = { | ||
subActionParams: { incident: { short_description: '' }, comments: [] }, | ||
}; | ||
|
||
expect(await connectorTypeModel.validateParams(actionParams)).toEqual({ | ||
errors: { | ||
['subActionParams.incident.short_description']: ['Short description is required.'], | ||
}, | ||
}); | ||
}); | ||
}); |
71 changes: 71 additions & 0 deletions
71
...plugins/stack_connectors/public/connector_types/cases/servicenow_itsm/servicenow_itsm.tsx
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,71 @@ | ||
/* | ||
* 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 { lazy } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import type { | ||
ActionTypeModel as ConnectorTypeModel, | ||
GenericValidationResult, | ||
} from '@kbn/triggers-actions-ui-plugin/public'; | ||
import { ServiceNowConfig, ServiceNowSecrets } from '../../lib/servicenow/types'; | ||
import { ServiceNowITSMActionParams } from './types'; | ||
import { | ||
getConnectorDescriptiveTitle, | ||
getSelectedConnectorIcon, | ||
} from '../../lib/servicenow/helpers'; | ||
|
||
export const SERVICENOW_ITSM_DESC = i18n.translate( | ||
'xpack.stackConnectors.components.serviceNowITSM.selectMessageText', | ||
{ | ||
defaultMessage: 'Create an incident in ServiceNow ITSM.', | ||
} | ||
); | ||
|
||
export const SERVICENOW_ITSM_TITLE = i18n.translate( | ||
'xpack.stackConnectors.components.serviceNowITSM.connectorTypeTitle', | ||
{ | ||
defaultMessage: 'ServiceNow ITSM', | ||
} | ||
); | ||
|
||
export function getServiceNowITSMConnectorType(): ConnectorTypeModel< | ||
ServiceNowConfig, | ||
ServiceNowSecrets, | ||
ServiceNowITSMActionParams | ||
> { | ||
return { | ||
id: '.servicenow', | ||
iconClass: lazy(() => import('./logo')), | ||
selectMessage: SERVICENOW_ITSM_DESC, | ||
actionTypeTitle: SERVICENOW_ITSM_TITLE, | ||
actionConnectorFields: lazy(() => import('../../lib/servicenow/servicenow_connectors')), | ||
validateParams: async ( | ||
actionParams: ServiceNowITSMActionParams | ||
): Promise<GenericValidationResult<unknown>> => { | ||
const translations = await import('../../lib/servicenow/translations'); | ||
const errors = { | ||
'subActionParams.incident.short_description': new Array<string>(), | ||
}; | ||
const validationResult = { | ||
errors, | ||
}; | ||
if ( | ||
actionParams.subActionParams && | ||
actionParams.subActionParams.incident && | ||
!actionParams.subActionParams.incident.short_description?.length | ||
) { | ||
errors['subActionParams.incident.short_description'].push(translations.TITLE_REQUIRED); | ||
} | ||
return validationResult; | ||
}, | ||
actionParamsFields: lazy(() => import('./servicenow_itsm_params')), | ||
customConnectorSelectItem: { | ||
getText: getConnectorDescriptiveTitle, | ||
getComponent: getSelectedConnectorIcon, | ||
}, | ||
}; | ||
} |
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
13 changes: 13 additions & 0 deletions
13
x-pack/plugins/stack_connectors/public/connector_types/cases/servicenow_itsm/types.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,13 @@ | ||
/* | ||
* 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 type { ExecutorSubActionPushParamsITSM } from '../../../../server/connector_types/lib/servicenow/types'; | ||
|
||
export interface ServiceNowITSMActionParams { | ||
subAction: string; | ||
subActionParams: ExecutorSubActionPushParamsITSM; | ||
} |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/stack_connectors/public/connector_types/cases/servicenow_sir/index.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,8 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { getServiceNowSIRConnectorType } from './servicenow_sir'; |
Oops, something went wrong.