Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cases] ServiceNow connectors UI changes #114234

Merged
merged 134 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from 120 commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
066f9b0
POC
cnasikas Jul 13, 2021
0cd0027
Before and after saving connector callbacks
cnasikas Jul 19, 2021
ed3f37f
Draft callbacks on SN
cnasikas Jul 19, 2021
48c9144
Migrate legacy connectors
cnasikas Jul 19, 2021
e0537c6
Add deprecated connector
cnasikas Jul 19, 2021
2ea1e10
Fix callbacks types
cnasikas Jul 19, 2021
c16d69d
Pass isEdit to connector forms
cnasikas Jul 19, 2021
5689c65
Get application info hook
cnasikas Jul 19, 2021
748204e
Validate instance on save
cnasikas Jul 19, 2021
09be958
Support both legacy and new app
cnasikas Jul 20, 2021
518011f
Seperate SIR
cnasikas Jul 20, 2021
503755b
Log application version & and throw otherwise
cnasikas Jul 20, 2021
8962a49
Deprecated tooltip cases
cnasikas Jul 20, 2021
3685dd1
Deprecated tooltip alerts
cnasikas Jul 20, 2021
0fb1807
Improve message
cnasikas Jul 21, 2021
6e677e1
Improve translation
cnasikas Jul 25, 2021
fdb8fc8
Change to elastic table & fix types
cnasikas Aug 5, 2021
688f83d
Add callbacks to add modal
cnasikas Aug 5, 2021
44f0e23
Pass new props to tests
cnasikas Aug 5, 2021
4775d62
Change health api url to production
cnasikas Aug 5, 2021
9e56803
Better installation message
cnasikas Aug 5, 2021
b5eef2f
Migrate connectors functionality
cnasikas Aug 5, 2021
f4ca823
Change migration version to 7.16
cnasikas Aug 31, 2021
8651cc7
Fix bug
cnasikas Aug 31, 2021
484156b
Improve message
cnasikas Sep 1, 2021
1d1b4e7
Use feature flag
cnasikas Sep 3, 2021
1c1ea44
Create credentials component
cnasikas Sep 7, 2021
bbcdf03
Add form to migration modal
cnasikas Sep 7, 2021
569c5fc
Improve installation callout
cnasikas Sep 16, 2021
d29e4a7
Improve deprecated callout
cnasikas Sep 16, 2021
9354925
Improve modal
cnasikas Sep 16, 2021
79c56cb
Improve application required modal
cnasikas Sep 16, 2021
24a6d21
Improve SN form
cnasikas Sep 16, 2021
3d220c4
Support both connectors
cnasikas Sep 18, 2021
8086ce1
Support correlation attributes
cnasikas Sep 18, 2021
c05a4cb
Use same component for SIR
cnasikas Sep 18, 2021
ec7bfb7
Prevent using legacy connectors when creating a case
cnasikas Sep 18, 2021
729c8e9
Add observables
cnasikas Sep 21, 2021
4d22f7a
Unique observables
cnasikas Sep 21, 2021
1ba41d7
Push only if there are observables
cnasikas Sep 21, 2021
783e44e
Change labels to plural
cnasikas Sep 27, 2021
b9f95e0
Pass correlation ID and value
cnasikas Sep 27, 2021
6df9ed3
Show errors on the callout
cnasikas Sep 27, 2021
9c8ebf2
Improve alerts tooltip
cnasikas Sep 27, 2021
47fc26a
Improve cases tooltip
cnasikas Sep 27, 2021
3c0b9db
Warning callout on cases configuration page
cnasikas Sep 27, 2021
c306206
Fix tooltip content
cnasikas Sep 27, 2021
3a17b5f
Add help text
cnasikas Sep 27, 2021
4129666
Change from string to array
cnasikas Sep 27, 2021
caa4292
Fix i18n
cnasikas Sep 27, 2021
a855d0f
Fix spelling
cnasikas Sep 28, 2021
3af5428
Update incidents for ITSM
cnasikas Sep 28, 2021
e446115
Update incidents for SIR
cnasikas Sep 28, 2021
6a3db84
Fix types
cnasikas Sep 28, 2021
59fee89
Fix backend tests
cnasikas Sep 28, 2021
6d95208
Fix frontend tests
cnasikas Sep 28, 2021
8711f17
Add service tests
cnasikas Sep 28, 2021
394acb4
Fix i18n
cnasikas Sep 28, 2021
378fe22
Merge branch 'master' into sn_import_set
kibanamachine Sep 28, 2021
955b1a6
Fix cypress test
cnasikas Sep 28, 2021
b250d23
Improve ServiceNow intergration tests
cnasikas Sep 29, 2021
b57fd00
Fix cases integration tests
cnasikas Sep 29, 2021
224eca1
Fix triggers actions ui end to end test
cnasikas Sep 29, 2021
d355074
Fix tests
cnasikas Sep 29, 2021
6782970
Rename modal
cnasikas Sep 29, 2021
0d48027
Show error message on modal
cnasikas Sep 29, 2021
b051285
Create useOldConnector helper
cnasikas Sep 29, 2021
c4b1865
Show the update incident toggle only on new connectors
cnasikas Sep 29, 2021
5ae1eb4
Add observables for old connectors
cnasikas Sep 29, 2021
6ddd323
Fix error when obs are empty
cnasikas Sep 29, 2021
a5bec1f
Enable SIR for alerts
cnasikas Sep 29, 2021
3ae7b4d
Fix types
cnasikas Sep 29, 2021
7f33adc
Improve combineObservables
cnasikas Sep 30, 2021
bdd26ce
Add test for the sir api
cnasikas Sep 30, 2021
2119f85
Add test for the sir service
cnasikas Sep 30, 2021
6777b94
Add documentation
cnasikas Sep 30, 2021
79dcb32
Merge branch 'master' into sn_import_set
cnasikas Sep 30, 2021
196c13e
PR feedback
cnasikas Oct 1, 2021
baa7834
Improve cases deprecated callouts
cnasikas Oct 1, 2021
33ce596
Improve observables format
cnasikas Oct 1, 2021
e2b6de2
Add integration tests for SIR
cnasikas Oct 1, 2021
cca7e80
Merge branch 'master' into sn_import_set
cnasikas Oct 4, 2021
1951495
Fix doc error
cnasikas Oct 4, 2021
dd9977c
Add config tests
cnasikas Oct 4, 2021
3932eb3
Add getIncident tests
cnasikas Oct 4, 2021
91ced67
Add util tests
cnasikas Oct 4, 2021
139ede7
Add migration tests
cnasikas Oct 4, 2021
b7f5bd2
Add tests for connectors and improve callouts
cnasikas Oct 4, 2021
da3358e
Add more tests
cnasikas Oct 4, 2021
8fead64
Add more UI tests
cnasikas Oct 5, 2021
70553f4
Merge branch 'master' into sn_import_set
kibanamachine Oct 5, 2021
4da14e8
Merge branch 'master' into sn_import_set
kibanamachine Oct 6, 2021
73700f2
Merge branch 'master' into sn_import_set
kibanamachine Oct 6, 2021
5609160
update connector modal to flyout
semd Oct 6, 2021
6d75546
PR feedback
cnasikas Oct 7, 2021
d2b1443
Test CI
cnasikas Oct 7, 2021
4bcb00c
restore auth callout
semd Oct 7, 2021
23ef65d
edit connector form spacing
semd Oct 7, 2021
44cdf20
Improve integration tests
cnasikas Oct 7, 2021
747fbc4
Add 8 pixels to the left of the connector icon
jonathan-buttner Oct 7, 2021
0942beb
update switch to checkboxes
semd Oct 7, 2021
843768a
case detail ui
semd Oct 7, 2021
9037947
Merge branch '1769_connectors_ui_changes' of https://github.com/semd/…
semd Oct 7, 2021
c6f3a80
Merge remote-tracking branch 'upstream/master' into 1769_connectors_u…
semd Oct 7, 2021
766dcf6
Seperate ServiceNow integration tests
cnasikas Oct 11, 2021
409e31d
Merge branch 'master' into sn_import_set
cnasikas Oct 11, 2021
23d0602
Merge branch 'sn_import_set' into 1769_connectors_ui_changes
cnasikas Oct 11, 2021
3a21b82
Remove observables fields
cnasikas Oct 11, 2021
00369a8
Add correlation values
cnasikas Oct 11, 2021
bcf96d0
Merge branch 'master' into 1769_connectors_ui_changes
cnasikas Oct 12, 2021
dd365da
Fix merge
cnasikas Oct 13, 2021
2fa7a35
add deprecated text in the dropdown
semd Oct 13, 2021
e85f62d
update card icon to the right
semd Oct 13, 2021
22feff2
new update connetor test and other tests fixes
semd Oct 13, 2021
cbfc7c2
PR feedback
cnasikas Oct 14, 2021
74086bd
Remove observables from docs
cnasikas Oct 14, 2021
2c9a2ae
Merge branch '1769_connectors_ui_changes' of github.com:semd/kibana i…
cnasikas Oct 14, 2021
4166a02
Remove unused translations
cnasikas Oct 14, 2021
823822a
Using eui theme for styling
jonathan-buttner Oct 14, 2021
271ed07
Merge branch 'master' into 1769_connectors_ui_changes
kibanamachine Oct 14, 2021
4e7c3da
Content feeback
cnasikas Oct 15, 2021
0611158
Add more unit tests
cnasikas Oct 15, 2021
d05ec41
Fix i18n
cnasikas Oct 15, 2021
14f5aab
Fix types
cnasikas Oct 15, 2021
2937675
Fixes
cnasikas Oct 15, 2021
61bd516
Fixes
cnasikas Oct 15, 2021
0e8a733
test properly
semd Oct 15, 2021
e801905
Merge branch '1769_connectors_ui_changes' of https://github.com/semd/…
semd Oct 15, 2021
ca267fb
fix duplicated translation
semd Oct 15, 2021
a2a60b9
Merge branch '1769_connectors_ui_changes' of github.com:semd/kibana i…
cnasikas Oct 15, 2021
ad06a2e
Simplify tooltip
cnasikas Oct 15, 2021
dddfee4
Writing feedback
cnasikas Oct 18, 2021
58eb4ab
Merge branch 'master' into 1769_connectors_ui_changes
cnasikas Oct 18, 2021
f17f629
Fix test
cnasikas Oct 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,11 @@ image::management/connectors/images/servicenow-sir-params-test.png[ServiceNow Se
ServiceNow SecOps actions have the following configuration properties.

Short description:: A short description for the incident, used for searching the contents of the knowledge base.
Source Ips:: A list of source IPs related to the incident. The IPs will be added as observables to the security incident.
Destination Ips:: A list of destination IPs related to the incident. The IPs will be added as observables to the security incident.
Malware URLs:: A list of malware URLs related to the incident. The URLs will be added as observables to the security incident.
Malware Hashes:: A list of malware hashes related to the incident. The hashes will be added as observables to the security incident.
Priority:: The priority of the incident.
Category:: The category of the incident.
Subcategory:: The subcategory of the incident.
Correlation ID:: All actions sharing this ID will be associated with the same ServiceNow security incident. If an incident exists in ServiceNow with the same correlation ID the security incident will be updated. Default value: `<rule ID>:<alert instance ID>`.
Correlation Display:: A descriptive label of the alert for correlation purposes in ServiceNow.
Description:: The details about the incident.
Additional comments:: Additional information for the client, such as how to troubleshoot the issue.

Expand Down
2 changes: 2 additions & 0 deletions docs/management/connectors/action-types/servicenow.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Severity:: The severity of the incident.
Impact:: The effect an incident has on business. Can be measured by the number of affected users or by how critical it is to the business in question.
Category:: The category of the incident.
Subcategory:: The category of the incident.
Correlation ID:: All actions sharing this ID will be associated with the same ServiceNow incident. If an incident exists in ServiceNow with the same correlation ID the incident will be updated. Default value: `<rule ID>:<alert instance ID>`.
Correlation Display:: A descriptive label of the alert for correlation purposes in ServiceNow.
Short description:: A short description for the incident, used for searching the contents of the knowledge base.
Description:: The details about the incident.
Additional comments:: Additional information for the client, such as how to troubleshoot the issue.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ export class DocLinksService {
preconfiguredConnectors: `${KIBANA_DOCS}pre-configured-connectors.html`,
preconfiguredAlertHistoryConnector: `${KIBANA_DOCS}index-action-type.html#preconfigured-connector-alert-history`,
serviceNowAction: `${KIBANA_DOCS}servicenow-action-type.html#configuring-servicenow`,
serviceNowSIRAction: `${KIBANA_DOCS}servicenow-sir-action-type.html`,
setupPrerequisites: `${KIBANA_DOCS}alerting-setup.html#alerting-prerequisites`,
slackAction: `${KIBANA_DOCS}slack-action-type.html#configuring-slack`,
teamsAction: `${KIBANA_DOCS}teams-action-type.html#configuring-teams`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,13 @@ describe('ConnectorsDropdown', () => {
>
<span>
My Connector
(deprecated)
</span>
</EuiFlexItem>
<EuiFlexItem
grow={false}
>
<EuiIconTip
<Styled(EuiIconTip)
aria-label="Deprecated connector"
color="warning"
content="Please update your connector"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ActionConnector } from '../../containers/configure/types';
import * as i18n from './translations';
import { useKibana } from '../../common/lib/kibana';
import { getConnectorIcon, isLegacyConnector } from '../utils';
import { euiStyled } from '../../../../../../src/plugins/kibana_react/common';

export interface Props {
connectors: ActionConnector[];
Expand Down Expand Up @@ -57,6 +58,11 @@ const addNewConnector = {
'data-test-subj': 'dropdown-connector-add-connector',
};

const StyledEuiIconTip = euiStyled(EuiIconTip)`
margin-left: ${({ theme }) => theme.eui.euiSizeS}
margin-bottom: 0 !important;
`;

const ConnectorsDropdownComponent: React.FC<Props> = ({
connectors,
disabled,
Expand Down Expand Up @@ -87,11 +93,14 @@ const ConnectorsDropdownComponent: React.FC<Props> = ({
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<span>{connector.name}</span>
<span>
{connector.name}
{isLegacyConnector(connector) && ` (${i18n.DEPRECATED_TOOLTIP_TEXT})`}
</span>
</EuiFlexItem>
{isLegacyConnector(connector) && (
<EuiFlexItem grow={false}>
<EuiIconTip
<StyledEuiIconTip
aria-label={i18n.DEPRECATED_TOOLTIP_TITLE}
size={ICON_SIZE}
type="alert"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ export const DEPRECATED_TOOLTIP_TITLE = i18n.translate(
}
);

export const DEPRECATED_TOOLTIP_TEXT = i18n.translate(
'xpack.cases.configureCases.deprecatedTooltipText',
{
defaultMessage: 'deprecated',
}
);

export const DEPRECATED_TOOLTIP_CONTENT = i18n.translate(
'xpack.cases.configureCases.deprecatedTooltipContent',
{
Expand Down
26 changes: 15 additions & 11 deletions x-pack/plugins/cases/public/components/connectors/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { memo, useMemo } from 'react';
import { EuiCard, EuiIcon, EuiLoadingSpinner } from '@elastic/eui';
import { EuiCard, EuiFlexGroup, EuiFlexItem, EuiIcon, EuiLoadingSpinner } from '@elastic/eui';
import styled from 'styled-components';

import { ConnectorTypes } from '../../../common';
Expand Down Expand Up @@ -59,16 +59,20 @@ const ConnectorCardDisplay: React.FC<ConnectorCardProps> = ({
<>
{isLoading && <EuiLoadingSpinner data-test-subj="connector-card-loading" />}
{!isLoading && (
<EuiCard
data-test-subj={`connector-card`}
description={description}
display="plain"
icon={icon}
layout="horizontal"
paddingSize="none"
title={title}
titleSize="xs"
/>
<EuiFlexGroup direction="row">
<EuiFlexItem>
<EuiCard
data-test-subj={`connector-card`}
description={description}
display="plain"
layout="horizontal"
paddingSize="none"
title={title}
titleSize="xs"
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>{icon}</EuiFlexItem>
</EuiFlexGroup>
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const ServiceNowITSMFieldsComponent: React.FunctionComponent<
{showConnectorWarning && (
<EuiFlexGroup>
<EuiFlexItem>
<DeprecatedCallout type={isEdit ? 'danger' : 'warning'} />
<DeprecatedCallout />
</EuiFlexItem>
</EuiFlexGroup>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const ServiceNowSIRFieldsComponent: React.FunctionComponent<
{showConnectorWarning && (
<EuiFlexGroup>
<EuiFlexItem>
<DeprecatedCallout type={isEdit ? 'danger' : 'warning'} />
<DeprecatedCallout />
</EuiFlexItem>
</EuiFlexGroup>
)}
Expand Down
4 changes: 0 additions & 4 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -25008,11 +25008,8 @@
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.categoryTitle": "カテゴリー",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.commentsTextAreaFieldLabel": "追加のコメント",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.descriptionTextAreaFieldLabel": "説明",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.destinationIPTitle": "デスティネーション IP",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.impactSelectFieldLabel": "インパクト",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.invalidApiUrlTextField": "URL が無効です。",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.malwareHashTitle": "マルウェアハッシュ",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.malwareURLTitle": "マルウェアURL",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.passwordTextFieldLabel": "パスワード",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.prioritySelectFieldLabel": "優先度",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.reenterValuesLabel": "ユーザー名とパスワードは暗号化されます。これらのフィールドの値を再入力してください。",
Expand All @@ -25022,7 +25019,6 @@
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.requiredUsernameTextField": "ユーザー名が必要です。",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.requireHttpsApiUrlTextField": "URL は https:// から始める必要があります。",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.severitySelectFieldLabel": "深刻度",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.sourceIPTitle": "ソース IP",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.subcategoryTitle": "サブカテゴリー",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.title": "インシデント",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.titleFieldLabel": "短い説明(必須)",
Expand Down
4 changes: 0 additions & 4 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -25436,11 +25436,8 @@
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.categoryTitle": "类别",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.commentsTextAreaFieldLabel": "其他注释",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.descriptionTextAreaFieldLabel": "描述",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.destinationIPTitle": "目标 IP",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.impactSelectFieldLabel": "影响",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.invalidApiUrlTextField": "URL 无效。",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.malwareHashTitle": "恶意软件哈希",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.malwareURLTitle": "恶意软件 URL",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.passwordTextFieldLabel": "密码",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.prioritySelectFieldLabel": "优先级",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.reenterValuesLabel": "用户名和密码已加密。请为这些字段重新输入值。",
Expand All @@ -25450,7 +25447,6 @@
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.requiredUsernameTextField": "“用户名”必填。",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.requireHttpsApiUrlTextField": "URL 必须以 https:// 开头。",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.severitySelectFieldLabel": "严重性",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.sourceIPTitle": "源 IP",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.subcategoryTitle": "子类别",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.title": "事件",
"xpack.triggersActionsUI.components.builtinActionTypes.servicenow.titleFieldLabel": "简短描述(必填)",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,13 @@
* 2.0.
*/

import React, { memo, useCallback } from 'react';
import {
EuiFlexGroup,
EuiFlexItem,
EuiFormRow,
EuiLink,
EuiFieldText,
EuiSpacer,
EuiTitle,
EuiFieldPassword,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React, { memo } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiTitle } from '@elastic/eui';
import { ActionConnectorFieldsProps } from '../../../../../public/types';
import { useKibana } from '../../../../common/lib/kibana';
import { getEncryptedFieldNotifyLabel } from '../../get_encrypted_field_notify_label';
import * as i18n from './translations';
import { ServiceNowActionConnector } from './types';
import { isFieldInvalid } from './helpers';
import { CredentialsApiUrl } from './credentials_api_url';
import { CredentialsAuth } from './credentials_auth';

interface Props {
action: ActionConnectorFieldsProps<ServiceNowActionConnector>['action'];
Expand All @@ -41,70 +30,20 @@ const CredentialsComponent: React.FC<Props> = ({
editActionSecrets,
editActionConfig,
}) => {
const { docLinks } = useKibana().services;
const { apiUrl } = action.config;
const { username, password } = action.secrets;

const isApiUrlInvalid = isFieldInvalid(apiUrl, errors.apiUrl);
const isUsernameInvalid = isFieldInvalid(username, errors.username);
const isPasswordInvalid = isFieldInvalid(password, errors.password);

const handleOnChangeActionConfig = useCallback(
(key: string, value: string) => editActionConfig(key, value),
[editActionConfig]
);

const handleOnChangeSecretConfig = useCallback(
(key: string, value: string) => editActionSecrets(key, value),
[editActionSecrets]
);

return (
<>
<EuiFlexGroup direction="column">
<EuiFlexItem>
<EuiTitle size="xxs">
<h4>{i18n.SN_INSTANCE_LABEL}</h4>
</EuiTitle>
<p>
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.serviceNowAction.apiUrlHelpLabel"
defaultMessage="Please provide the full URL to the desired ServiceNow instance. If you do not have one, you can {instance}"
values={{
instance: (
<EuiLink href={docLinks.links.alerting.serviceNowAction} target="_blank">
{i18n.SETUP_DEV_INSTANCE}
</EuiLink>
),
}}
/>
</p>
</EuiFlexItem>
<EuiFlexItem>
<EuiFormRow
id="apiUrl"
fullWidth
error={errors.apiUrl}
isInvalid={isApiUrlInvalid}
label={i18n.API_URL_LABEL}
helpText={i18n.API_URL_HELPTEXT}
>
<EuiFieldText
fullWidth
isInvalid={isApiUrlInvalid}
name="apiUrl"
readOnly={readOnly}
value={apiUrl || ''} // Needed to prevent uncontrolled input error when value is undefined
data-test-subj="apiUrlFromInput"
onChange={(evt) => handleOnChangeActionConfig('apiUrl', evt.target.value)}
onBlur={() => {
if (!apiUrl) {
editActionConfig('apiUrl', '');
}
}}
disabled={isLoading}
/>
</EuiFormRow>
<CredentialsApiUrl
action={action}
errors={errors}
readOnly={readOnly}
isLoading={isLoading}
editActionConfig={editActionConfig}
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="m" />
Expand All @@ -115,75 +54,15 @@ const CredentialsComponent: React.FC<Props> = ({
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="m" />
<EuiFlexGroup>
<EuiFlexItem>
<EuiFormRow fullWidth>
{getEncryptedFieldNotifyLabel(
!action.id,
2,
action.isMissingSecrets ?? false,
i18n.REENTER_VALUES_LABEL
)}
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="m" />
<EuiFlexGroup>
<EuiFlexItem>
<EuiFormRow
id="connector-servicenow-username"
fullWidth
error={errors.username}
isInvalid={isUsernameInvalid}
label={i18n.USERNAME_LABEL}
>
<EuiFieldText
fullWidth
isInvalid={isUsernameInvalid}
readOnly={readOnly}
name="connector-servicenow-username"
value={username || ''} // Needed to prevent uncontrolled input error when value is undefined
data-test-subj="connector-servicenow-username-form-input"
onChange={(evt) => handleOnChangeSecretConfig('username', evt.target.value)}
onBlur={() => {
if (!username) {
editActionSecrets('username', '');
}
}}
disabled={isLoading}
/>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="m" />
<EuiFlexGroup>
<EuiFlexItem>
<EuiFormRow
id="connector-servicenow-password"
fullWidth
error={errors.password}
isInvalid={isPasswordInvalid}
label={i18n.PASSWORD_LABEL}
>
<EuiFieldPassword
fullWidth
readOnly={readOnly}
isInvalid={isPasswordInvalid}
name="connector-servicenow-password"
value={password || ''} // Needed to prevent uncontrolled input error when value is undefined
data-test-subj="connector-servicenow-password-form-input"
onChange={(evt) => handleOnChangeSecretConfig('password', evt.target.value)}
onBlur={() => {
if (!password) {
editActionSecrets('password', '');
}
}}
disabled={isLoading}
/>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
<EuiFlexItem>
<CredentialsAuth
action={action}
errors={errors}
readOnly={readOnly}
isLoading={isLoading}
editActionSecrets={editActionSecrets}
/>
</EuiFlexItem>
</>
);
};
Expand Down
Loading