diff --git a/__tests__/test-utils/mock-data/manager.js b/__tests__/test-utils/mock-data/manager.js index ac4fb3129..5d7e3c6c0 100644 --- a/__tests__/test-utils/mock-data/manager.js +++ b/__tests__/test-utils/mock-data/manager.js @@ -153,6 +153,10 @@ export const mockFeedWithVersion = { tripCount: 415 }, latestVersionId: 'mock-feed-version-id', + // Include version as sometimes, this object is used as a FeedSourceSummary too. + latestVersion: { + lastUpdated: 1543389038810 + }, labelIds: [], name: 'test feed with a version', noteCount: 0, @@ -398,6 +402,7 @@ mockProjectWithDeployment.name = 'mock-project-with-deployments' export const mockDeployment = makeMockDeployment( mockProjectWithDeployment, + // $FlowFixMe, Passing partial data under FeedSourceSummary.latestVersion [mockFeedVersion] ) export const mockDeploymentSummary = makeMockDeploymentSummary() diff --git a/lib/manager/components/FeedSourceTableRow.js b/lib/manager/components/FeedSourceTableRow.js index 8dc6d24ba..211710b4f 100644 --- a/lib/manager/components/FeedSourceTableRow.js +++ b/lib/manager/components/FeedSourceTableRow.js @@ -24,13 +24,14 @@ import WatchButton from '../../common/containers/WatchButton' import FeedLabel from '../../common/components/FeedLabel' import LabelAssignerModal from '../components/LabelAssignerModal' import type { Props as ContainerProps } from '../containers/FeedSourceTableRow' -import type { Feed, ValidationSummary, Project } from '../../types' +import type { Feed, FeedVersionSummary, ValidationSummary, Project } from '../../types' import type { FeedSourceTableComparisonColumns, ManagerUserState } from '../../types/reducers' import { PublishStatus } from './PublishStatus' +import Status from './FeedStatus' type Props = ContainerProps & { comparisonColumn: FeedSourceTableComparisonColumns, @@ -45,6 +46,15 @@ type Props = ContainerProps & { user: ManagerUserState } +type VersionData = { + className: string, + endDate?: string, + errorCount: number | string, + icon: string, + startDate?: string, + status: string +} + const statusAttributeLookup = { 'active': { className: 'status-active', @@ -94,6 +104,13 @@ export default class FeedSourceTableRow extends PureComponent { messages = getComponentMessages('FeedSourceTableRow') dateFormat = this.messages('dateFormat') + getLastUpdateRelative (lastUpdated?: any) { + const lastVersionUpdate = !!lastUpdated && relativeDuration(lastUpdated) + return lastVersionUpdate + ? this.messages('lastUpdated').replace('%lastVersionUpdate%', lastVersionUpdate) + : '' + } + /** * Get some UI data from a ValidationSummary */ @@ -126,16 +143,11 @@ export default class FeedSourceTableRow extends PureComponent { } /** - * This method generates the variables and used to live in the render method, - * but was extracted to appease the eslint complexity rule + * Generate the variables for comparing published/deployed version vs. latest version. */ generateFeedSourceLabelRenderVars (feedSource: Feed, comparisonValidationSummary: ?ValidationSummary) { // data for feed source info column - let lastVersionUpdate = !!feedSource.lastUpdated && - relativeDuration(feedSource.lastUpdated) - lastVersionUpdate = lastVersionUpdate - ? this.messages('lastUpdated').replace('%lastVersionUpdate%', lastVersionUpdate) - : '' + const lastVersionUpdate = this.getLastUpdateRelative(feedSource.lastUpdated) // data for comparison column const comparisonData = comparisonValidationSummary && @@ -166,6 +178,37 @@ export default class FeedSourceTableRow extends PureComponent { } } + renderDetailCells (versionData: VersionData, publishedVersion?: FeedVersionSummary) { + const { className, endDate, errorCount, icon, startDate, status } = versionData + const { lastUpdated } = publishedVersion || {} + const lastVersionUpdate = this.getLastUpdateRelative(lastUpdated) + return ( + <> + + + + + {startDate} + {startDate && ' -'} + {endDate &&
} + {endDate} + + {errorCount} + {isExtensionEnabled('mtc') && ( + + + + )} + + ) + } + // eslint-disable-next-line complexity render () { const { @@ -177,7 +220,6 @@ export default class FeedSourceTableRow extends PureComponent { } = this.props const { - lastVersionUpdate, comparisonSubtext, comparisonData, comparisonSubtextDate @@ -187,67 +229,67 @@ export default class FeedSourceTableRow extends PureComponent { ) // data for latest validation columns - const currentVersionData = this.getVersionDisplayData(feedSource.latestValidation) - const latestVersionId = feedSource.latestValidation && feedSource.latestValidation.feedVersionId - const comparisonVersionId = comparisonValidationSummary && comparisonValidationSummary.feedVersionId + const { latestActiveFeedValidation, latestActiveVersion, latestValidation, latestVersion } = feedSource + const defaultVersion = latestActiveVersion || latestVersion + const defaultValidation = latestActiveFeedValidation || latestValidation + const { feedVersionId: latestVersionId } = latestValidation || {} + const { feedVersionId: activeVersionId } = defaultValidation || {} - if (latestVersionId && latestVersionId === comparisonVersionId) { - currentVersionData.status = comparisonColumn === 'DEPLOYED' + const { endDate, feedVersionId: comparisonVersionId, startDate } = comparisonValidationSummary || {} + const hasComparisonDates = startDate && endDate + + const latestVersionData = this.getVersionDisplayData(latestValidation) + const activeVersionData = this.getVersionDisplayData(defaultValidation) + + if (activeVersionId && activeVersionId === comparisonVersionId) { + activeVersionData.status = comparisonColumn === 'DEPLOYED' ? 'same-as-deployed' : 'same-as-published' } + const hasPendingVersion = activeVersionId !== latestVersionId + const rowsRequired = hasPendingVersion ? 2 : 1 + + // Render the active or expired version first. + // If there is a future version, show it underneath. return ( - - - - - {comparisonColumn && - - {comparisonData - ? ( - - ) - : - {comparisonColumn === 'PUBLISHED' - ? this.messages('status.feedNotPublished') - : this.messages('status.feedNotInDeployment')} - - } + <> + + + - } - - - - - {currentVersionData.startDate} - {currentVersionData.startDate && ' -'} - {currentVersionData.endDate &&
} - {currentVersionData.endDate} - - {currentVersionData.errorCount} - {isExtensionEnabled('mtc') && - - + {comparisonColumn && + + {comparisonData && hasComparisonDates + ? ( + + ) + : + {comparisonColumn === 'PUBLISHED' + ? this.messages('status.feedNotPublished') + : this.messages('status.feedNotInDeployment')} + + } + + } + {this.renderDetailCells(activeVersionData, defaultVersion)} + + + + {hasPendingVersion && + + {this.renderDetailCells(latestVersionData, latestVersion)} + } - - - - + ) } } @@ -348,32 +390,6 @@ class FeedInfo extends PureComponent<{ feedSource: Feed, project: Project, user: } } -class Status extends PureComponent<{ - dateFormat: string, - icon: string, - statusSpanClass: string, - statusText: string, - subtext: ?string, - subtextDate?: string -}> { - render () { - const {icon, dateFormat, subtext, statusSpanClass, statusText, subtextDate} = this.props - return ( -
- - - {statusText} - -
- {subtext} - {subtextDate &&
} - {subtextDate && `(${moment(subtextDate).format(dateFormat)})`} -
-
- ) - } -} - class FeedActionsDropdown extends PureComponent { messages = getComponentMessages('FeedActionsDropdown') diff --git a/lib/manager/components/FeedStatus.js b/lib/manager/components/FeedStatus.js new file mode 100644 index 000000000..c65e19f8f --- /dev/null +++ b/lib/manager/components/FeedStatus.js @@ -0,0 +1,37 @@ +// @flow + +import Icon from '@conveyal/woonerf/components/icon' +import moment from 'moment' +import React from 'react' + +type Props = { + dateFormat?: string, + icon: string, + statusSpanClass: string, + statusText: string, + subtext?: string, + subtextDate?: string +} + +export default function FeedStatus ({ + dateFormat, + icon, + statusSpanClass, + statusText, + subtext, + subtextDate +}: Props) { + return ( +
+ + + {statusText} + +
+ {subtext} + {subtextDate &&
} + {subtextDate && dateFormat && `(${moment(subtextDate).format(dateFormat)})`} +
+
+ ) +} diff --git a/lib/manager/components/PublishStatus.js b/lib/manager/components/PublishStatus.js index 209221fca..faedf66bc 100644 --- a/lib/manager/components/PublishStatus.js +++ b/lib/manager/components/PublishStatus.js @@ -1,14 +1,15 @@ // @flow -import Icon from '@conveyal/woonerf/components/icon' import humanizeDuration from 'humanize-duration' import moment from 'moment' import React, { PureComponent } from 'react' import { getComponentMessages } from '../../common/util/config' +import type { FeedVersionSummary } from '../../types' + +import FeedStatus from './FeedStatus' type Props = { - latestSentToExternalPublisher?: number, - publishState: string; + version?: FeedVersionSummary }; type PublishStatusState = { @@ -26,15 +27,16 @@ export class PublishStatus extends PureComponent { } componentDidMount () { - if (this.props.publishState === 'PUBLISHING') { + const { publishState } = this.props.version || {} + if (publishState === 'PUBLISHING') { this.updateElapsed() this._interval = setInterval(this.updateElapsed, 10000) } } componentDidUpdate (prevProps: Props) { - const wasProcessing = prevProps.publishState === 'PUBLISHING' - const isProcessingNow = this.props.publishState === 'PUBLISHING' + const wasProcessing = (prevProps.version || {}).publishState === 'PUBLISHING' + const isProcessingNow = (this.props.version || {}).publishState === 'PUBLISHING' if (!wasProcessing && isProcessingNow) { this.updateElapsed() this._interval = setInterval(this.updateElapsed, 10000) @@ -50,7 +52,7 @@ export class PublishStatus extends PureComponent { } updateElapsed = () => { - const ts = this.props.latestSentToExternalPublisher + const { sentToExternalPublisher: ts } = this.props.version || {} if (!ts) { this.setState({ elapsed: '' }) return @@ -69,48 +71,41 @@ export class PublishStatus extends PureComponent { }; render () { - const { publishState } = this.props + const { publishState = '' } = this.props.version || {} const { elapsed } = this.state if (publishState === 'PUBLISHED') { return ( - - - {this.messages('published')} - + ) } else if (publishState === 'PUBLISHING') { return ( - <> - - - {this.messages('publishingInProgress')} - -

