Skip to content

Commit

Permalink
fix: enhance toast message for MODE_CONFIG, surround entity names i…
Browse files Browse the repository at this point in the history
…n double quotes and remove optional placeholder for oauth fields as its conflicting
  • Loading branch information
harshpatel-crest committed Jun 4, 2021
1 parent d450d40 commit e5fe24d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
12 changes: 9 additions & 3 deletions ui/src/main/webapp/components/BaseFormView.jsx
Expand Up @@ -124,6 +124,7 @@ class BaseFormView extends PureComponent {
this.currentInput = context.rowData[props.serviceName][props.stanzaName];
} else if (props.mode === MODE_CONFIG) {
this.currentInput = props.currentServiceState;
this.mode_config_title = tab.title;
} else {
this.currentInput = context.rowData[props.serviceName];
}
Expand Down Expand Up @@ -592,10 +593,15 @@ class BaseFormView extends PureComponent {
if (this.hook && typeof this.hook.onSaveSuccess === 'function') {
this.hook.onSaveSuccess();
}
if (this.props.mode === MODE_EDIT || this.props.mode === MODE_CONFIG) {
generateToast(`Updated ${val.name}`, 'success');
if (this.props.mode === MODE_EDIT) {
generateToast(`Updated "${val.name}"`, 'success');
} else if (this.props.mode === MODE_CONFIG) {
generateToast(
`Updated "${this.mode_config_title ? this.mode_config_title : val.name}"`,
'success'
);
} else {
generateToast(`Created ${val.name}`, 'success');
generateToast(`Created "${val.name}"`, 'success');
}
this.props.handleFormSubmit(/* isSubmitting */ false, /* closeEntity */ true);
})
Expand Down
8 changes: 7 additions & 1 deletion ui/src/main/webapp/components/ControlWrapper.jsx
Expand Up @@ -34,8 +34,14 @@ class ControlWrapper extends React.PureComponent {
? 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 && !this.options?.placeholder) {
if (
!this.props.entity.required &&
!Object.prototype.hasOwnProperty.call(this.props.entity, 'oauth_field') &&
!this.options?.placeholder
) {
this.options = {
...this.options,
placeholder: 'optional',
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/webapp/components/DeleteModal.jsx
Expand Up @@ -60,7 +60,7 @@ class DeleteModal extends Component {
);
this.setState({ isDeleting: false });
this.handleRequestClose();
generateToast(`Deleted ${this.props.stanzaName}`, 'success');
generateToast(`Deleted "${this.props.stanzaName}"`, 'success');
});
}
);
Expand Down

0 comments on commit e5fe24d

Please sign in to comment.