Remove container web preview for security reasons

Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
This commit is contained in:
Mathieu Champlon 2019-09-25 16:15:17 +02:00
Родитель e9968d57e5
Коммит 6554c5c6d5
3 изменённых файлов: 1 добавлений и 102 удалений

Просмотреть файл

@ -2,7 +2,6 @@ import _ from 'underscore';
import $ from 'jquery';
import React from 'react/addons';
import ContainerProgress from './ContainerProgress.react';
import ContainerHomePreview from './ContainerHomePreview.react';
import ContainerHomeLogs from './ContainerHomeLogs.react';
import ContainerHomeFolders from './ContainerHomeFolders.react';
import {shell} from 'electron';
@ -36,10 +35,6 @@ var ContainerHome = React.createClass({
shell.openExternal('https://github.com/kitematic/kitematic/issues/new');
},
showWeb: function () {
return _.keys(this.props.ports).length > 0;
},
showFolders: function () {
return this.props.container.Mounts && this.props.container.Mounts.length > 0 && this.props.container.State.Running;
},
@ -118,19 +113,13 @@ var ContainerHome = React.createClass({
var logWidget = (
<ContainerHomeLogs container={this.props.container}/>
);
var webWidget;
if (this.showWeb()) {
webWidget = (
<ContainerHomePreview ports={this.props.ports} defaultPort={this.props.defaultPort} />
);
}
var folderWidget;
if (this.showFolders()) {
folderWidget = (
<ContainerHomeFolders container={this.props.container} />
);
}
if (logWidget && !webWidget && !folderWidget) {
if (logWidget && !folderWidget) {
body = (
<div className="details-panel home">
<div className="content">
@ -148,7 +137,6 @@ var ContainerHome = React.createClass({
{logWidget}
</div>
<div className="right">
{webWidget}
{folderWidget}
</div>
</div>

Просмотреть файл

@ -1,50 +0,0 @@
import React from 'react/addons';
import request from 'request';
import metrics from '../utils/MetricsUtil';
import ContainerHomeWebPreview from './ContainerHomeWebPreview.react';
import ContainerHomeIpPortsPreview from './ContainerHomeIpPortsPreview.react';
var ContainerHomePreview = React.createClass({
contextTypes: {
router: React.PropTypes.func
},
reload: function () {
var webview = document.getElementById('webview');
if (webview) {
var url = webview.src;
request(url, err => {
if (err && err.code === 'ECONNREFUSED') {
setTimeout(this.reload, 2000);
} else {
try {
webview.reload();
} catch (err) {}
}
});
}
},
componentWillUnmount: function () {
clearInterval(this.timer);
},
handleClickPortSettings: function () {
metrics.track('Viewed Port Settings', {
from: 'preview'
});
this.context.router.transitionTo('containerSettingsPorts', {name: this.context.router.getCurrentParams().name});
},
render: function () {
var preview;
if (this.props.defaultPort) {
preview = (<ContainerHomeWebPreview ports={this.props.ports} defaultPort={this.props.defaultPort} handleClickPortSettings={this.handleClickPortSettings}/>);
} else {
preview = (<ContainerHomeIpPortsPreview ports={this.props.ports} handleClickPortSettings={this.handleClickPortSettings}/>);
}
return preview;
}
});
module.exports = ContainerHomePreview;

Просмотреть файл

@ -1,39 +0,0 @@
import React from 'react/addons';
import metrics from '../utils/MetricsUtil';
import {shell} from 'electron';
var ContainerHomeWebPreview = React.createClass({
handleClickPreview: function () {
metrics.track('Opened In Browser', {
from: 'preview'
});
shell.openExternal('http://' + this.props.ports[this.props.defaultPort].url);
},
handleClickPortSettings: function () {
this.props.handleClickPortSettings();
},
render: function () {
var frame = React.createElement('webview', {className: 'frame', id: 'webview', src: 'http://' + this.props.ports[this.props.defaultPort].url, autosize: 'on'});
return (
<div className="web-preview wrapper">
<div className="widget">
<div className="top-bar">
<div className="text">Web Preview</div>
<div className="action" onClick={this.handleClickPreview}>
<span className="icon icon-open-external"></span>
</div>
<div className="action" onClick={this.handleClickPortSettings}>
<span className="icon icon-preferences"></span>
</div>
</div>
{frame}
<div onClick={this.handleClickPreview} className="frame-overlay"></div>
</div>
</div>
);
}
});
module.exports = ContainerHomeWebPreview;