Skip to content

Commit

Permalink
fix(code): ADDON-46211 Fiixed the issue to set the dynmic placeholder (
Browse files Browse the repository at this point in the history
  • Loading branch information
tbalar-splunk committed Oct 13, 2022
1 parent 560509d commit 37e5488
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
14 changes: 14 additions & 0 deletions ui/src/main/webapp/components/BaseFormView.jsx
Expand Up @@ -1064,6 +1064,20 @@ class BaseFormView extends PureComponent {
};
}

// Add 'optional' placeholder for optional field
// Note: for oauth field it is possible required is false but the field is actually required
// based on what type of authentication is selected
if (
!e.required &&
!Object.prototype.hasOwnProperty.call(e, 'oauth_field') &&
!e.options?.placeholder
) {
e.options = {
...e.options,
placeholder: 'optional',
};
}

return (
<ControlWrapper
key={e.field}
Expand Down
46 changes: 16 additions & 30 deletions ui/src/main/webapp/components/ControlWrapper.jsx
Expand Up @@ -33,20 +33,6 @@ class ControlWrapper extends React.PureComponent {
this.controlType = this.isString(props.entity.type)
? CONTROL_TYPE_MAP[props.entity.type]
: null;
// Add 'optional' placeholder for optional field
// Note: for oauth field it is possible required is false but the field is actually required
// based on what type of authentication is selected
this.options = this.props.entity.options;
if (
!this.props.entity.required &&
!Object.prototype.hasOwnProperty.call(this.props.entity, 'oauth_field') &&
!this.options?.placeholder
) {
this.options = {
...this.options,
placeholder: 'optional',
};
}
}

isString = (str) => {
Expand All @@ -70,26 +56,26 @@ class ControlWrapper extends React.PureComponent {

rowView = this.controlType
? React.createElement(this.controlType, {
data,
field,
handleChange,
addCustomValidator,
utilCustomFunctions,
controlOptions: this.options,
})
data,
field,
handleChange,
addCustomValidator,
utilCustomFunctions,
controlOptions: this.props.entity.options,
})
: `No View Found for ${type} type`;
} else {
rowView = this.controlType
? React.createElement(this.controlType, {
handleChange,
value: this.props.value,
field,
controlOptions: this.options,
error: this.props.error,
disabled: this.props.disabled,
encrypted,
dependencyValues: this.props.dependencyValues,
})
handleChange,
value: this.props.value,
field,
controlOptions: this.props.entity.options,
error: this.props.error,
disabled: this.props.disabled,
encrypted,
dependencyValues: this.props.dependencyValues,
})
: `No View Found for ${type} type`;
}

Expand Down

0 comments on commit 37e5488

Please sign in to comment.