mirror of https://github.com/docker/docs.git
Fix bug with change in 1.8.0 remote volumes API
Signed-off-by: Jeffrey Morgan <jmorganca@gmail.com>
This commit is contained in:
parent
4ef89bd076
commit
5d1a55386c
|
|
@ -41,7 +41,7 @@ var ContainerHome = React.createClass({
|
|||
},
|
||||
|
||||
showFolders: function () {
|
||||
return this.props.container.Volumes && _.keys(this.props.container.Volumes).length > 0 && this.props.container.State.Running;
|
||||
return this.props.container.Mounts && this.props.container.Mounts.length > 0 && this.props.container.State.Running;
|
||||
},
|
||||
|
||||
render: function () {
|
||||
|
|
|
|||
|
|
@ -14,30 +14,36 @@ var ContainerHomeFolder = React.createClass({
|
|||
contextTypes: {
|
||||
router: React.PropTypes.func
|
||||
},
|
||||
handleClickFolder: function (hostVolume, containerVolume) {
|
||||
handleClickFolder: function (source, destination) {
|
||||
metrics.track('Opened Volume Directory', {
|
||||
from: 'home'
|
||||
});
|
||||
|
||||
if (hostVolume.indexOf(util.windowsToLinuxPath(util.home())) === -1) {
|
||||
if (source.indexOf(util.windowsToLinuxPath(util.home())) === -1) {
|
||||
dialog.showMessageBox({
|
||||
message: `Enable all volumes to edit files? This may not work with all database containers.`,
|
||||
buttons: ['Enable Volumes', 'Cancel']
|
||||
}, (index) => {
|
||||
if (index === 0) {
|
||||
var volumes = _.clone(this.props.container.Volumes);
|
||||
var newHostVolume = util.escapePath(path.join(util.home(), util.documents(), 'Kitematic', this.props.container.Name, containerVolume));
|
||||
volumes[containerVolume] = newHostVolume;
|
||||
var binds = _.pairs(volumes).map(function (pair) {
|
||||
if(util.isWindows()) {
|
||||
return util.windowsToLinuxPath(pair[1]) + ':' + pair[0];
|
||||
var mounts = _.clone(this.props.container.Mounts);
|
||||
var newSource = util.escapePath(path.join(util.home(), util.documents(), 'Kitematic', this.props.container.Name, destination));
|
||||
var binds = mounts.map(function (m) {
|
||||
let source = m.Source;
|
||||
if (m.Destination === destination) {
|
||||
source = newSource;
|
||||
}
|
||||
return pair[1] + ':' + pair[0];
|
||||
|
||||
if(util.isWindows()) {
|
||||
return util.windowsToLinuxPath(source) + ':' + m.Destination;
|
||||
}
|
||||
|
||||
return source + ':' + m.Destination;
|
||||
});
|
||||
mkdirp(newHostVolume, function (err) {
|
||||
|
||||
mkdirp(newSource, function (err) {
|
||||
console.log(err);
|
||||
if (!err) {
|
||||
shell.showItemInFolder(newHostVolume);
|
||||
shell.showItemInFolder(newSource);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -45,7 +51,7 @@ var ContainerHomeFolder = React.createClass({
|
|||
}
|
||||
});
|
||||
} else {
|
||||
let path = util.isWindows() ? util.linuxToWindowsPath(hostVolume) : hostVolume;
|
||||
let path = util.isWindows() ? util.linuxToWindowsPath(source) : source;
|
||||
shell.showItemInFolder(path);
|
||||
}
|
||||
},
|
||||
|
|
@ -60,12 +66,13 @@ var ContainerHomeFolder = React.createClass({
|
|||
return false;
|
||||
}
|
||||
|
||||
var folders = _.map(_.omit(this.props.container.Volumes, (v, k) => k.indexOf('/Users/') !== -1), (val, key) => {
|
||||
var firstFolder = key;
|
||||
var folders = _.map(this.props.container.Mounts, (m, i) => {
|
||||
let destination = m.Destination;
|
||||
let source = m.Source;
|
||||
return (
|
||||
<div key={key} className="folder" onClick={this.handleClickFolder.bind(this, val, key)}>
|
||||
<div key={i} className="folder" onClick={this.handleClickFolder.bind(this, source, destination)}>
|
||||
<RetinaImage src="folder.png" />
|
||||
<div className="text">{firstFolder}</div>
|
||||
<div className="text">{destination}</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,16 +26,23 @@ var ContainerSettingsVolumes = React.createClass({
|
|||
}
|
||||
|
||||
metrics.track('Choose Directory for Volume');
|
||||
|
||||
if(util.isWindows()) {
|
||||
directory = util.escapePath(util.windowsToLinuxPath(directory));
|
||||
}
|
||||
var volumes = _.clone(this.props.container.Volumes);
|
||||
volumes[dockerVol] = directory;
|
||||
var binds = _.pairs(volumes).map(function (pair) {
|
||||
return pair[1] + ':' + pair[0];
|
||||
|
||||
var mounts = _.clone(this.props.container.Mounts);
|
||||
_.each(mounts, m => {
|
||||
if (m.Destination === dockerVol) {
|
||||
m.Source = directory;
|
||||
}
|
||||
});
|
||||
|
||||
containerActions.update(this.props.container.Name, {Binds: binds, Volumes: volumes});
|
||||
var binds = mounts.map(m => {
|
||||
return m.Source + ':' + m.Destination;
|
||||
});
|
||||
|
||||
containerActions.update(this.props.container.Name, {Binds: binds, Mounts: mounts});
|
||||
});
|
||||
},
|
||||
handleRemoveVolumeClick: function (dockerVol) {
|
||||
|
|
@ -45,13 +52,17 @@ var ContainerSettingsVolumes = React.createClass({
|
|||
|
||||
var hostConfig = _.clone(this.props.container.HostConfig);
|
||||
var binds = hostConfig.Binds;
|
||||
var volumes = _.clone(this.props.container.Volumes);
|
||||
volumes[dockerVol] = null;
|
||||
var mounts = _.clone(this.props.container.Mounts);
|
||||
_.each(mounts, m => {
|
||||
if (m.Destination === dockerVol) {
|
||||
m.Source = null;
|
||||
}
|
||||
});
|
||||
var index = _.findIndex(binds, bind => bind.indexOf(`:${dockerVol}`) !== -1);
|
||||
if (index >= 0) {
|
||||
binds.splice(index, 1);
|
||||
}
|
||||
containerActions.update(this.props.container.Name, {HostConfig: hostConfig, Binds: binds, Volumes: volumes});
|
||||
containerActions.update(this.props.container.Name, {HostConfig: hostConfig, Binds: binds, Mounts: mounts});
|
||||
},
|
||||
handleOpenVolumeClick: function (path) {
|
||||
metrics.track('Opened Volume Directory', {
|
||||
|
|
@ -69,24 +80,25 @@ var ContainerSettingsVolumes = React.createClass({
|
|||
}
|
||||
|
||||
var homeDir = util.isWindows() ? util.windowsToLinuxPath(util.home()) : util.home();
|
||||
var volumes = _.map(this.props.container.Volumes, (val, key) => {
|
||||
if (!val || val.indexOf(homeDir) === -1) {
|
||||
val = (
|
||||
var mounts= _.map(this.props.container.Mounts, (m, i) => {
|
||||
let source = m.Source, destination = m.Destination;
|
||||
if (!m.Source || m.Source.indexOf(homeDir) === -1) {
|
||||
source = (
|
||||
<span className="value-right">No Folder</span>
|
||||
);
|
||||
} else {
|
||||
let local = util.isWindows() ? util.linuxToWindowsPath(val) : val;
|
||||
val = (
|
||||
<a className="value-right" onClick={this.handleOpenVolumeClick.bind(this, val)}>{local.replace(process.env.HOME, '~')}</a>
|
||||
let local = util.isWindows() ? util.linuxToWindowsPath(source) : source;
|
||||
source = (
|
||||
<a className="value-right" onClick={this.handleOpenVolumeClick.bind(this, source)}>{local.replace(process.env.HOME, '~')}</a>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<tr>
|
||||
<td>{key}</td>
|
||||
<td>{val}</td>
|
||||
<td>{destination}</td>
|
||||
<td>{source}</td>
|
||||
<td>
|
||||
<a className="btn btn-action small" disabled={this.props.container.State.Updating} onClick={this.handleChooseVolumeClick.bind(this, key)}>Change</a>
|
||||
<a className="btn btn-action small" disabled={this.props.container.State.Updating} onClick={this.handleRemoveVolumeClick.bind(this, key)}>Remove</a>
|
||||
<a className="btn btn-action small" disabled={this.props.container.State.Updating} onClick={this.handleChooseVolumeClick.bind(this, destination)}>Change</a>
|
||||
<a className="btn btn-action small" disabled={this.props.container.State.Updating} onClick={this.handleRemoveVolumeClick.bind(this, destination)}>Remove</a>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
|
|
@ -104,7 +116,7 @@ var ContainerSettingsVolumes = React.createClass({
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{volumes}
|
||||
{mounts}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue