Skip to content

Commit

Permalink
Fix [Batch run] unable to rerun batch job - blocked on 'Run Details' …
Browse files Browse the repository at this point in the history
…step (#290)
  • Loading branch information
illia-prokopchuk authored Jun 20, 2024
1 parent 47e1df6 commit 3810d90
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/lib/components/FormChipCell/FormChipCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ const FormChipCell = ({
return errorData
}

const validateChip = ({ key, value }) => {
const validateChip = ({ key, value, disabled }) => {
const validateField = (value, field) => {
const [newRules, isValidField] = checkPatternsValidity(
validationRules[field].filter((rule) => rule.pattern),
Expand All @@ -335,7 +335,7 @@ const FormChipCell = ({
return invalidRules.map((rule) => ({ name: rule.name, label: rule.label }))
}

return [validateField(key, 'key'), validateField(value, 'value')]
return disabled ? [null, null] : [validateField(key, 'key'), validateField(value, 'value')]
}

return (
Expand Down
48 changes: 21 additions & 27 deletions src/lib/utils/validation.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,6 @@ const generateRule = {
label: ValidationConstants.REQUIRED.LABEL,
pattern: new RegExp('\\S')
}
},
checkForValidCustomLabels: (internalLabels) => {
return {
name: 'customLabels',
label: 'System-defined labels cannot be modified.',
pattern: (value) => {
return !internalLabels.includes(value)
}
}
}
}

Expand Down Expand Up @@ -381,8 +372,7 @@ const validationRules = {
generateRule.beginEndWith('a-z A-Z 0-9'),
generateRule.length({ max: 56 })
],
combobox: [generateRule.required()],
labels: [(internalLabels) => generateRule.checkForValidCustomLabels(internalLabels)]
combobox: [generateRule.required()]
},
project: {
name: [
Expand All @@ -393,10 +383,7 @@ const validationRules = {
generateRule.required()
],
labels: {
key: [
...commonRules.k8sLabels.key,
(internalLabels) => generateRule.checkForValidCustomLabels(internalLabels)
],
key: commonRules.k8sLabels.key,
value: commonRules.k8sLabels.value
},
params: {
Expand Down Expand Up @@ -431,8 +418,7 @@ const validationRules = {
key: [
generateRule.validCharactersWithPrefix('a-z A-Z 0-9 - _ .'),
generateRule.beginEndWith('a-z A-Z 0-9'),
generateRule.length({ max: 75 }),
(internalLabels) => generateRule.checkForValidCustomLabels(internalLabels)
generateRule.length({ max: 75 })
],
value: generateRule.length({ max: 255 })
}
Expand All @@ -443,23 +429,31 @@ const validationRules = {
* Returns the list of validation rules for `type`, optionally appending provided additional rules.
* @function getValidationRules
* @param {string} type - The property path to the list of validation rules.
* @param {Array.<Object>} [additionalRules] - Additional rules to append.
* @param {Array.<Object>} [customData] - Additional data to be passed to the custom rule functions.
* @param {Array.<Object> | Object} [additionalRules] - Additional rules or rule to append.
* @returns {Array.<Object>} The rule list of type `type` with `additionalRules` appended to it if provided.
*/
export const getValidationRules = (type, additionalRules, customData) => {
export const getValidationRules = (type, additionalRules) => {
return lodash
.chain(validationRules)
.get(type)
.defaultTo([])
.cloneDeep()
.map((rule) => {
if (typeof rule === 'function') {
return rule(customData)
}

return rule
})
.concat(lodash.defaultTo(additionalRules, []))
.value()
}

/**
* Creates a validation rule to ensure system-defined labels cannot be modified.
* @function getInternalLabelsValidationRule
* @param {string} internalLabels - An array of defined labels that should not be modified.
* @returns {Object} The rule that checks if a value is not in the internal labels.
*/
export const getInternalLabelsValidationRule = internalLabels => {
return {
name: 'customLabels',
label: 'System-defined labels cannot be modified.',
pattern: value => {
return !internalLabels.includes(value)
}
}
}

0 comments on commit 3810d90

Please sign in to comment.