mirror of
https://github.com/docker/docs.git
synced 2026-04-02 09:18:57 +07:00
75 lines
2.2 KiB
JavaScript
75 lines
2.2 KiB
JavaScript
var React = require('react/addons');
|
|
var ipc = require('ipc');
|
|
var metrics = require('./Metrics');
|
|
var Router = require('react-router');
|
|
|
|
if (localStorage.getItem('settings.closeVMOnQuit') === 'true') {
|
|
ipc.send('vm', true);
|
|
} else {
|
|
ipc.send('vm', false);
|
|
}
|
|
|
|
var Preferences = React.createClass({
|
|
mixins: [Router.Navigation],
|
|
getInitialState: function () {
|
|
return {
|
|
closeVMOnQuit: localStorage.getItem('settings.closeVMOnQuit') === 'true',
|
|
metricsEnabled: metrics.enabled()
|
|
};
|
|
},
|
|
handleGoBackClick: function () {
|
|
this.goBack();
|
|
metrics.track('Went Back From Preferences');
|
|
},
|
|
handleChangeCloseVMOnQuit: function (e) {
|
|
var checked = e.target.checked;
|
|
this.setState({
|
|
closeVMOnQuit: checked
|
|
});
|
|
localStorage.setItem('settings.closeVMOnQuit', checked);
|
|
ipc.send('vm', checked);
|
|
metrics.track('Toggled Close VM On Quit', {
|
|
close: checked
|
|
});
|
|
},
|
|
handleChangeMetricsEnabled: function (e) {
|
|
var checked = e.target.checked;
|
|
this.setState({
|
|
metricsEnabled: checked
|
|
});
|
|
metrics.setEnabled(checked);
|
|
metrics.track('Toggled Metrics', {
|
|
enabled: checked
|
|
});
|
|
},
|
|
render: function () {
|
|
return (
|
|
<div className="preferences">
|
|
<div className="preferences-content">
|
|
<a onClick={this.handleGoBackClick}>Go Back</a>
|
|
<div className="title">VM Settings</div>
|
|
<div className="option">
|
|
<div className="option-name">
|
|
Shut Down Linux VM on closing Kitematic
|
|
</div>
|
|
<div className="option-value">
|
|
<input type="checkbox" checked={this.state.closeVMOnQuit} onChange={this.handleChangeCloseVMOnQuit}/>
|
|
</div>
|
|
</div>
|
|
<div className="title">App Settings</div>
|
|
<div className="option">
|
|
<div className="option-name">
|
|
Report anonymous usage analytics
|
|
</div>
|
|
<div className="option-value">
|
|
<input type="checkbox" checked={this.state.metricsEnabled} onChange={this.handleChangeMetricsEnabled}/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
});
|
|
|
|
module.exports = Preferences;
|