Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Mar 17, 2020
1 parent 584824f commit b78ca8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions x-pack/legacy/plugins/siem/public/lib/connectors/servicenow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export function getActionType(): ActionTypeModel {
const ServiceNowConnectorFields: React.FunctionComponent<ActionConnectorFieldsProps<
ServiceNowActionConnector
>> = ({ action, editActionConfig, editActionSecrets, errors }) => {
/* We do not provide defaults values to the fields (like empty string for apiUrl) intentionally.
* If we do, errors will be shown the first time the flyout is open even though the user did not
* interact with the form. Also, we would like to show errors for empty fields provided by the user.
/*/
const { apiUrl, casesConfiguration: { mapping = [] } = {} } = action.config;
const { username, password } = action.secrets;

Expand Down Expand Up @@ -153,7 +157,7 @@ const ServiceNowConnectorFields: React.FunctionComponent<ActionConnectorFieldsPr
fullWidth
isInvalid={isApiUrlInvalid}
name="apiUrl"
value={apiUrl || ''}
value={apiUrl || ''} // Needed to prevent uncontrolled input error when value is undefined
data-test-subj="apiUrlFromInput"
placeholder="https://<instance>.service-now.com"
onChange={handleOnChangeActionConfig.bind(null, 'apiUrl')}
Expand All @@ -175,7 +179,7 @@ const ServiceNowConnectorFields: React.FunctionComponent<ActionConnectorFieldsPr
fullWidth
isInvalid={isUsernameInvalid}
name="username"
value={username || ''}
value={username || ''} // Needed to prevent uncontrolled input error when value is undefined
data-test-subj="usernameFromInput"
onChange={handleOnChangeSecretConfig.bind(null, 'username')}
onBlur={handleOnBlurSecretConfig.bind(null, 'username')}
Expand All @@ -196,7 +200,7 @@ const ServiceNowConnectorFields: React.FunctionComponent<ActionConnectorFieldsPr
fullWidth
isInvalid={isPasswordInvalid}
name="password"
value={password || ''}
value={password || ''} // Needed to prevent uncontrolled input error when value is undefined
data-test-subj="passwordFromInput"
onChange={handleOnChangeSecretConfig.bind(null, 'password')}
onBlur={handleOnBlurSecretConfig.bind(null, 'password')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const ConfigureCasesComponent: React.FC = () => {
});
const { loading: isLoadingConnectors, connectors, refetchConnectors } = useConnectors();

// ActionsConnectorsContextProvider reloadConnectors prop expects a Promise<void>.
// TODO: Fix it if reloadConnectors type change.
const reloadConnectors = useCallback(async () => refetchConnectors(), []);
const isLoadingAny = isLoadingConnectors || persistLoading || loadingCaseConfigure;
const updateConnectorDisabled = isLoadingAny || !connectorIsValid || connectorId === 'none';
Expand Down

0 comments on commit b78ca8b

Please sign in to comment.