Skip to content

Commit

Permalink
Merge pull request #10076 from openshift-cherrypick-robot/cherry-pick…
Browse files Browse the repository at this point in the history
…-10013-to-release-4.9

[release-4.9] Bug 2004567: Fix basic spring boot sample form crash
  • Loading branch information
openshift-merge-robot committed Oct 22, 2021
2 parents 318f5a8 + fff4f52 commit 8e192ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
Expand Up @@ -181,7 +181,7 @@ const GitSection: React.FC<GitSectionProps> = ({
setFieldValue('devfile.devfileHasError', true);
return;
}
if (!values.devfile?.devfileSourceUrl) {
if (importType !== 'devfile' && !values.devfile?.devfileSourceUrl) {
setFieldValue('devfile.devfilePath', devfilePath);
setFieldValue('docker.dockerfilePath', 'Dockerfile');
const gitService = getGitService(
Expand All @@ -204,6 +204,7 @@ const GitSection: React.FC<GitSectionProps> = ({
},
[
gitUrlError,
importType,
setFieldValue,
values.devfile,
values.git.dir,
Expand All @@ -227,10 +228,9 @@ const GitSection: React.FC<GitSectionProps> = ({
setFieldValue('git.isUrlValidating', false);
return;
}

const detectedGitType = detectGitType(url);
const gitType = values.git.showGitType ? values.git.type : detectedGitType;
const gitRepoName = detectGitRepoName(url);
const gitRepoName = formType !== 'sample' && detectGitRepoName(url);

// Updated detectedType only
if (detectedGitType !== values.git.detectedType) {
Expand Down Expand Up @@ -292,14 +292,14 @@ const GitSection: React.FC<GitSectionProps> = ({
values.application.selectedKey !== UNASSIGNED_KEY &&
setFieldValue('application.name', `${gitRepoName}-app`);

if (
(importType === 'devfile' && values.devfile?.devfileContent) ||
imageStreamName ||
values.formType === 'edit'
) {
if (importType === 'devfile' || imageStreamName || values.formType === 'edit') {
setValidated(ValidatedOptions.success);
setFieldValue('git.validated', ValidatedOptions.success);
setFieldValue('git.isUrlValidating', false);
importType === 'devfile' && setFieldValue('build.strategy', BuildStrategyType.Devfile);
importType === 'devfile' &&
!values.devfile?.devfileContent &&
setFieldValue('import.recommendedStrategy', importStrategies[0]);
values.formType === 'edit' &&
values.build.strategy === BuildStrategyType.Source &&
handleBuilderImageRecommendation(
Expand Down Expand Up @@ -372,6 +372,7 @@ const GitSection: React.FC<GitSectionProps> = ({
values.application.name,
values.application.selectedKey,
values.build.strategy,
formType,
nameTouched,
importType,
imageStreamName,
Expand All @@ -392,8 +393,8 @@ const GitSection: React.FC<GitSectionProps> = ({
setFieldValue('git.dir', dir);
setFieldValue('git.ref', ref);
setFieldTouched('git.url', true);
debouncedHandleGitUrlChange(url, ref, dir);
}, [debouncedHandleGitUrlChange, sampleRepo, setFieldTouched, setFieldValue, tag]);
handleGitUrlChange(url, ref, dir);
}, [handleGitUrlChange, sampleRepo, setFieldTouched, setFieldValue, tag]);

React.useEffect(() => {
(!dirty || gitDirTouched) &&
Expand Down Expand Up @@ -506,7 +507,7 @@ const GitSection: React.FC<GitSectionProps> = ({
)}
</>
)}
<AdvancedGitOptions formContextField={formContextField} />
{formType !== 'sample' && <AdvancedGitOptions formContextField={formContextField} />}
</FormSection>
);
};
Expand Down
Expand Up @@ -65,9 +65,13 @@ export const detectGitType = (url: string): GitTypes => {
};

export const createComponentName = (nameString: string): string => {
if (nameRegex.test(nameString)) {
return nameString;
}
try {
if (nameRegex.test(nameString)) {
return nameString;
}
// eslint-disable-next-line no-empty
} catch {}

const kebabCaseStr = _.kebabCase(nameString);
return nameString.match(/^\d/) || kebabCaseStr.match(/^\d/)
? `ocp-${kebabCaseStr}`
Expand Down

0 comments on commit 8e192ea

Please sign in to comment.