@@ -159,15 +184,25 @@ var ContainerSettingsGeneral = React.createClass({
{btnSaveName}
);
- var pendingEnvVars = _.map(this.state.pendingEnv, (val, key) => {
+
+ let vars = _.map(this.state.env, (kvp, index) => {
+ let [key, val] = kvp;
+ let icon;
+ if (index === this.state.env.length - 1) {
+ icon =
Delete Container
diff --git a/src/components/ContainerSettingsVolumes.react.js b/src/components/ContainerSettingsVolumes.react.js
index 73c8ef95c0..4aa87f4350 100644
--- a/src/components/ContainerSettingsVolumes.react.js
+++ b/src/components/ContainerSettingsVolumes.react.js
@@ -4,12 +4,12 @@ var remote = require('remote');
var dialog = remote.require('dialog');
var shell = require('shell');
var metrics = require('../utils/MetricsUtil');
-var ContainerStore = require('../stores/ContainerStore');
+var containerActions = require('../actions/ContainerActions');
var ContainerSettingsVolumes = React.createClass({
handleChooseVolumeClick: function (dockerVol) {
var self = this;
- dialog.showOpenDialog({properties: ['openDirectory', 'createDirectory']}, function (filenames) {
+ dialog.showOpenDialog({properties: ['openDirectory', 'createDirectory']}, (filenames) => {
if (!filenames) {
return;
}
@@ -21,11 +21,8 @@ var ContainerSettingsVolumes = React.createClass({
var binds = _.pairs(volumes).map(function (pair) {
return pair[1] + ':' + pair[0];
});
- ContainerStore.updateContainer(self.props.container.Name, {
- Binds: binds
- }, function (err) {
- if (err) { console.log(err); }
- });
+
+ containerActions.update(this.props.container.Name, {Binds: binds});
}
});
},
@@ -38,11 +35,7 @@ var ContainerSettingsVolumes = React.createClass({
var binds = _.pairs(volumes).map(function (pair) {
return pair[1] + ':' + pair[0];
});
- ContainerStore.updateContainer(this.props.container.Name, {
- Binds: binds
- }, function (err) {
- if (err) { console.log(err); }
- });
+ containerActions.update(this.props.container.Name, {Binds: binds});
},
handleOpenVolumeClick: function (path) {
metrics.track('Opened Volume Directory', {
diff --git a/src/components/Containers.react.js b/src/components/Containers.react.js
index 9b6c525b80..a5829d82ce 100644
--- a/src/components/Containers.react.js
+++ b/src/components/Containers.react.js
@@ -1,6 +1,6 @@
var $ = require('jquery');
var _ = require('underscore');
-var React = require('react/addons');
+var React = require('react');
var Router = require('react-router');
var containerStore = require('../stores/ContainerStore');
var ContainerList = require('./ContainerList.react');
@@ -62,7 +62,9 @@ var Containers = React.createClass({
});
let name = this.context.router.getCurrentParams().name;
- if (name && !containers[name]) {
+ if (containerStore.getState().pending) {
+ this.context.router.transitionTo('pull');
+ } else if (name && !containers[name]) {
if (sorted.length) {
this.context.router.transitionTo('containerHome', {name: sorted[0].Name});
} else {
@@ -72,7 +74,8 @@ var Containers = React.createClass({
this.setState({
containers: containers,
- sorted: sorted
+ sorted: sorted,
+ pending: containerStore.getState().pending
});
},
diff --git a/src/components/ImageCard.react.js b/src/components/ImageCard.react.js
index a139a2f47d..67a0a0a229 100644
--- a/src/components/ImageCard.react.js
+++ b/src/components/ImageCard.react.js
@@ -1,14 +1,16 @@
var $ = require('jquery');
var React = require('react/addons');
+var Router = require('react-router');
var RetinaImage = require('react-retina-image');
var metrics = require('../utils/MetricsUtil');
var OverlayTrigger = require('react-bootstrap').OverlayTrigger;
var Tooltip = require('react-bootstrap').Tooltip;
var util = require('../utils/Util');
-var dockerUtil = require('../utils/DockerUtil');
+var containerActions = require('../actions/ContainerActions');
var containerStore = require('../stores/ContainerStore');
var ImageCard = React.createClass({
+ mixins: [Router.Navigation],
getInitialState: function () {
return {
tags: [],
@@ -28,7 +30,8 @@ var ImageCard = React.createClass({
from: 'search'
});
let name = containerStore.generateName(repository);
- dockerUtil.run(name, repository, this.state.chosenTag);
+ containerActions.run(name, repository, this.state.chosenTag);
+ this.transitionTo('containerHome', {name});
},
handleTagOverlayClick: function (name) {
var $tagOverlay = $(this.getDOMNode()).find('.tag-overlay');
diff --git a/src/components/NewContainerPull.react.js b/src/components/NewContainerPull.react.js
index 3327b399f5..4a9150a962 100644
--- a/src/components/NewContainerPull.react.js
+++ b/src/components/NewContainerPull.react.js
@@ -1,30 +1,32 @@
var React = require('react/addons');
var Router = require('react-router');
var shell = require('shell');
-var ContainerStore = require('../stores/ContainerStore');
+var containerActions = require('../actions/ContainerActions');
+var containerStore = require('../stores/ContainerStore');
var metrics = require('../utils/MetricsUtil');
module.exports = React.createClass({
mixins: [Router.Navigation],
handleOpenClick: function () {
- var repo = this.props.pending.repository;
+ var repo = this.props.pending.repo;
if (repo.indexOf('/') === -1) {
- shell.openExternal(`https://registry.hub.docker.com/_/${this.props.pending.repository}`);
+ shell.openExternal(`https://registry.hub.docker.com/_/${this.props.pending.repo}`);
} else {
- shell.openExternal(`https://registry.hub.docker.com/u/${this.props.pending.repository}`);
+ shell.openExternal(`https://registry.hub.docker.com/u/${this.props.pending.repo}`);
}
},
handleCancelClick: function () {
metrics.track('Canceled Click-To-Pull');
- ContainerStore.clearPending();
+ containerActions.clearPending();
this.context.router.transitionTo('new');
},
handleConfirmClick: function () {
metrics.track('Created Container', {
from: 'click-to-pull'
});
- ContainerStore.clearPending();
- ContainerStore.create(this.props.pending.repository, this.props.pending.tag, function () {});
+ containerActions.clearPending();
+ let name = containerStore.generateName(this.props.pending.repo);
+ containerActions.run(name, this.props.pending.repo, this.props.pending.tag);
},
render: function () {
if (!this.props.pending) {
@@ -34,7 +36,7 @@ module.exports = React.createClass({
-
+
Please confirm to create the container.
Cancel Confirm
diff --git a/src/stores/ContainerStore.js b/src/stores/ContainerStore.js
index 8bdb4f632f..ddb8a9d676 100644
--- a/src/stores/ContainerStore.js
+++ b/src/stores/ContainerStore.js
@@ -11,6 +11,9 @@ class ContainerStore {
// Blacklist of containers to avoid updating
this.muted = {};
+
+ // Pending container to create
+ this.pending = null;
}
start ({name}) {
@@ -106,7 +109,7 @@ class ContainerStore {
this.setState({containers});
}
- error ({ name, error }) {
+ error ({name, error}) {
let containers = this.containers;
if (containers[name]) {
containers[name].Error = error;
@@ -114,6 +117,15 @@ class ContainerStore {
this.setState({containers});
}
+ pending ({repo, tag}) {
+ let pending = {repo, tag};
+ this.setState({pending});
+ }
+
+ clearPending () {
+ this.setState({pending: null});
+ }
+
static generateName (repo) {
let base = _.last(repo.split('/'));
let count = 1;
diff --git a/src/utils/ContainerUtil.js b/src/utils/ContainerUtil.js
index 2ddfdafcb4..4d6016ce6e 100644
--- a/src/utils/ContainerUtil.js
+++ b/src/utils/ContainerUtil.js
@@ -4,13 +4,13 @@ var docker = require('../utils/DockerUtil');
var ContainerUtil = {
env: function (container) {
if (!container || !container.Config || !container.Config.Env) {
- return {};
+ return [];
}
- return _.object(container.Config.Env.map(function (env) {
+ return _.map(container.Config.Env, env => {
var i = env.indexOf('=');
var splits = [env.slice(0, i), env.slice(i + 1)];
return splits;
- }));
+ });
},
// TODO: inject host here instead of requiring Docker
diff --git a/src/utils/URLUtil.js b/src/utils/URLUtil.js
index 9f195ffdb4..2b4e8a8933 100644
--- a/src/utils/URLUtil.js
+++ b/src/utils/URLUtil.js
@@ -1,6 +1,6 @@
var util = require('./Util');
var parseUri = require('parseUri');
-var containerStore = require('../stores/ContainerStore');
+var containerServerActions = require('../actions/ContainerServerActions');
module.exports = {
TYPE_WHITELIST: ['repository'],
@@ -52,7 +52,7 @@ module.exports = {
}
if (type === 'repository' && method === 'run') {
- containerStore.setPending(repo, 'latest');
+ containerServerActions.pending({repo, tag: 'latest'});
return true;
}
return false;