|
|
|
@ -34,6 +34,7 @@ interface Props {
|
|
|
|
|
baseWebhookUrl?: string;
|
|
|
|
|
webhookId?: string;
|
|
|
|
|
webhooksDocs?: string;
|
|
|
|
|
createdFromCustomTemplateId?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function GitForm({
|
|
|
|
@ -49,6 +50,7 @@ export function GitForm({
|
|
|
|
|
baseWebhookUrl,
|
|
|
|
|
webhookId,
|
|
|
|
|
webhooksDocs,
|
|
|
|
|
createdFromCustomTemplateId,
|
|
|
|
|
}: Props) {
|
|
|
|
|
const [value, setValue] = useState(initialValue); // TODO: remove this state when form is not inside angularjs
|
|
|
|
|
const webhooksDocsUrl = useDocsUrl(webhooksDocs);
|
|
|
|
@ -69,6 +71,7 @@ export function GitForm({
|
|
|
|
|
handleChange({ RepositoryURLValid: value })
|
|
|
|
|
}
|
|
|
|
|
model={value}
|
|
|
|
|
createdFromCustomTemplateId={createdFromCustomTemplateId}
|
|
|
|
|
errors={errors.RepositoryURL}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
@ -78,6 +81,7 @@ export function GitForm({
|
|
|
|
|
model={value}
|
|
|
|
|
error={errors.RepositoryReferenceName}
|
|
|
|
|
isUrlValid={value.RepositoryURLValid}
|
|
|
|
|
createdFromCustomTemplateId={createdFromCustomTemplateId}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<ComposePathField
|
|
|
|
@ -89,6 +93,7 @@ export function GitForm({
|
|
|
|
|
model={value}
|
|
|
|
|
isDockerStandalone={isDockerStandalone}
|
|
|
|
|
errors={errors.ComposeFilePathInRepository}
|
|
|
|
|
createdFromCustomTemplateId={createdFromCustomTemplateId}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{isAdditionalFilesFieldVisible && (
|
|
|
|
@ -137,16 +142,18 @@ export function GitForm({
|
|
|
|
|
|
|
|
|
|
export async function validateGitForm(
|
|
|
|
|
gitCredentials: Array<GitCredential>,
|
|
|
|
|
formValues: GitFormModel
|
|
|
|
|
formValues: GitFormModel,
|
|
|
|
|
isCreatedFromCustomTemplate: boolean
|
|
|
|
|
) {
|
|
|
|
|
return validateForm<GitFormModel>(
|
|
|
|
|
() => buildGitValidationSchema(gitCredentials),
|
|
|
|
|
() => buildGitValidationSchema(gitCredentials, isCreatedFromCustomTemplate),
|
|
|
|
|
formValues
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function buildGitValidationSchema(
|
|
|
|
|
gitCredentials: Array<GitCredential>
|
|
|
|
|
gitCredentials: Array<GitCredential>,
|
|
|
|
|
isCreatedFromCustomTemplate: boolean
|
|
|
|
|
): SchemaOf<GitFormModel> {
|
|
|
|
|
return object({
|
|
|
|
|
RepositoryURL: string()
|
|
|
|
@ -171,5 +178,7 @@ export function buildGitValidationSchema(
|
|
|
|
|
RepositoryURLValid: boolean().default(false),
|
|
|
|
|
AutoUpdate: autoUpdateValidation().nullable(),
|
|
|
|
|
TLSSkipVerify: boolean().default(false),
|
|
|
|
|
}).concat(gitAuthValidation(gitCredentials, false)) as SchemaOf<GitFormModel>;
|
|
|
|
|
}).concat(
|
|
|
|
|
gitAuthValidation(gitCredentials, false, isCreatedFromCustomTemplate)
|
|
|
|
|
) as SchemaOf<GitFormModel>;
|
|
|
|
|
}
|
|
|
|
|