Skip to content

Commit

Permalink
fix: bug fixes related to input and configuration page
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvanshus-crest committed May 17, 2021
1 parent b5eb568 commit ca21343
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
7 changes: 6 additions & 1 deletion ui/src/main/webapp/components/BaseFormView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class BaseFormView extends PureComponent {
oauth: 'OAuth 2.0 Authentication',
};
entity.options = {};
entity.options.isClearable = true;
entity.options.autoCompleteFields = authType.map((type) => {
return { label: content[type], value: type };
});
Expand Down Expand Up @@ -520,7 +521,7 @@ class BaseFormView extends PureComponent {
this.saveData();
}
};
if (this.hook && typeof this.hook.onSave === 'function') {
if (this.hook && typeof this.hook.onSave === 'function' && typeof this.onSavePromise !== 'undefined') {
this.onSavePromise.then(() => {
executeValidationSubmit();
});
Expand Down Expand Up @@ -947,6 +948,10 @@ class BaseFormView extends PureComponent {
}
const temState = this.state.data[e.field];

if(temState.placeholder) {
e = { ...e, options: { ...e.options, placeholder: temState.placeholder }}
}

return (
<ControlWrapper
key={e.field}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/webapp/components/ComboBoxWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import styled from 'styled-components';

const StyledDiv = styled.div`
div:first-child {
width: 300px !important;
width: 320px !important;
}
`;

Expand Down
7 changes: 4 additions & 3 deletions ui/src/main/webapp/components/DeleteModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class DeleteModal extends Component {
}

handleRequestClose = () => {
// set ErrorMsg to empty string on close or cancel
// so that on again open of modal it does not show the same ErrorMsg
this.state.ErrorMsg = '';
this.props.handleRequestClose();
};

Expand All @@ -43,9 +46,7 @@ class DeleteModal extends Component {
handleError: false,
})
.catch((err) => {
const errorSubmitMsg = parseErrorMsg(
err?.response?.data?.messages[0]?.text
);
const errorSubmitMsg = parseErrorMsg(err);
this.setState({ ErrorMsg: errorSubmitMsg, isDeleting: false });
return Promise.reject(err);
})
Expand Down
16 changes: 11 additions & 5 deletions ui/src/main/webapp/components/SingleInputComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function SingleInputComponent(props) {
disableSearch,
labelField,
autoCompleteFields,
isClearable,
} = controlOptions;

function handleChange(e, obj) {
Expand Down Expand Up @@ -147,11 +148,15 @@ function SingleInputComponent(props) {
>
{options && options.length > 0 && options}
</SelectWrapper>
<Button
appearance="secondary"
icon={<Clear />}
onClick={() => restProps.handleChange(field, '')}
/>
{ isClearable !== true ? (
<Button
appearance="secondary"
icon={<Clear />}
onClick={() => restProps.handleChange(field, '')}
/>
) : (
<></>
)}
</>
)}
</>
Expand All @@ -176,6 +181,7 @@ SingleInputComponent.propTypes = {
referenceName: PropTypes.string,
disableSearch: PropTypes.bool,
labelField: PropTypes.string,
isClearable: PropTypes.bool,
}),
};

Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/webapp/util/messageUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const parseErrorMsg = (err) => {
let matches;
try {
const msg = err.response.data.messages[0].text;
regex = /.+"REST Error \[[\d]+\]:\s+.+\s+--\s+([\s\S]*)"\.\s*See splunkd\.log(\/python.log)? for more details\./;
regex = /.+"REST Error \[[\d]+\]:\s+.+\s+--\s+(?:b'([\s\S]*)'|([\s\S]*))"\.\s*See splunkd\.log(\/python.log)? for more details\./;
matches = regex.exec(msg);
if (matches && matches[1]) {
try {
Expand Down

0 comments on commit ca21343

Please sign in to comment.