import React from 'react'; import { connect } from 'react-redux'; import find from 'lodash/find'; import map from 'lodash/map'; import { CircularProgress } from 'weaveworks-ui-components'; import { getImagesForService } from '../../actions/app-actions'; const topologyWhitelist = ['kube-controllers']; function newImagesAvailable(images, currentId) { const current = find(images, i => i.ID === currentId); if (current) { const timestamp = new Date(current.CreatedAt); return Boolean(find(images, i => new Date(i.CreatedAt) > timestamp)); } return false; } class NodeDetailsImageStatus extends React.PureComponent { constructor(props, context) { super(props, context); this.getImagesUrl = this.getImagesUrl.bind(this); } componentDidMount() { if (this.shouldRender() && this.props.serviceId) { this.props.getImagesForService(this.props.params.orgId, this.props.serviceId); } } getImagesUrl() { const { serviceId, params } = this.props; return `/flux/${params.orgId}/services/${encodeURIComponent(serviceId)}`; } shouldRender() { const { pseudo, topologyId } = this.props; return !pseudo && topologyId && topologyWhitelist.includes(topologyId); } renderImages() { const { errors, containers, isFetching } = this.props; const error = !isFetching && errors; if (isFetching) { return (
Error: {JSON.stringify(map(errors, 'message'))}
); } if (!containers) { return 'No service images found'; } return (