Skip to content

Commit

Permalink
containers: Always ignore validation errors for empty slots in ImageR…
Browse files Browse the repository at this point in the history
…unModal

This is the same fix as in 07197e5 for PodCreateModal.
  • Loading branch information
mvollmer committed Oct 21, 2024
1 parent 51690a7 commit def5f36
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/ImageRunModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -652,14 +652,25 @@ export class ImageRunModal extends React.Component {
};

isFormInvalid = validationFailed => {
const groupHasError = row => row && Object.values(row)
.filter(val => val) // Filter out empty/undefined properties
.length > 0; // If one field has error, the whole group (dynamicList) is invalid

function checkGroup(validation, values) {
function rowHasError(row, idx) {
// We always ignore errors for empty slots in
// "values". Errors for these slots might show up when
// the debounced validation runs after a row has been
// removed.
if (!row || !values[idx])
return false;

return Object.values(row)
.filter(val => val) // Filter out empty/undefined properties
.length > 0; // If one field has error, the whole group (dynamicList) is invalid
}
return validation && validation.some(rowHasError);
}
// If at least one group is invalid, then the whole form is invalid
return validationFailed.publish?.some(groupHasError) ||
validationFailed.volumes?.some(groupHasError) ||
validationFailed.env?.some(groupHasError) ||
return checkGroup(validationFailed.publish, this.state.publish) ||
checkGroup(validationFailed.volumes, this.state.volumes) ||
checkGroup(validationFailed.env, this.state.env) ||
!!validationFailed.containerName;
};

Expand Down

0 comments on commit def5f36

Please sign in to comment.