diff --git a/frontend/web/components/pages/ChangeRequestPage.js b/frontend/web/components/pages/ChangeRequestPage.js index 9d69cbfc97e6..579b3cc6c581 100644 --- a/frontend/web/components/pages/ChangeRequestPage.js +++ b/frontend/web/components/pages/ChangeRequestPage.js @@ -148,13 +148,17 @@ const ChangeRequestsPage = class extends Component { AppActions.actionChangeRequest(this.props.match.params.id, 'approve') } + getScheduledDate = (changeRequest) => { + return changeRequest.environment_feature_versions.length > 0 + ? moment(changeRequest.environment_feature_versions[0].live_from) + : moment(changeRequest.feature_states[0].live_from) + } + publishChangeRequest = () => { const id = this.props.match.params.id const changeRequest = ChangeRequestStore.model[id] - const isScheduled = - new Date(changeRequest.feature_states[0].live_from).valueOf() > - new Date().valueOf() - const scheduledDate = moment(changeRequest.feature_states[0].live_from) + const scheduledDate = this.getScheduledDate(changeRequest) + const isScheduled = scheduledDate > moment() openConfirm({ body: ( @@ -252,11 +256,9 @@ const ChangeRequestsPage = class extends Component { orgUsers && orgUsers.find((v) => v.id === changeRequest.committed_by)) || {} - const isScheduled = - new Date(changeRequest.feature_states[0].live_from).valueOf() > - new Date().valueOf() - const scheduledDate = moment(changeRequest.feature_states[0].live_from) + const scheduledDate = this.getScheduledDate(changeRequest) + const isScheduled = scheduledDate > moment() const approval = changeRequest &&