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);
|
||||
}
|
||||
|
||||
update (name, containerOpts) {
|
||||
this.dispatch({name, containerOpts});
|
||||
dockerUtil.updateContainer(name, containerOpts);
|
||||
update (name, container) {
|
||||
this.dispatch({name, container});
|
||||
dockerUtil.updateContainer(name, container);
|
||||
}
|
||||
|
||||
clearPending () {
|
||||
|
|
|
@ -18,14 +18,14 @@ var ContainerHomeFolder = React.createClass({
|
|||
from: 'home'
|
||||
});
|
||||
|
||||
if (hostVolume.indexOf(process.env.HOME) === -1) {
|
||||
if (hostVolume.indexOf(util.windowsToLinuxPath(util.home())) === -1) {
|
||||
dialog.showMessageBox({
|
||||
message: 'Enable all volumes to edit files via Finder? 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 = 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;
|
||||
var binds = _.pairs(volumes).map(function (pair) {
|
||||
if(util.isWindows()) {
|
||||
|
@ -44,7 +44,8 @@ var ContainerHomeFolder = React.createClass({
|
|||
}
|
||||
});
|
||||
} else {
|
||||
shell.showItemInFolder(hostVolume);
|
||||
let path = util.isWindows() ? util.linuxToWindowsPath(hostVolume) : hostVolume;
|
||||
shell.showItemInFolder(path);
|
||||
}
|
||||
},
|
||||
handleClickChangeFolders: function () {
|
||||
|
|
|
@ -9,37 +9,49 @@ var containerActions = require('../actions/ContainerActions');
|
|||
|
||||
var ContainerSettingsVolumes = React.createClass({
|
||||
handleChooseVolumeClick: function (dockerVol) {
|
||||
var self = this;
|
||||
dialog.showOpenDialog({properties: ['openDirectory', 'createDirectory']}, (filenames) => {
|
||||
if (!filenames) {
|
||||
return;
|
||||
}
|
||||
|
||||
var directory = filenames[0];
|
||||
if (directory) {
|
||||
|
||||
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.windowsToLinuxPath(directory);
|
||||
directory = util.escapePath(util.windowsToLinuxPath(directory));
|
||||
}
|
||||
var volumes = _.clone(self.props.container.Volumes);
|
||||
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) {
|
||||
metrics.track('Removed Volume Directory', {
|
||||
from: 'settings'
|
||||
});
|
||||
|
||||
var hostConfig = _.clone(this.props.container.HostConfig);
|
||||
var binds = hostConfig.Binds;
|
||||
var volumes = _.clone(this.props.container.Volumes);
|
||||
delete volumes[dockerVol];
|
||||
var binds = _.pairs(volumes).map(function (pair) {
|
||||
return pair[1] + ':' + pair[0];
|
||||
});
|
||||
containerActions.update(this.props.container.Name, {Binds: binds, Volumes: volumes});
|
||||
volumes[dockerVol] = 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});
|
||||
},
|
||||
handleOpenVolumeClick: function (path) {
|
||||
metrics.track('Opened Volume Directory', {
|
||||
|
@ -52,10 +64,7 @@ var ContainerSettingsVolumes = React.createClass({
|
|||
return false;
|
||||
}
|
||||
|
||||
var homeDir = process.env.HOME;
|
||||
if(util.isWindows()) {
|
||||
homeDir = util.windowsToLinuxPath(homeDir);
|
||||
}
|
||||
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 = (
|
||||
|
|
|
@ -74,7 +74,7 @@ class ContainerStore {
|
|||
return;
|
||||
}
|
||||
|
||||
deepExtend(containers[name], container);
|
||||
_.extend(containers[name], container);
|
||||
|
||||
if (containers[name].State) {
|
||||
containers[name].State.Updating = true;
|
||||
|
|
|
@ -44,7 +44,8 @@ module.exports = {
|
|||
return app.getPath('home');
|
||||
},
|
||||
documents: function () {
|
||||
return this.isWindows() ? 'My\ Documents' : 'Documents';
|
||||
// TODO: fix me for windows 7
|
||||
return 'Documents';
|
||||
},
|
||||
supportDir: function () {
|
||||
return app.getPath('userData');
|
||||
|
@ -141,5 +142,8 @@ module.exports = {
|
|||
}
|
||||
return fullPath;
|
||||
},
|
||||
linuxToWindowsPath: function (linuxAbsPath) {
|
||||
return linuxAbsPath.replace('/c', 'c:').split('/').join('\\');
|
||||
},
|
||||
webPorts: ['80', '8000', '8080', '3000', '5000', '2368', '9200', '8983']
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue