Skip to content

Commit

Permalink
FIX: Update time is not working for ingested events. [SDNTB-616] (#1404)
Browse files Browse the repository at this point in the history
  • Loading branch information
GyanP authored and MarkLark86 committed Jan 3, 2020
1 parent 9e584fe commit 8b571b6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions client/components/ItemActionConfirmation/forms/updateTimeForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class UpdateTimeComponent extends React.Component {
const errors = cloneDeep(this.state.errors);
let relatedEvents = this.state.relatedEvents;
let errorMessages = [];
const fieldsToValidate = Object.keys(diff);

if (field === '_startTime') {
if (value && moment.isMoment(value) && value.isValid()) {
Expand Down Expand Up @@ -118,12 +119,18 @@ export class UpdateTimeComponent extends React.Component {
set(diff, field, value);
}

if (diff.dates != null && diff.dates.tz == null) {
// if no timezone use default one
diff.dates.tz = this.props.defaultTimeZone;
}

diff[TO_BE_CONFIRMED_FIELD] = false;
this.props.onValidate(
diff,
this.props.formProfiles,
errors,
errorMessages
errorMessages,
fieldsToValidate
);

this.setState({
Expand Down Expand Up @@ -302,12 +309,14 @@ UpdateTimeComponent.propTypes = {
formProfiles: PropTypes.object,
submitting: PropTypes.bool,
modalProps: PropTypes.object,
defaultTimeZone: PropTypes.string,
};

const mapStateToProps = (state) => ({
timeFormat: getTimeFormat(state),
dateFormat: getDateFormat(state),
formProfiles: selectors.forms.profiles(state),
defaultTimeZone: selectors.config.defaultTimeZone(state),
});

const mapDispatchToProps = (dispatch) => ({
Expand All @@ -333,13 +342,14 @@ const mapDispatchToProps = (dispatch) => ({

return promise;
},
onValidate: (item, profile, errors, errorMessages) => dispatch(validateItem({
onValidate: (item, profile, errors, errorMessages, fieldsToValidate) => dispatch(validateItem({
profileName: ITEM_TYPE.EVENT,
diff: item,
formProfiles: profile,
errors: errors,
messages: errorMessages,
fields: ['dates'],
fieldsToValidate: fieldsToValidate,
})),
});

Expand Down

0 comments on commit 8b571b6

Please sign in to comment.