diff --git a/build.gradle b/build.gradle index 2a81fdd..cd8a2d5 100644 --- a/build.gradle +++ b/build.gradle @@ -118,7 +118,7 @@ shadowJar { include(dependency("org.apache.httpcomponents:httpclient-cache:.*")) include(dependency("org.apache.httpcomponents:httpcore:.*")) include(dependency("org.apache.httpcomponents:httpcore-nio:.*")) - include(dependency("org.apache.httpcomponents:httpcore-mime:.*")) + include(dependency("org.apache.httpcomponents:httpmime:.*")) include(dependency("org.glassfish.jersey.core:jersey-server:.*")) include(dependency("org.glassfish.jersey.core:jersey-common:.*")) include(dependency("jakarta.ws.rs:jakarta.ws.rs-api:.*")) diff --git a/ui/src/components/constans.js b/ui/src/components/constants.js similarity index 100% rename from ui/src/components/constans.js rename to ui/src/components/constants.js diff --git a/ui/src/components/integrationFormFields/integrationFormFields.jsx b/ui/src/components/integrationFormFields/integrationFormFields.jsx index e54f4ae..eb68c5d 100644 --- a/ui/src/components/integrationFormFields/integrationFormFields.jsx +++ b/ui/src/components/integrationFormFields/integrationFormFields.jsx @@ -1,11 +1,12 @@ import React, { useEffect } from 'react'; -import { LABELS } from '../constans'; +import { LABELS } from '../constants'; +import { btsJiraCloudUrl } from '../utils'; export const IntegrationFormFields = (props) => { const { initialize, disabled, initialData, updateMetaData, ...extensionProps } = props; const { components: { FieldErrorHint, FieldElement, FieldText, FieldTextFlex }, - validators: { requiredField, btsUrl, btsProjectKey, btsIntegrationName, email }, + validators: { requiredField, btsProjectKey, btsIntegrationName, email }, constants: { SECRET_FIELDS_KEY }, } = extensionProps; @@ -33,7 +34,7 @@ export const IntegrationFormFields = (props) => { { const { data, goToPreviousPage, onUpdate, isGlobal, ...extensionProps } = props; diff --git a/ui/src/components/utils.js b/ui/src/components/utils.js new file mode 100644 index 0000000..37fecbc --- /dev/null +++ b/ui/src/components/utils.js @@ -0,0 +1,19 @@ +const regex = (regexStr) => (value) => RegExp(regexStr).test(value); +const trimValue = (value) => (typeof value === 'string' ? value.trim() : value); +const isEmpty = (value) => { + const trimmedValue = trimValue(value); + return trimmedValue === '' || trimmedValue === undefined || trimmedValue === null; +}; +const isNotEmpty = (value) => !isEmpty(value); +const composeValidators = (validators) => (value) => + validators.every((validator) => validator(value)); + +const jiraCloudUrl = composeValidators([ + isNotEmpty, + regex(/https:\/\/[^?]*.atlassian.(net|com)\/.*/), +]); + +const bindMessageToValidator = (validator, errorMessage) => (value) => + !validator(value) ? errorMessage : undefined; + +export const btsJiraCloudUrl = bindMessageToValidator(jiraCloudUrl, 'btsUrlHint');