mirror of https://github.com/docker/docs.git
Merge branch 'master' into hub
This commit is contained in:
commit
bd462b7ee9
|
|
@ -5,6 +5,7 @@ var metrics = require('../utils/MetricsUtil');
|
||||||
var dialog = remote.require('dialog');
|
var dialog = remote.require('dialog');
|
||||||
var ContainerUtil = require('../utils/ContainerUtil');
|
var ContainerUtil = require('../utils/ContainerUtil');
|
||||||
var containerActions = require('../actions/ContainerActions');
|
var containerActions = require('../actions/ContainerActions');
|
||||||
|
var util = require('../utils/Util');
|
||||||
|
|
||||||
var ContainerSettingsGeneral = React.createClass({
|
var ContainerSettingsGeneral = React.createClass({
|
||||||
mixins: [React.addons.LinkedStateMixin],
|
mixins: [React.addons.LinkedStateMixin],
|
||||||
|
|
@ -16,6 +17,11 @@ var ContainerSettingsGeneral = React.createClass({
|
||||||
getInitialState: function () {
|
getInitialState: function () {
|
||||||
let env = ContainerUtil.env(this.props.container) || [];
|
let env = ContainerUtil.env(this.props.container) || [];
|
||||||
env.push(['', '']);
|
env.push(['', '']);
|
||||||
|
|
||||||
|
env = _.map(env, e => {
|
||||||
|
return [util.randomId(), e[0], e[1]];
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
slugName: null,
|
slugName: null,
|
||||||
nameError: null,
|
nameError: null,
|
||||||
|
|
@ -23,14 +29,6 @@ var ContainerSettingsGeneral = React.createClass({
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
shouldComponentUpdate: function (nextProps, nextState) {
|
|
||||||
if (nextState.slugName !== this.state.slugName || nextState.nameError !== this.state.nameError) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
handleNameChange: function (e) {
|
handleNameChange: function (e) {
|
||||||
let name = e.target.value;
|
let name = e.target.value;
|
||||||
if (name === this.state.slugName) {
|
if (name === this.state.slugName) {
|
||||||
|
|
@ -87,7 +85,7 @@ var ContainerSettingsGeneral = React.createClass({
|
||||||
metrics.track('Saved Environment Variables');
|
metrics.track('Saved Environment Variables');
|
||||||
let list = [];
|
let list = [];
|
||||||
_.each(this.state.env, kvp => {
|
_.each(this.state.env, kvp => {
|
||||||
let [key, value] = kvp;
|
let [, key, value] = kvp;
|
||||||
if ((key && key.length) || (value && value.length)) {
|
if ((key && key.length) || (value && value.length)) {
|
||||||
list.push(key + '=' + value);
|
list.push(key + '=' + value);
|
||||||
}
|
}
|
||||||
|
|
@ -97,7 +95,7 @@ var ContainerSettingsGeneral = React.createClass({
|
||||||
|
|
||||||
handleChangeEnvKey: function (index, event) {
|
handleChangeEnvKey: function (index, event) {
|
||||||
let env = _.map(this.state.env, _.clone);
|
let env = _.map(this.state.env, _.clone);
|
||||||
env[index][0] = event.target.value;
|
env[index][1] = event.target.value;
|
||||||
this.setState({
|
this.setState({
|
||||||
env: env
|
env: env
|
||||||
});
|
});
|
||||||
|
|
@ -105,7 +103,7 @@ var ContainerSettingsGeneral = React.createClass({
|
||||||
|
|
||||||
handleChangeEnvVal: function (index, event) {
|
handleChangeEnvVal: function (index, event) {
|
||||||
let env = _.map(this.state.env, _.clone);
|
let env = _.map(this.state.env, _.clone);
|
||||||
env[index][1] = event.target.value;
|
env[index][2] = event.target.value;
|
||||||
this.setState({
|
this.setState({
|
||||||
env: env
|
env: env
|
||||||
});
|
});
|
||||||
|
|
@ -113,7 +111,7 @@ var ContainerSettingsGeneral = React.createClass({
|
||||||
|
|
||||||
handleAddEnvVar: function () {
|
handleAddEnvVar: function () {
|
||||||
let env = _.map(this.state.env, _.clone);
|
let env = _.map(this.state.env, _.clone);
|
||||||
env.push(['', '']);
|
env.push([util.randomId(), '', '']);
|
||||||
this.setState({
|
this.setState({
|
||||||
env: env
|
env: env
|
||||||
});
|
});
|
||||||
|
|
@ -123,8 +121,9 @@ var ContainerSettingsGeneral = React.createClass({
|
||||||
handleRemoveEnvVar: function (index) {
|
handleRemoveEnvVar: function (index) {
|
||||||
let env = _.map(this.state.env, _.clone);
|
let env = _.map(this.state.env, _.clone);
|
||||||
env.splice(index, 1);
|
env.splice(index, 1);
|
||||||
|
|
||||||
if (env.length === 0) {
|
if (env.length === 0) {
|
||||||
env.push(['', '']);
|
env.push([util.randomId(), '', '']);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
@ -183,7 +182,7 @@ var ContainerSettingsGeneral = React.createClass({
|
||||||
);
|
);
|
||||||
|
|
||||||
let vars = _.map(this.state.env, (kvp, index) => {
|
let vars = _.map(this.state.env, (kvp, index) => {
|
||||||
let [key, val] = kvp;
|
let [id, key, val] = kvp;
|
||||||
let icon;
|
let icon;
|
||||||
if (index === this.state.env.length - 1) {
|
if (index === this.state.env.length - 1) {
|
||||||
icon = <a onClick={this.handleAddEnvVar} className="only-icon btn btn-positive small"><span className="icon icon-add-1"></span></a>;
|
icon = <a onClick={this.handleAddEnvVar} className="only-icon btn btn-positive small"><span className="icon icon-add-1"></span></a>;
|
||||||
|
|
@ -192,7 +191,7 @@ var ContainerSettingsGeneral = React.createClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="keyval-row">
|
<div key={id} className="keyval-row">
|
||||||
<input type="text" className="key line" defaultValue={key} onChange={this.handleChangeEnvKey.bind(this, index)}></input>
|
<input type="text" className="key line" defaultValue={key} onChange={this.handleChangeEnvKey.bind(this, index)}></input>
|
||||||
<input type="text" className="val line" defaultValue={val} onChange={this.handleChangeEnvVal.bind(this, index)}></input>
|
<input type="text" className="val line" defaultValue={val} onChange={this.handleChangeEnvVal.bind(this, index)}></input>
|
||||||
{icon}
|
{icon}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,10 @@ export default {
|
||||||
stream.setEncoding('utf8');
|
stream.setEncoding('utf8');
|
||||||
stream.on('data', function () {});
|
stream.on('data', function () {});
|
||||||
stream.on('end', () => {
|
stream.on('end', () => {
|
||||||
|
if (!this.placeholders[container.Name]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
delete this.placeholders[container.Name];
|
delete this.placeholders[container.Name];
|
||||||
localStorage.setItem('placeholders', JSON.stringify(this.placeholders));
|
localStorage.setItem('placeholders', JSON.stringify(this.placeholders));
|
||||||
this.createContainer(container.Name, {Image: container.Config.Image});
|
this.createContainer(container.Name, {Image: container.Config.Image});
|
||||||
|
|
@ -146,7 +150,7 @@ export default {
|
||||||
let imageName = repository + ':' + tag;
|
let imageName = repository + ':' + tag;
|
||||||
|
|
||||||
let placeholderData = {
|
let placeholderData = {
|
||||||
Id: require('crypto').randomBytes(32).toString('hex'),
|
Id: util.randomId(),
|
||||||
Name: name,
|
Name: name,
|
||||||
Image: imageName,
|
Image: imageName,
|
||||||
Config: {
|
Config: {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ var exec = require('exec');
|
||||||
var Promise = require('bluebird');
|
var Promise = require('bluebird');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
var crypto = require('crypto');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
exec: function (args, options) {
|
exec: function (args, options) {
|
||||||
|
|
@ -131,5 +132,8 @@ module.exports = {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
randomId: function () {
|
||||||
|
return crypto.randomBytes(32).toString('hex');
|
||||||
|
},
|
||||||
webPorts: ['80', '8000', '8080', '3000', '5000', '2368', '9200', '8983']
|
webPorts: ['80', '8000', '8080', '3000', '5000', '2368', '9200', '8983']
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue