{
+ messages = getComponentMessages('FeedSourceTableRow');
+ _interval: ?IntervalID;
+
+ constructor (props: Props) {
+ super(props)
+ this.state = { elapsed: '' }
+ this._interval = null
+ }
+
+ componentDidMount () {
+ if (this.props.publishState === 'PUBLISHING') {
+ this.updateElapsed()
+ this._interval = setInterval(this.updateElapsed, 10000)
+ }
+ }
+
+ componentDidUpdate (prevProps: Props) {
+ const wasProcessing = prevProps.publishState === 'PUBLISHING'
+ const isProcessingNow = this.props.publishState === 'PUBLISHING'
+ if (!wasProcessing && isProcessingNow) {
+ this.updateElapsed()
+ this._interval = setInterval(this.updateElapsed, 10000)
+ } else if (wasProcessing && !isProcessingNow && this._interval) {
+ clearInterval(this._interval)
+ this._interval = null
+ this.setState({ elapsed: '' })
+ }
+ }
+
+ componentWillUnmount () {
+ if (this._interval) clearInterval(this._interval)
+ }
+
+ updateElapsed = () => {
+ const ts = this.props.latestSentToExternalPublisher
+ if (!ts) {
+ this.setState({ elapsed: '' })
+ return
+ }
+ // Normalize to milliseconds
+ let ms = Number(ts)
+ if (isNaN(ms)) {
+ ms = +moment(ts)
+ }
+ if (!ms || isNaN(ms)) {
+ this.setState({ elapsed: '' })
+ return
+ }
+ const human = humanizeDuration(Date.now() - ms, { largest: 2 })
+ this.setState({ elapsed: human })
+ };
+
+ // eslint-disable-next-line complexity
+ render () {
+ const { publishState } = this.props
+ const { elapsed } = this.state
+
+ if (publishState === 'PUBLISHED') {
+ return (
+
+
+ {this.messages('status.published')}
+
+ )
+ } else if (publishState === 'PUBLISHING') {
+ return (
+ <>
+
+
+ {this.messages('status.publishingInProgress')}
+
+
+ {elapsed ? `Processing for ${elapsed}` : null}
+
+ >
+ )
+ } else if (!publishState) {
+ return (
+
+
+ {this.messages('status.no-version')}
+
+ )
+ } else if (publishState === 'PUBLISH_BLOCKED') {
+ return (
+
+
+ {this.messages('status.publishDisabled')}
+
+ )
+ } else if (publishState === 'READY_TO_PUBLISH') {
+ return (
+
+
+ {this.messages('status.canPublish')}
+
+ )
+ }
+ return null
+ }
+}
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..e3221fe2c 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'
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..e95651111 100644
--- a/lib/types/index.js
+++ b/lib/types/index.js
@@ -400,9 +400,11 @@ export type FeedSourceSummary = {
isPublic: boolean,
labelIds: Array,
lastUpdated?: number,
+ latestSentToExternalPublisher?: ?number,
latestValidation?: ValidationSummary,
name: string,
- projectId: string
+ projectId: string,
+ publishState?: ?string
}
export type Feed = FeedSourceSummary & {