mirror of
https://github.com/docker/docs.git
synced 2026-11-06 12:54:24 +03:00
When a container is first started and the image is downloading there is no id set. With this patch we'll check if the container has a id and and is downloading, if so we'll substitute it with the image name and render such. This will fix the react key props warning in the developer console as well as maybe give us some sort of performance boost(?) Signed-off-by: Kristján Oddsson <koddsson@gmail.com>
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
var React = require('react/addons');
|
|
var ContainerListItem = require('./ContainerListItem.react');
|
|
var ContainerListNewItem = require('./ContainerListNewItem.react');
|
|
|
|
var ContainerList = React.createClass({
|
|
componentWillMount: function () {
|
|
this._start = Date.now();
|
|
},
|
|
render: function () {
|
|
var self = this;
|
|
var containers = this.props.containers.map(function (container) {
|
|
var container_id = container.Id;
|
|
if (!container_id && container.State.Downloading) {
|
|
// Fall back to the container image name when there is no id. (when the
|
|
// image is downloading).
|
|
container_id = container.Image;
|
|
}
|
|
return (
|
|
<ContainerListItem key={container_id} container={container} start={self._start} />
|
|
);
|
|
});
|
|
var newItem;
|
|
if (!this.props.downloading) {
|
|
newItem = <ContainerListNewItem key={'newcontainer'} containers={this.props.containers} />;
|
|
} else {
|
|
newItem = '';
|
|
}
|
|
return (
|
|
<ul>
|
|
{newItem}
|
|
{containers}
|
|
</ul>
|
|
);
|
|
}
|
|
});
|
|
|
|
module.exports = ContainerList;
|