diff --git a/package.json b/package.json index 07ed9db51e..fc3adc32c1 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ "node_modules/6to5" ] }, - "docker-version": "1.4.1", - "boot2docker-version": "1.4.1", + "docker-version": "1.5.0", + "boot2docker-version": "1.5.0", "atom-shell-version": "0.21.1", "virtualbox-version": "4.3.20", "virtualbox-filename": "VirtualBox-4.3.20.pkg", diff --git a/src/ContainerDetails.react.js b/src/ContainerDetails.react.js index 745d77ab86..1063adf9c3 100644 --- a/src/ContainerDetails.react.js +++ b/src/ContainerDetails.react.js @@ -19,7 +19,7 @@ var ContainerDetail = React.createClass({ }, init: function () { var currentRoute = _.last(this.getRoutes()).name; - if (currentRoute === 'containerDetail') { + if (currentRoute === 'containerDetails') { this.transitionTo('containerHome', {name: this.getParams().name}); } }, diff --git a/src/ContainerDetailsbak.react.js b/src/ContainerDetailsbak.react.js deleted file mode 100644 index 049f41b690..0000000000 --- a/src/ContainerDetailsbak.react.js +++ /dev/null @@ -1,640 +0,0 @@ -var _ = require('underscore'); -var $ = require('jquery'); -var React = require('react/addons'); -var Router = require('react-router'); -var exec = require('exec'); -var path = require('path'); -var remote = require('remote'); -var rimraf = require('rimraf'); -var fs = require('fs'); -var dialog = remote.require('dialog'); -var ContainerStore = require('./ContainerStore'); -var ContainerUtil = require('./ContainerUtil'); -var boot2docker = require('./Boot2Docker'); -var ContainerDetailsHeader = require('./ContainerDetailsHeader.react'); -var ContainerHome = require('./ContainerHome.react'); -var RetinaImage = require('react-retina-image'); -var Radial = require('./Radial.react'); - -var _oldHeight = 0; - -var ContainerDetailsbak = React.createClass({ - mixins: [Router.State, Router.Navigation], - PAGE_HOME: 'home', - PAGE_LOGS: 'logs', - PAGE_SETTINGS: 'settings', - PAGE_PORTS: 'ports', - PAGE_VOLUMES: 'volumes', - getInitialState: function () { - return { - logs: [], - page: this.PAGE_HOME, - env: {}, - pendingEnv: {}, - ports: {}, - volumes: {}, - defaultPort: null - }; - }, - componentWillReceiveProps: function () { - this.init(); - }, - componentDidMount: function () { - this.init(); - ContainerStore.on(ContainerStore.SERVER_PROGRESS_EVENT, this.updateProgress); - ContainerStore.on(ContainerStore.SERVER_LOGS_EVENT, this.updateLogs); - }, - componentWillUnmount: function () { - ContainerStore.removeListener(ContainerStore.SERVER_PROGRESS_EVENT, this.updateProgress); - ContainerStore.removeListener(ContainerStore.SERVER_LOGS_EVENT, this.updateLogs); - }, - componentDidUpdate: function () { - // Scroll logs to bottom - var parent = $('.details-logs'); - if (parent.length) { - if (parent.scrollTop() >= _oldHeight) { - parent.stop(); - parent.scrollTop(parent[0].scrollHeight - parent.height()); - } - _oldHeight = parent[0].scrollHeight - parent.height(); - } - }, - init: function () { - var container = ContainerStore.container(this.getParams().name); - if (!container) { - return; - } - this.setState({ - progress: ContainerStore.progress(this.getParams().name), - env: ContainerUtil.env(container), - page: this.PAGE_HOME - }); - var ports = ContainerUtil.ports(container); - var webPorts = ['80', '8000', '8080', '3000', '5000', '2368']; - this.setState({ - ports: ports, - defaultPort: _.find(_.keys(ports), function (port) { - return webPorts.indexOf(port) !== -1; - }) - }); - this.updateLogs(); - }, - updateLogs: function (name) { - if (name && name !== this.getParams().name) { - return; - } - this.setState({ - logs: ContainerStore.logs(this.getParams().name) - }); - }, - updateProgress: function (name) { - if (name === this.getParams().name) { - this.setState({ - progress: ContainerStore.progress(name) - }); - } - }, - disableRun: function () { - return (!this.props.container.State.Running || !this.state.defaultPort); - }, - disableRestart: function () { - return (this.props.container.State.Downloading || this.props.container.State.Restarting); - }, - disableTerminal: function () { - return (!this.props.container.State.Running); - }, - disableTab: function () { - return (this.props.container.State.Downloading); - }, - showHome: function () { - if (!this.disableTab()) { - /*this.setState({ - page: this.PAGE_HOME - });*/ - this.transitionTo('containerHome', {name: this.getParams().name}); - } - }, - showLogs: function () { - if (!this.disableTab()) { - this.setState({ - page: this.PAGE_LOGS - }); - } - }, - showPorts: function () { - this.setState({ - page: this.PAGE_PORTS - }); - }, - showVolumes: function () { - this.setState({ - page: this.PAGE_VOLUMES - }); - }, - showSettings: function () { - if (!this.disableTab()) { - this.setState({ - page: this.PAGE_SETTINGS - }); - } - }, - handleRun: function () { - if (this.state.defaultPort && !this.disableRun()) { - exec(['open', this.state.ports[this.state.defaultPort].url], function (err) { - if (err) { throw err; } - }); - } - }, - handleRestart: function () { - if (!this.disableRestart()) { - ContainerStore.restart(this.props.container.Name, function (err) { - console.log(err); - }); - } - }, - handleTerminal: function () { - if (!this.disableTerminal()) { - var container = this.props.container; - var terminal = path.join(process.cwd(), 'resources', 'terminal'); - var cmd = [terminal, boot2docker.command().replace(/ /g, '\\\\\\\\ ').replace(/\(/g, '\\\\\\\\(').replace(/\)/g, '\\\\\\\\)'), 'ssh', '-t', 'sudo', 'docker', 'exec', '-i', '-t', container.Name, 'sh']; - exec(cmd, function (stderr, stdout, code) { - console.log(stderr); - console.log(stdout); - if (code) { - console.log(stderr); - } - }); - } - }, - handleViewLink: function (url) { - exec(['open', url], function (err) { - if (err) { throw err; } - }); - }, - handleChangeDefaultPort: function (port, e) { - if (e.target.checked) { - this.setState({ - defaultPort: null - }); - } else { - this.setState({ - defaultPort: port - }); - } - }, - handleChooseVolumeClick: function (dockerVol) { - var self = this; - dialog.showOpenDialog({properties: ['openDirectory', 'createDirectory']}, function (filenames) { - if (!filenames) { - return; - } - var directory = filenames[0]; - if (directory) { - var volumes = _.clone(self.props.container.Volumes); - volumes[dockerVol] = directory; - 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); } - }); - } - }); - }, - handleOpenVolumeClick: function (path) { - exec(['open', path], function (err) { - if (err) { throw err; } - }); - }, - handleSaveContainerName: function () { - var newName = $('#input-container-name').val(); - if (newName === this.props.container.Name) { - return; - } - if (fs.existsSync(path.join(process.env.HOME, 'Kitematic', this.props.container.Name))) { - fs.renameSync(path.join(process.env.HOME, 'Kitematic', this.props.container.Name), path.join(process.env.HOME, 'Kitematic', newName)); - } - ContainerStore.updateContainer(this.props.container.Name, { - name: newName - }, function (err) { - this.transitionTo('container', {name: newName}); - if (err) { - console.error(err); - } - }.bind(this)); - }, - handleSaveEnvVar: function () { - var $rows = $('.env-vars .keyval-row'); - var envVarList = []; - $rows.each(function () { - var key = $(this).find('.key').val(); - var val = $(this).find('.val').val(); - if (!key.length || !val.length) { - return; - } - envVarList.push(key + '=' + val); - }); - var self = this; - ContainerStore.updateContainer(self.props.container.Name, { - Env: envVarList - }, function (err) { - if (err) { - console.error(err); - } else { - self.setState({ - pendingEnv: {} - }); - $('#new-env-key').val(''); - $('#new-env-val').val(''); - } - }); - }, - handleAddPendingEnvVar: function () { - var newKey = $('#new-env-key').val(); - var newVal = $('#new-env-val').val(); - var newEnv = {}; - newEnv[newKey] = newVal; - this.setState({ - pendingEnv: _.extend(this.state.pendingEnv, newEnv) - }); - $('#new-env-key').val(''); - $('#new-env-val').val(''); - }, - handleRemoveEnvVar: function (key) { - var newEnv = _.omit(this.state.env, key); - this.setState({ - env: newEnv - }); - }, - handleRemovePendingEnvVar: function (key) { - var newEnv = _.omit(this.state.pendingEnv, key); - this.setState({ - pendingEnv: newEnv - }); - }, - handleDeleteContainer: function () { - dialog.showMessageBox({ - message: 'Are you sure you want to delete this container?', - buttons: ['Delete', 'Cancel'] - }, function (index) { - var volumePath = path.join(process.env.HOME, 'Kitematic', this.props.container.Name); - if (fs.existsSync(volumePath)) { - rimraf(volumePath, function (err) { - console.log(err); - }); - } - if (index === 0) { - ContainerStore.remove(this.props.container.Name, function (err) { - console.error(err); - }); - } - }.bind(this)); - }, - handleItemMouseEnterRun: function () { - var $action = $(this.getDOMNode()).find('.action .run'); - $action.css("visibility", "visible"); - }, - handleItemMouseLeaveRun: function () { - var $action = $(this.getDOMNode()).find('.action .run'); - $action.css("visibility", "hidden"); - }, - handleItemMouseEnterRestart: function () { - var $action = $(this.getDOMNode()).find('.action .restart'); - $action.css("visibility", "visible"); - }, - handleItemMouseLeaveRestart: function () { - var $action = $(this.getDOMNode()).find('.action .restart'); - $action.css("visibility", "hidden"); - }, - handleItemMouseEnterTerminal: function () { - var $action = $(this.getDOMNode()).find('.action .terminal'); - $action.css("visibility", "visible"); - }, - handleItemMouseLeaveTerminal: function () { - var $action = $(this.getDOMNode()).find('.action .terminal'); - $action.css("visibility", "hidden"); - }, - render: function () { - var self = this; - - if (!this.state) { - return
; - } - - var logs = this.state.logs.map(function (l, i) { - return ; - }); - - if (!this.props.container) { - return false; - } - - var button; - if (this.state.progress === 1) { - button = View; - } else { - button = View; - } - - var envVars = _.map(this.state.env, function (val, key) { - return ( - - ); - }); - var pendingEnvVars = _.map(this.state.pendingEnv, function (val, key) { - return ( - - ); - }); - - var disabledClass = ''; - if (!this.props.container.State.Running) { - disabledClass = 'disabled'; - } - - /*var buttonClass = React.addons.classSet({ - btn: true, - 'btn-action': true, - 'with-icon': true, - disabled: !this.props.container.State.Running - }); - - var restartButtonClass = React.addons.classSet({ - btn: true, - 'btn-action': true, - 'with-icon': true, - disabled: this.props.container.State.Downloading || this.props.container.State.Restarting - }); - - var viewButtonClass = React.addons.classSet({ - btn: true, - 'btn-action': true, - 'with-icon': true, - disabled: !this.props.container.State.Running || !this.state.defaultPort - }); - - var kitematicVolumes = _.pairs(this.props.container.Volumes).filter(function (pair) { - return pair[1].indexOf(path.join(process.env.HOME, 'Kitematic')) !== -1; - }); - - var volumesButtonClass = React.addons.classSet({ - btn: true, - 'btn-action': true, - 'with-icon': true, - disabled: !kitematicVolumes.length - }); - - var textButtonClasses = React.addons.classSet({ - 'btn': true, - 'btn-action': true, - 'only-icon': true, - 'active': this.state.page === this.PAGE_LOGS, - disabled: this.props.container.State.Downloading - }); - - var gearButtonClass = React.addons.classSet({ - 'btn': true, - 'btn-action': true, - 'only-icon': true, - 'active': this.state.page === this.PAGE_SETTINGS, - disabled: this.props.container.State.Downloading - });*/ - - var ports = _.map(_.pairs(self.state.ports), function (pair) { - var key = pair[0]; - var val = pair[1]; - return ( -