- {elapsed ? `Processing for ${elapsed}` : null} -

- - ) - } else if (!publishState) { - return ( - - - {this.messages('no-version')} - + ) } else if (publishState === 'PUBLISH_BLOCKED') { return ( - - - {this.messages('publishDisabled')} - + ) } else if (publishState === 'READY_TO_PUBLISH') { return ( - - - {this.messages('canPublish')} - + ) } return null diff --git a/lib/manager/containers/__tests__/__snapshots__/DeploymentsPanel.js.snap b/lib/manager/containers/__tests__/__snapshots__/DeploymentsPanel.js.snap index 662cd1976..13c8e8203 100644 --- a/lib/manager/containers/__tests__/__snapshots__/DeploymentsPanel.js.snap +++ b/lib/manager/containers/__tests__/__snapshots__/DeploymentsPanel.js.snap @@ -74,6 +74,9 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -212,6 +215,9 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -314,6 +320,9 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -452,6 +461,9 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -611,6 +623,9 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -777,6 +792,9 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -915,6 +933,9 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -1133,6 +1154,9 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -1263,6 +1287,9 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -1401,6 +1428,9 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -1676,6 +1706,9 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -1814,6 +1847,9 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, diff --git a/lib/manager/containers/__tests__/__snapshots__/FeedSourceTable.js.snap b/lib/manager/containers/__tests__/__snapshots__/FeedSourceTable.js.snap index bb1359560..87414e452 100644 --- a/lib/manager/containers/__tests__/__snapshots__/FeedSourceTable.js.snap +++ b/lib/manager/containers/__tests__/__snapshots__/FeedSourceTable.js.snap @@ -73,6 +73,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -175,6 +178,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -248,6 +254,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -296,6 +305,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -373,6 +385,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -475,6 +490,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -669,6 +687,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -771,6 +792,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -898,6 +922,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -1000,6 +1027,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -2951,6 +2981,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -3025,6 +3058,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -3127,6 +3163,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -3226,6 +3265,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -3299,6 +3341,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -3401,6 +3446,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -3516,10 +3564,10 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -3626,6 +3677,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -3728,6 +3782,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -3954,6 +4011,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -4027,6 +4087,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -4129,6 +4192,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -4236,8 +4302,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds - manager > FeedSourceTable should render with a project with feeds (Aug 1, 2019) - + - manager > FeedSourceTable should render with a project with feeds Last updated 5 months ago - + manager > FeedSourceTable should render with a project with feeds > 78 - + manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -4446,6 +4518,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, @@ -4548,6 +4623,9 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "stopTimesCount": 11170, "tripCount": 415, }, + "latestVersion": Object { + "lastUpdated": 1543389038810, + }, "latestVersionId": "mock-feed-version-id", "name": "test feed with a version", "noteCount": 0, diff --git a/lib/manager/util/index.js b/lib/manager/util/index.js index 44a1d24a3..8c2260970 100644 --- a/lib/manager/util/index.js +++ b/lib/manager/util/index.js @@ -412,7 +412,10 @@ export function projectHasAtLeastOneDeployment (project: ?Project): boolean { export function projectHasAtLeastOneFeedWithAPublishedVersion (project: ?Project): boolean { return !!project && !!project.feedSources && - project.feedSources.some(feedSource => feedSource.publishState === 'PUBLISHED') + project.feedSources.some(feedSource => ( + (feedSource.latestActiveVersion && feedSource.latestActiveVersion.publishState === 'PUBLISHED') || + (feedSource.latestVersion && feedSource.latestVersion.publishState === 'PUBLISHED') + )) } export function validationState (val: ?boolean): ?string { diff --git a/lib/types/index.js b/lib/types/index.js index 8d78f78f3..58b4a8e4d 100644 --- a/lib/types/index.js +++ b/lib/types/index.js @@ -406,11 +406,13 @@ export type FeedSourceSummary = { isPublic: boolean, labelIds: Array, lastUpdated?: number, + latestActiveFeedValidation?: ValidationSummary, + latestActiveVersion?: FeedVersionSummary, latestSentToExternalPublisher?: ?number, latestValidation?: ValidationSummary, + latestVersion?: FeedVersionSummary, name: string, - projectId: string, - publishState?: ?string + projectId: string } export type Feed = FeedSourceSummary & { @@ -549,6 +551,7 @@ export type FeedVersionSummary = { originNamespace: ?string, publishState?: 'PUBLISHED' | 'PUBLISHING' | 'PUBLISH_BLOCKED' | 'READY_TO_PUBLISH', retrievalMethod: ?RetrievalMethod, + sentToExternalPublisher?: number | null, updated: number, // HACK: validationSummary is fully populated in FeedVersion. // Only startDate and endDate are available in FeedVersionSummary.