mirror of https://github.com/docker/docs.git
Fixing bug where removing a volume would require two clicks on the remove button
This commit is contained in:
parent
407fd508d9
commit
3515c306d5
|
@ -28,9 +28,9 @@ class ContainerActions {
|
||||||
dockerUtil.restart(name);
|
dockerUtil.restart(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
update (name, containerOpts) {
|
update (name, container) {
|
||||||
this.dispatch({name, containerOpts});
|
this.dispatch({name, container});
|
||||||
dockerUtil.updateContainer(name, containerOpts);
|
dockerUtil.updateContainer(name, container);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearPending () {
|
clearPending () {
|
||||||
|
|
|
@ -18,18 +18,18 @@ var ContainerHomeFolder = React.createClass({
|
||||||
from: 'home'
|
from: 'home'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (hostVolume.indexOf(process.env.HOME) === -1) {
|
if (hostVolume.indexOf(util.windowsToLinuxPath(util.home())) === -1) {
|
||||||
dialog.showMessageBox({
|
dialog.showMessageBox({
|
||||||
message: 'Enable all volumes to edit files via Finder? This may not work with all database containers.',
|
message: 'Enable all volumes to edit files via Finder? This may not work with all database containers.',
|
||||||
buttons: ['Enable Volumes', 'Cancel']
|
buttons: ['Enable Volumes', 'Cancel']
|
||||||
}, (index) => {
|
}, (index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
var volumes = _.clone(this.props.container.Volumes);
|
var volumes = _.clone(this.props.container.Volumes);
|
||||||
var newHostVolume = path.join(util.home(), util.documents(), 'Kitematic', this.props.container.Name, containerVolume);
|
var newHostVolume = util.escapePath(path.join(util.home(), util.documents(), 'Kitematic', this.props.container.Name, containerVolume));
|
||||||
volumes[containerVolume] = newHostVolume;
|
volumes[containerVolume] = newHostVolume;
|
||||||
var binds = _.pairs(volumes).map(function (pair) {
|
var binds = _.pairs(volumes).map(function (pair) {
|
||||||
if(util.isWindows()) {
|
if(util.isWindows()) {
|
||||||
return util.windowsToLinuxPath(pair[1]) + ':' + pair[0];
|
return util.windowsToLinuxPath(pair[1]) + ':' + pair[0];
|
||||||
}
|
}
|
||||||
return pair[1] + ':' + pair[0];
|
return pair[1] + ':' + pair[0];
|
||||||
});
|
});
|
||||||
|
@ -44,7 +44,8 @@ var ContainerHomeFolder = React.createClass({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
shell.showItemInFolder(hostVolume);
|
let path = util.isWindows() ? util.linuxToWindowsPath(hostVolume) : hostVolume;
|
||||||
|
shell.showItemInFolder(path);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleClickChangeFolders: function () {
|
handleClickChangeFolders: function () {
|
||||||
|
|
|
@ -9,37 +9,49 @@ var containerActions = require('../actions/ContainerActions');
|
||||||
|
|
||||||
var ContainerSettingsVolumes = React.createClass({
|
var ContainerSettingsVolumes = React.createClass({
|
||||||
handleChooseVolumeClick: function (dockerVol) {
|
handleChooseVolumeClick: function (dockerVol) {
|
||||||
var self = this;
|
|
||||||
dialog.showOpenDialog({properties: ['openDirectory', 'createDirectory']}, (filenames) => {
|
dialog.showOpenDialog({properties: ['openDirectory', 'createDirectory']}, (filenames) => {
|
||||||
if (!filenames) {
|
if (!filenames) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var directory = filenames[0];
|
|
||||||
if (directory) {
|
|
||||||
metrics.track('Choose Directory for Volume');
|
|
||||||
if(util.isWindows()) {
|
|
||||||
directory = util.windowsToLinuxPath(directory);
|
|
||||||
}
|
|
||||||
var volumes = _.clone(self.props.container.Volumes);
|
|
||||||
volumes[dockerVol] = directory;
|
|
||||||
var binds = _.pairs(volumes).map(function (pair) {
|
|
||||||
return pair[1] + ':' + pair[0];
|
|
||||||
});
|
|
||||||
|
|
||||||
containerActions.update(this.props.container.Name, {Binds: binds, Volumes: volumes});
|
var directory = filenames[0];
|
||||||
|
|
||||||
|
if (!directory || directory.indexOf(util.home()) === -1) {
|
||||||
|
dialog.showMessageBox({
|
||||||
|
type: 'warning',
|
||||||
|
buttons: ['OK'],
|
||||||
|
message: 'Invalid directory. Volume directories must be under your Users directory'
|
||||||
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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];
|
||||||
|
});
|
||||||
|
|
||||||
|
containerActions.update(this.props.container.Name, {Binds: binds, Volumes: volumes});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleRemoveVolumeClick: function (dockerVol) {
|
handleRemoveVolumeClick: function (dockerVol) {
|
||||||
metrics.track('Removed Volume Directory', {
|
metrics.track('Removed Volume Directory', {
|
||||||
from: 'settings'
|
from: 'settings'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var hostConfig = _.clone(this.props.container.HostConfig);
|
||||||
|
var binds = hostConfig.Binds;
|
||||||
var volumes = _.clone(this.props.container.Volumes);
|
var volumes = _.clone(this.props.container.Volumes);
|
||||||
delete volumes[dockerVol];
|
volumes[dockerVol] = null;
|
||||||
var binds = _.pairs(volumes).map(function (pair) {
|
var index = _.findIndex(binds, bind => bind.indexOf(`:${dockerVol}`) !== -1);
|
||||||
return pair[1] + ':' + pair[0];
|
if (index >= 0) {
|
||||||
});
|
binds.splice(index, 1);
|
||||||
containerActions.update(this.props.container.Name, {Binds: binds, Volumes: volumes});
|
}
|
||||||
|
containerActions.update(this.props.container.Name, {HostConfig: hostConfig, Binds: binds, Volumes: volumes});
|
||||||
},
|
},
|
||||||
handleOpenVolumeClick: function (path) {
|
handleOpenVolumeClick: function (path) {
|
||||||
metrics.track('Opened Volume Directory', {
|
metrics.track('Opened Volume Directory', {
|
||||||
|
@ -52,10 +64,7 @@ var ContainerSettingsVolumes = React.createClass({
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var homeDir = process.env.HOME;
|
var homeDir = util.isWindows() ? util.windowsToLinuxPath(util.home()) : util.home();
|
||||||
if(util.isWindows()) {
|
|
||||||
homeDir = util.windowsToLinuxPath(homeDir);
|
|
||||||
}
|
|
||||||
var volumes = _.map(this.props.container.Volumes, (val, key) => {
|
var volumes = _.map(this.props.container.Volumes, (val, key) => {
|
||||||
if (!val || val.indexOf(homeDir) === -1) {
|
if (!val || val.indexOf(homeDir) === -1) {
|
||||||
val = (
|
val = (
|
||||||
|
|
|
@ -74,7 +74,7 @@ class ContainerStore {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
deepExtend(containers[name], container);
|
_.extend(containers[name], container);
|
||||||
|
|
||||||
if (containers[name].State) {
|
if (containers[name].State) {
|
||||||
containers[name].State.Updating = true;
|
containers[name].State.Updating = true;
|
||||||
|
|
|
@ -44,7 +44,8 @@ module.exports = {
|
||||||
return app.getPath('home');
|
return app.getPath('home');
|
||||||
},
|
},
|
||||||
documents: function () {
|
documents: function () {
|
||||||
return this.isWindows() ? 'My\ Documents' : 'Documents';
|
// TODO: fix me for windows 7
|
||||||
|
return 'Documents';
|
||||||
},
|
},
|
||||||
supportDir: function () {
|
supportDir: function () {
|
||||||
return app.getPath('userData');
|
return app.getPath('userData');
|
||||||
|
@ -141,5 +142,8 @@ module.exports = {
|
||||||
}
|
}
|
||||||
return fullPath;
|
return fullPath;
|
||||||
},
|
},
|
||||||
|
linuxToWindowsPath: function (linuxAbsPath) {
|
||||||
|
return linuxAbsPath.replace('/c', 'c:').split('/').join('\\');
|
||||||
|
},
|
||||||
webPorts: ['80', '8000', '8080', '3000', '5000', '2368', '9200', '8983']
|
webPorts: ['80', '8000', '8080', '3000', '5000', '2368', '9200', '8983']
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue