From 603b9c5952b3b0a88d07af8e3cb0d2380825c38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Sun, 5 Apr 2015 15:42:11 +0000 Subject: [PATCH] Fetch tags when a Image card has been mounted. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For images that don't have a "latest" tag (such as `google/debian`) we fetch all the tags when the `ImageCard` component mounts and set the chosen tag to the first one in the list (so far it seems to be the latest tag where such a tag exists but we can add some logic here to choose a appropriate tag if we want). Signed-off-by: Kristján Oddsson --- src/ImageCard.react.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ImageCard.react.js b/src/ImageCard.react.js index db895f6e32..88f12d60fd 100644 --- a/src/ImageCard.react.js +++ b/src/ImageCard.react.js @@ -50,6 +50,14 @@ var ImageCard = React.createClass({ } util.exec(['open', $repoUri + this.props.image.name]); }, + componentDidMount: function() { + $.get('https://registry.hub.docker.com/v1/repositories/' + this.props.image.name + '/tags', function (result) { + this.setState({ + tags: result, + chosenTag: result[0].name + }); + }.bind(this)); + }, render: function () { var self = this; var name;