Merge pull request #193 from lbryio/developer-menu

Add option in Developer Settings to enable/disable developer menu
This commit is contained in:
alexliebowitz 2017-03-08 18:24:13 -05:00 committed by GitHub
commit 2ff2d12d94
5 changed files with 29 additions and 14 deletions

View file

@ -8,8 +8,8 @@ Web UI version numbers should always match the corresponding version of LBRY App
## [Unreleased]
### Added
*
*
* A way to access the Developer Settings panel in Electron (Ctrl-Shift or Cmd-Shift and click logo)
* Option in Developer Settings to toggle developer menu
*
### Changed

View file

@ -20,6 +20,12 @@ var drawerImageStyle = { //@TODO: remove this, img should be properly scaled onc
};
var Drawer = React.createClass({
handleLogoClicked: function(event) {
if (event.ctrlKey && event.shiftKey) {
window.location.href = 'index.html?developer'
event.preventDefault();
}
},
getInitialState: function() {
return {
balance: 0,
@ -37,7 +43,7 @@ var Drawer = React.createClass({
<nav id="drawer">
<div id="drawer-handle">
<Link title="Close" onClick={this.props.onCloseDrawer} icon="icon-bars" className="close-drawer-link"/>
<a href="index.html?discover"><img src={lbry.imagePath("lbry-dark-1600x528.png")} style={drawerImageStyle}/></a>
<a href="index.html?discover" onMouseUp={this.handleLogoClicked}><img src={lbry.imagePath("lbry-dark-1600x528.png")} style={drawerImageStyle}/></a>
</div>
<DrawerItem href='index.html?discover' viewingPage={this.props.viewingPage} label="Discover" icon="icon-search" />
<DrawerItem href='index.html?publish' viewingPage={this.props.viewingPage} label="Publish" icon="icon-upload" />

View file

@ -1,5 +1,8 @@
import lighthouse from './lighthouse.js';
const {remote} = require('electron');
const menu = remote.require('./menu/main-menu');
var lbry = {
isConnected: false,
rootPath: '.',
@ -15,6 +18,7 @@ var lbry = {
debug: false,
useCustomLighthouseServers: false,
customLighthouseServers: [],
showDeveloperMenubar: false,
}
};
@ -547,4 +551,13 @@ lbry.fileInfoUnsubscribe = function(name, subscribeId) {
delete lbry._fileInfoSubscribeCallbacks[name][subscribeId];
}
lbry.showMenuIfNeeded = function() {
const showingMenu = sessionStorage.getItem('menuShown') || null;
const chosenMenu = lbry.getClientSetting('showDeveloperMenu') ? 'developer' : 'normal';
if (chosenMenu != showingMenu) {
menu.showMenubar(chosenMenu == 'developer');
}
sessionStorage.setItem('menuShown', chosenMenu);
};
export default lbry;

View file

@ -5,6 +5,7 @@ import lighthouse from './lighthouse.js';
import App from './app.js';
import SplashScreen from './component/splash.js';
lbry.showMenuIfNeeded();
var init = function() {
window.lbry = lbry;

View file

@ -5,15 +5,16 @@ import FormField from '../component/form.js';
const DeveloperPage = React.createClass({
getInitialState: function() {
return {
debugMode: lbry.getClientSetting('debug'),
showDeveloperMenu: lbry.getClientSetting('showDeveloperMenu'),
useCustomLighthouseServers: lbry.getClientSetting('useCustomLighthouseServers'),
customLighthouseServers: lbry.getClientSetting('customLighthouseServers').join('\n'),
};
},
handleDebugModeChange: function(event) {
lbry.setClientSetting('debug', event.target.checked);
handleShowDeveloperMenuChange: function(event) {
lbry.setClientSetting('showDeveloperMenu', event.target.checked);
lbry.showMenuIfNeeded();
this.setState({
debugMode: event.target.checked,
showDeveloperMenu: event.target.checked,
});
},
handleUseCustomLighthouseServersChange: function(event) {
@ -22,19 +23,13 @@ const DeveloperPage = React.createClass({
useCustomLighthouseServers: event.target.checked,
});
},
handleCustomLighthouseServersChange: function(event) {
lbry.setClientSetting('customLighthouseServers', event.target.value.trim().split('\n'));
this.setState({
customLighthouseServers: event.target.value,
});
},
render: function() {
return (
<main>
<section className="card">
<h3>Developer Settings</h3>
<div className="form-row">
<label><FormField type="checkbox" onChange={this.handleDebugModeChange} checked={this.state.debugMode} /> Enable debug mode (exposes LBRY modules in global scope)</label>
<label><FormField type="checkbox" onChange={this.handleShowDeveloperMenuChange} checked={this.state.showDeveloperMenu} /> Show developer menu</label>
</div>
<div className="form-row">
<label><FormField type="checkbox" onChange={this.handleUseCustomLighthouseServersChange} checked={this.state.useCustomLighthouseServers} /> Use custom search servers</label>