mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[8.13] [Actions] [ServiceNow] Add required UI validation for correlation_id when recovered action (#177422) (#177550)
# Backport This will backport the following commits from `main` to `8.13`: - [[Actions] [ServiceNow] Add required UI validation for correlation_id when recovered action (#177422)](https://github.com/elastic/kibana/pull/177422) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Janki Salvi","email":"117571355+js-jankisalvi@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-02-22T08:21:31Z","message":"[Actions] [ServiceNow] Add required UI validation for correlation_id when recovered action (#177422)\n\n## Summary\r\n\r\nThis PR adds UI validation for `correlation_id` field in case of\r\nRecovered action.\r\n\r\n<img width=\"503\" alt=\"image\"\r\nsrc=\"60731f81
-1dc5-4d34-b9f8-4a3488df244f\">\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"401f79c335c8a0c4e3afb531a76bb27630e834ea","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Feature:Actions","Team:ResponseOps","v8.13.0","v8.14.0"],"title":"[Actions] [ServiceNow] Add required UI validation for correlation_id when recovered action","number":177422,"url":"https://github.com/elastic/kibana/pull/177422","mergeCommit":{"message":"[Actions] [ServiceNow] Add required UI validation for correlation_id when recovered action (#177422)\n\n## Summary\r\n\r\nThis PR adds UI validation for `correlation_id` field in case of\r\nRecovered action.\r\n\r\n<img width=\"503\" alt=\"image\"\r\nsrc=\"60731f81
-1dc5-4d34-b9f8-4a3488df244f\">\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"401f79c335c8a0c4e3afb531a76bb27630e834ea"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"8.13","label":"v8.13.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/177422","number":177422,"mergeCommit":{"message":"[Actions] [ServiceNow] Add required UI validation for correlation_id when recovered action (#177422)\n\n## Summary\r\n\r\nThis PR adds UI validation for `correlation_id` field in case of\r\nRecovered action.\r\n\r\n<img width=\"503\" alt=\"image\"\r\nsrc=\"60731f81
-1dc5-4d34-b9f8-4a3488df244f\">\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"401f79c335c8a0c4e3afb531a76bb27630e834ea"}}]}] BACKPORT--> Co-authored-by: Janki Salvi <117571355+js-jankisalvi@users.noreply.github.com>
This commit is contained in:
parent
fc823116c7
commit
f91e5cb22d
2 changed files with 47 additions and 3 deletions
|
@ -339,5 +339,27 @@ describe('ServiceNowITSMParamsFields renders', () => {
|
|||
incident: { correlation_id: 'updated correlation id' },
|
||||
});
|
||||
});
|
||||
|
||||
test('throws error if correlation_id is null and sub action is recovered', () => {
|
||||
const newProps = {
|
||||
...defaultProps,
|
||||
actionParams: {
|
||||
subAction: 'closeIncident',
|
||||
subActionParams: {
|
||||
incident: {
|
||||
...defaultProps.actionParams.subActionParams.incident,
|
||||
correlation_id: null,
|
||||
},
|
||||
comments: null,
|
||||
},
|
||||
},
|
||||
errors: { 'subActionParams.incident.correlation_id': ['correlation_id_error'] },
|
||||
selectedActionGroupId: ACTION_GROUP_RECOVERED,
|
||||
};
|
||||
|
||||
const wrapper = mountWithIntl(<ServiceNowITSMParamsFields {...newProps} />);
|
||||
|
||||
expect(wrapper.find('.euiFormErrorText').text()).toBe('correlation_id_error');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -45,16 +45,31 @@ const defaultFields: Fields = {
|
|||
};
|
||||
|
||||
const CorrelationIdField: React.FunctionComponent<
|
||||
Pick<ActionParamsProps<ServiceNowITSMActionParams>, 'index' | 'messageVariables'> & {
|
||||
Pick<ActionParamsProps<ServiceNowITSMActionParams>, 'index' | 'messageVariables' | 'errors'> & {
|
||||
correlationId: string | null;
|
||||
selectedActionGroupId?: string;
|
||||
editSubActionProperty: (key: string, value: any) => void;
|
||||
}
|
||||
> = ({ index, messageVariables, correlationId, editSubActionProperty }) => {
|
||||
> = ({
|
||||
index,
|
||||
messageVariables,
|
||||
correlationId,
|
||||
editSubActionProperty,
|
||||
selectedActionGroupId,
|
||||
errors,
|
||||
}) => {
|
||||
const { docLinks } = useKibana().services;
|
||||
return (
|
||||
<EuiFormRow
|
||||
fullWidth
|
||||
label={i18n.CORRELATION_ID}
|
||||
error={errors['subActionParams.incident.correlation_id']}
|
||||
isInvalid={
|
||||
errors['subActionParams.incident.correlation_id'] !== undefined &&
|
||||
errors['subActionParams.incident.correlation_id'].length > 0 &&
|
||||
!correlationId &&
|
||||
selectedActionGroupId === ACTION_GROUP_RECOVERED
|
||||
}
|
||||
helpText={
|
||||
<EuiLink href={docLinks.links.alerting.serviceNowAction} target="_blank">
|
||||
<FormattedMessage
|
||||
|
@ -65,7 +80,9 @@ const CorrelationIdField: React.FunctionComponent<
|
|||
}
|
||||
labelAppend={
|
||||
<EuiText size="xs" color="subdued">
|
||||
{i18n.OPTIONAL_LABEL}
|
||||
{selectedActionGroupId !== ACTION_GROUP_RECOVERED
|
||||
? i18n.OPTIONAL_LABEL
|
||||
: i18n.REQUIRED_LABEL}
|
||||
</EuiText>
|
||||
}
|
||||
>
|
||||
|
@ -75,6 +92,7 @@ const CorrelationIdField: React.FunctionComponent<
|
|||
messageVariables={messageVariables}
|
||||
paramsProperty={'correlation_id'}
|
||||
inputTargetValue={correlationId ?? undefined}
|
||||
errors={errors['subActionParams.incident.correlation_id'] as string[]}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
);
|
||||
|
@ -297,6 +315,8 @@ const ServiceNowParamsFields: React.FunctionComponent<
|
|||
messageVariables={messageVariables}
|
||||
correlationId={incident.correlation_id}
|
||||
editSubActionProperty={editSubActionProperty}
|
||||
selectedActionGroupId={selectedActionGroupId}
|
||||
errors={errors}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
|
@ -374,6 +394,8 @@ const ServiceNowParamsFields: React.FunctionComponent<
|
|||
messageVariables={messageVariables}
|
||||
correlationId={incident.correlation_id}
|
||||
editSubActionProperty={editSubActionProperty}
|
||||
selectedActionGroupId={selectedActionGroupId}
|
||||
errors={errors}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue