Skip to content

Commit dbd7ae6

Browse files
committed
feat: add param required in yaml validator util
1 parent 0c8efa3 commit dbd7ae6

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

src/Pages/GlobalConfigurations/DeploymentCharts/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface DeploymentChartInfo {
2525

2626
export type DeploymentChartListDTO = DeploymentChartInfo[]
2727

28-
interface DeploymentChartVersionsType
28+
export interface DeploymentChartVersionsType
2929
extends Pick<DeploymentChartInfo, 'id' | 'version' | 'uploadedBy' | 'isUserUploaded'> {
3030
description: string
3131
}

src/Pages/GlobalConfigurations/DeploymentCharts/utils.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
*/
1616

1717
import { versionComparatorBySortOrder } from '@Shared/Helpers'
18-
import { DeploymentChartListDTO, DeploymentChartType, DEVTRON_DEPLOYMENT_CHART_NAMES } from './types'
18+
import {
19+
DeploymentChartListDTO,
20+
DeploymentChartType,
21+
DeploymentChartVersionsType,
22+
DEVTRON_DEPLOYMENT_CHART_NAMES,
23+
} from './types'
1924
import fallbackGuiSchema from './basicViewSchema.json'
2025

2126
export const convertDeploymentChartListToChartType = (data: DeploymentChartListDTO): DeploymentChartType[] => {
@@ -27,27 +32,20 @@ export const convertDeploymentChartListToChartType = (data: DeploymentChartListD
2732
if (!name || !id || !version) {
2833
return acc
2934
}
35+
const currVersionDetail: DeploymentChartVersionsType = {
36+
id,
37+
version,
38+
description: chartDescription || '',
39+
uploadedBy: isUserUploaded ? uploadedBy || '' : 'Devtron',
40+
isUserUploaded: isUserUploaded || true,
41+
}
3042
const detail = acc[name]
3143
if (detail) {
32-
detail.versions.push({
33-
id,
34-
version,
35-
description: chartDescription || '',
36-
uploadedBy: isUserUploaded ? uploadedBy || '' : 'Devtron',
37-
isUserUploaded,
38-
})
44+
detail.versions.push(currVersionDetail)
3945
} else {
4046
acc[name] = {
4147
name,
42-
versions: [
43-
{
44-
id,
45-
version,
46-
description: chartDescription || '',
47-
uploadedBy: isUserUploaded ? uploadedBy || '' : 'Devtron',
48-
isUserUploaded: isUserUploaded || true,
49-
},
50-
],
48+
versions: [currVersionDetail],
5149
}
5250
}
5351
return acc

src/Shared/validations.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,15 @@ export const validateCMVolumeMountPath = (value: string): { isValid: boolean; me
472472
return { isValid: true, message: '' }
473473
}
474474

475-
export const validateYAML = (yamlString: string): ValidationResponseType => {
475+
export const validateYAML = (yamlString: string, isRequired?: boolean): ValidationResponseType => {
476476
try {
477-
if (yamlString) {
478-
parse(yamlString)
477+
if (!yamlString && isRequired) {
478+
return {
479+
isValid: false,
480+
message: 'Empty yaml string',
481+
}
479482
}
483+
parse(yamlString)
480484
return {
481485
isValid: true,
482486
}

0 commit comments

Comments
 (0)