@@ -5,10 +5,11 @@ import moment from 'moment'
55import React , { Component } from 'react'
66import { Button , ButtonToolbar , MenuItem } from 'react-bootstrap'
77import { Link } from 'react-router'
8+ import { connect } from 'react-redux'
89
910import * as versionsActions from '../../actions/versions'
1011import { BLOCKING_ERROR_TYPES } from '../../util/version'
11- import type { Feed , FeedVersion , FeedVersionSummary , GtfsPlusValidation } from '../../../types'
12+ import type { Feed , FeedVersion , FeedVersionSummary , GtfsPlusValidation , ServerJob } from '../../../types'
1213import type { ManagerUserState } from '../../../types/reducers'
1314
1415import VersionRetrievalBadge from './VersionRetrievalBadge'
@@ -17,6 +18,7 @@ import VersionSelectorDropdown from './VersionSelectorDropdown'
1718export type Props = {
1819 feedSource : Feed ,
1920 gtfsPlusValidation : GtfsPlusValidation ,
21+ jobs ?: Array < ServerJob > ,
2022 mergeVersions : typeof versionsActions . mergeVersions ,
2123 publishFeedVersion : typeof versionsActions . publishFeedVersion ,
2224 user : ManagerUserState ,
@@ -72,7 +74,7 @@ function checkBlockingIssue (version: FeedVersion): boolean {
7274 ! ! ( errorCounts . find ( ec => BLOCKING_ERROR_TYPES . indexOf ( ec . type ) !== - 1 ) )
7375}
7476
75- export default class FeedVersionActionsMTC extends Component < Props > {
77+ class FeedVersionActionsMTC extends Component < Props > {
7678 _handleMergeVersion : ( ( versionId : string ) => void ) = ( versionId : string ) => {
7779 // Note: service period feed merge has only been extensively tested with
7880 // MTC-specific logic.
@@ -85,6 +87,7 @@ export default class FeedVersionActionsMTC extends Component<Props> {
8587 const {
8688 feedSource,
8789 gtfsPlusValidation,
90+ jobs,
8891 user,
8992 version
9093 } = this . props
@@ -106,6 +109,8 @@ export default class FeedVersionActionsMTC extends Component<Props> {
106109 const end = + moment ( summary . endDate )
107110 const expired = end < now
108111
112+ const jobsProcessingThisVersion = jobs && jobs . some ( job => job . feedVersionId === version . id )
113+
109114 const publishButtonDisabled = ! gtfsPlusValidation ||
110115 hasGtfsPlusBlockingIssue ||
111116 ! gtfsPlusValidation . published ||
@@ -115,7 +120,8 @@ export default class FeedVersionActionsMTC extends Component<Props> {
115120 hasBlockingIssue ||
116121 isPublished ||
117122 processing ||
118- ! userCanManageFeed ( user , version )
123+ ! userCanManageFeed ( user , version ) ||
124+ jobsProcessingThisVersion
119125
120126 let publishWarningMessage
121127 if ( hasBlockingIssue || hasGtfsPlusBlockingIssue ) {
@@ -185,3 +191,9 @@ export default class FeedVersionActionsMTC extends Component<Props> {
185191 )
186192 }
187193}
194+
195+ const mapStateToProps = state => ( {
196+ jobs : state . status . jobMonitor . jobs
197+ } )
198+
199+ export default connect ( mapStateToProps ) ( FeedVersionActionsMTC )
0 commit comments