{
{currentVersionData.endDate}
| {currentVersionData.errorCount} |
+ {comparisonColumn && comparisonColumn === 'PUBLISHED' &&
+
+
+ |
+ }
|
@@ -247,6 +256,7 @@ export default class FeedSourceTableRow extends PureComponent {
class FeedInfo extends PureComponent<{ feedSource: Feed, project: Project, user: ManagerUserState }> {
messages = getComponentMessages('FeedInfo')
+ /* eslint-disable complexity */
render () {
const { feedSource, project, user } = this.props
@@ -365,6 +375,103 @@ class Status extends PureComponent<{
}
}
+// TODO: a lot of duplication with FeedVersionActionsMTC.js
+
+// duplicated function from FeedVersionActionsMTC.js with a different type
+function checkBlockingIssues (feedSource: Feed): boolean {
+ if (!feedSource.latestValidation) return false
+ const errorCounts = feedSource.latestErrorCounts
+ return !!errorCounts &&
+ !!(errorCounts.find(ec => BLOCKING_ERROR_TYPES.indexOf(ec.type) !== -1))
+}
+
+class PublishStatus extends PureComponent<{
+ feedSource: Feed,
+ jobs: Array
+}> {
+ messages = getComponentMessages('PublishStatus')
+
+ render () {
+ const {feedSource, jobs} = this.props
+ const isPublished = feedSource.latestPublishedVersionId != null &&
+ feedSource.latestNamespace != null &&
+ feedSource.latestPublishedVersionId === feedSource.latestNamespace
+ const hasGtfsPlusBlockingIssue = feedSource.latestGtfsPlusValidation &&
+ feedSource.latestGtfsPlusValidation.issues &&
+ feedSource.latestGtfsPlusValidation.issues.length > 0
+ const now = +moment().startOf('day')
+ const end = feedSource.latestValidation && feedSource.latestValidation.endDate
+ ? +moment(feedSource.latestValidation.endDate)
+ : null
+ const expired = end != null ? end < now : false
+ const processing = feedSource.latestSentToExternalPublisher && !feedSource.latestProcessedByExternalPublisher
+ const jobsProcessingThisVersion = jobs && jobs.some(job => job.feedVersionId != null && job.feedVersionId === feedSource.id)
+
+ const publishingDisabled = !feedSource.latestGtfsPlusValidation ||
+ hasGtfsPlusBlockingIssue ||
+ !feedSource.latestGtfsPlusValidation.published ||
+ expired ||
+ !feedSource.latestValidation ||
+ checkBlockingIssues(feedSource) ||
+ hasGtfsPlusBlockingIssue ||
+ isPublished ||
+ processing ||
+ jobsProcessingThisVersion
+
+ if (isPublished) {
+ return (
+
+
+ {this.messages('published')}
+
+ )
+ } else if (processing) {
+ return (
+
+
+ {this.messages('publishingInProgress')}
+
+ )
+ } else if (!feedSource.latestGtfsPlusValidation) {
+ return (
+
+
+ {this.messages('no version')}
+
+ )
+ } else if (publishingDisabled) {
+ let reason = ''
+ if (hasGtfsPlusBlockingIssue) {
+ reason = this.messages('publishingDisabledBlockingIssue')
+ } else if (expired) {
+ reason = this.messages('publishingDisabledExpired')
+ } else if (!feedSource.latestGtfsPlusValidation || !feedSource.latestGtfsPlusValidation.published) {
+ reason = this.messages('publishingDisabledNotPublished')
+ } else if (!feedSource.latestValidation) {
+ reason = this.messages('publishingDisabledNoVersions')
+ } else if (jobsProcessingThisVersion) {
+ reason = this.messages('publishingDisabledProcessingJob')
+ }
+ return (
+
+
+ {this.messages('publishDisabled')}
+
+ {reason}
+
+
+ )
+ } else {
+ return (
+
+
+ {this.messages('canPublish')}
+
+ )
+ }
+ }
+}
+
class FeedActionsDropdown extends PureComponent {
messages = getComponentMessages('FeedActionsDropdown')
diff --git a/lib/manager/components/version/FeedVersionActionsMTC.js b/lib/manager/components/version/FeedVersionActionsMTC.js
index 4d0c0c53b..9f8ea0088 100644
--- a/lib/manager/components/version/FeedVersionActionsMTC.js
+++ b/lib/manager/components/version/FeedVersionActionsMTC.js
@@ -83,6 +83,7 @@ class FeedVersionActionsMTC extends Component {
_onClickPublish: (() => any) = () => this.props.publishFeedVersion(this.props.version)
+ // eslint-disable-next-line complexity
render (): React$Element<"div"> {
const {
feedSource,
diff --git a/lib/manager/containers/FeedSourceTableRow.js b/lib/manager/containers/FeedSourceTableRow.js
index 07ff9f16a..de9e06c32 100644
--- a/lib/manager/containers/FeedSourceTableRow.js
+++ b/lib/manager/containers/FeedSourceTableRow.js
@@ -12,7 +12,6 @@ import {
import {uploadFeed} from '../actions/versions'
import FeedSourceTableRow from '../components/FeedSourceTableRow'
import {getVersionValidationSummaryByFilterStrategy} from '../util/version'
-
import type {Feed, Project} from '../../types'
import type {AppState} from '../../types/reducers'
@@ -25,6 +24,7 @@ const mapStateToProps = (state: AppState, ownProps: Props) => {
const {projects, user} = state
const {feedSource, project} = ownProps
const comparisonColumn = projects.filter.feedSourceTableComparisonColumn
+ const jobs = state.status.jobMonitor.jobs
return {
comparisonColumn,
@@ -33,6 +33,7 @@ const mapStateToProps = (state: AppState, ownProps: Props) => {
feedSource,
comparisonColumn
),
+ jobs,
user
}
}
diff --git a/lib/manager/util/index.js b/lib/manager/util/index.js
index f43b1ca22..1f909a8f8 100644
--- a/lib/manager/util/index.js
+++ b/lib/manager/util/index.js
@@ -412,7 +412,7 @@ export function projectHasAtLeastOneDeployment (project: ?Project): boolean {
export function projectHasAtLeastOneFeedWithAPublishedVersion (project: ?Project): boolean {
return !!project &&
!!project.feedSources &&
- project.feedSources.some(feedSource => feedSource.publishedVersionId)
+ project.feedSources.some(feedSource => feedSource.latestPublishedVersionId)
}
export function validationState (val: ?boolean): ?string {
diff --git a/lib/style.css b/lib/style.css
index a3fc66e71..88d0d2559 100644
--- a/lib/style.css
+++ b/lib/style.css
@@ -325,6 +325,18 @@ td.feed-source-info {
background-color: #853be5;
}
+.status-unpublished {
+ background-color: #337ab7;
+}
+
+.status-publish-disabled {
+ background-color: #c9302c;
+}
+
+.status-publishing {
+ background-color: #d08600;
+}
+
.feed-status-subtext {
font-size: 12px;
margin-top: 8px;
diff --git a/lib/types/index.js b/lib/types/index.js
index 70cf72fe4..76a8f9925 100644
--- a/lib/types/index.js
+++ b/lib/types/index.js
@@ -400,9 +400,16 @@ export type FeedSourceSummary = {
isPublic: boolean,
labelIds: Array,
lastUpdated?: number,
+ latestErrorCounts?: Array,
+ latestGtfsPlusValidation?: GtfsPlusValidation,
+ latestNamespace?: ?string,
+ latestProcessedByExternalPublisher?: ?number,
+ latestPublishedVersionId?: ?string,
+ latestSentToExternalPublisher?: ?number,
latestValidation?: ValidationSummary,
name: string,
- projectId: string
+ projectId: string,
+ publishedValidationSummary?: ValidationSummary
}
export type Feed = FeedSourceSummary & {