Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix [Batch run] unable to rerun batch job - blocked on 'Run Details' step #290

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
}