Skip to content

Commit

Permalink
Use key, value style arguments for onValidationChange methods
Browse files Browse the repository at this point in the history
This aligns with the comment and with how onChange works.
  • Loading branch information
jelly committed Jan 10, 2024
1 parent 2c163bb commit 9872c76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/ImageRunModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ export class ImageRunModal extends React.Component {
* - value: An array of validation errors of the form. Each item of the array represents a row of the dynamic list.
* Index needs to corellate with a row number
*/
dynamicListOnValidationChange = (value, key) => {
dynamicListOnValidationChange = (key, value) => {
const validationFailedDelta = { ...this.state.validationFailed };

validationFailedDelta[key] = value;
Expand Down Expand Up @@ -994,7 +994,7 @@ export class ImageRunModal extends React.Component {
label={_("Port mapping")}
actionLabel={_("Add port mapping")}
validationFailed={dialogValues.validationFailed.publish}
onValidationChange={value => this.dynamicListOnValidationChange(value, "publish")}
onValidationChange={value => this.dynamicListOnValidationChange('publish', value)}
onChange={value => this.onValueChanged('publish', value)}
default={{ IP: null, containerPort: null, hostPort: null, protocol: 'tcp' }}
itemcomponent={ <PublishPort />} />
Expand All @@ -1004,7 +1004,7 @@ export class ImageRunModal extends React.Component {
label={_("Volumes")}
actionLabel={_("Add volume")}
validationFailed={dialogValues.validationFailed.volumes}
onValidationChange={value => this.dynamicListOnValidationChange(value, "volumes")}
onValidationChange={value => this.dynamicListOnValidationChange('volumes', value)}
onChange={value => this.onValueChanged('volumes', value)}
default={{ containerPath: null, hostPath: null, mode: 'rw' }}
options={{ selinuxAvailable }}
Expand All @@ -1016,7 +1016,7 @@ export class ImageRunModal extends React.Component {
label={_("Environment variables")}
actionLabel={_("Add variable")}
validationFailed={dialogValues.validationFailed.env}
onValidationChange={value => this.dynamicListOnValidationChange(value, "env")}
onValidationChange={value => this.dynamicListOnValidationChange('env', value)}
onChange={value => this.onValueChanged('env', value)}
default={{ envKey: null, envValue: null }}
helperText={_("Paste one or more lines of key=value pairs into any field for bulk import")}
Expand Down
4 changes: 2 additions & 2 deletions src/PodCreateModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const PodCreateModal = ({ user, systemServiceAvailable, userServiceAvaila
* - value: An array of validation errors of the form. Each item of the array represents a row of the dynamic list.
* Index needs to corellate with a row number
*/
const dynamicListOnValidationChange = (value, key) => {
const dynamicListOnValidationChange = (key, value) => {
setValidationFailed(prevState => {
prevState[key] = value;
if (prevState[key].every(a => a === undefined))
Expand Down Expand Up @@ -178,7 +178,7 @@ export const PodCreateModal = ({ user, systemServiceAvailable, userServiceAvaila
label={_("Port mapping")}
actionLabel={_("Add port mapping")}
validationFailed={validationFailed.publish}
onValidationChange={value => dynamicListOnValidationChange(value, "publish")}
onValidationChange={value => dynamicListOnValidationChange('publish', value)}
onChange={value => setPublish(value)}
default={{ IP: null, containerPort: null, hostPort: null, protocol: 'tcp' }}
itemcomponent={ <PublishPort />} />
Expand Down

0 comments on commit 9872c76

Please sign in to comment.