Add option in Developer Settings to enable/disable developer menu

Also added the ability to access Developer Settings by holding
Ctrl-Shift or Cmd-Shift and clicking the LBRY logo.

https://youtu.be/pXPXMxsXT28
This commit is contained in:
Alex Liebowitz 2017-03-08 03:56:34 -05:00
parent a6979445cc
commit 694eb77b0b
5 changed files with 33 additions and 14 deletions

View file

@ -8,8 +8,8 @@ Web UI version numbers should always match the corresponding version of LBRY App
## [Unreleased] ## [Unreleased]
### Added ### 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 ### Changed

View file

@ -20,6 +20,13 @@ var drawerImageStyle = { //@TODO: remove this, img should be properly scaled onc
}; };
var Drawer = React.createClass({ var Drawer = React.createClass({
handleLogoClicked: function(event) {
if (event.shiftKey && (event.ctrlKey || event.metaKey)) {
window.location.href = 'index.html?developer'
event.preventDefault();
return false;
}
},
getInitialState: function() { getInitialState: function() {
return { return {
balance: 0, balance: 0,
@ -37,7 +44,7 @@ var Drawer = React.createClass({
<nav id="drawer"> <nav id="drawer">
<div id="drawer-handle"> <div id="drawer-handle">
<Link title="Close" onClick={this.props.onCloseDrawer} icon="icon-bars" className="close-drawer-link"/> <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> </div>
<DrawerItem href='index.html?discover' viewingPage={this.props.viewingPage} label="Discover" icon="icon-search" /> <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" /> <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'; import lighthouse from './lighthouse.js';
const {remote} = require('electron');
const menu = remote.require('./menu/main-menu');
var lbry = { var lbry = {
isConnected: false, isConnected: false,
rootPath: '.', rootPath: '.',
@ -15,6 +18,7 @@ var lbry = {
debug: false, debug: false,
useCustomLighthouseServers: false, useCustomLighthouseServers: false,
customLighthouseServers: [], customLighthouseServers: [],
menu: 'normal',
} }
}; };
@ -555,4 +559,16 @@ lbry.fileInfoUnsubscribe = function(name, subscribeId) {
delete lbry._fileInfoSubscribeCallbacks[name][subscribeId]; delete lbry._fileInfoSubscribeCallbacks[name][subscribeId];
} }
lbry.showMenuIfNeeded = function() {
const showingMenu = sessionStorage.getItem('menuShown');
const chosenMenu = lbry.getClientSetting('menu');
if (!showingMenu || showingMenu != chosenMenu) {
if (chosenMenu == 'normal') {
menu.showNormalMenubar();
} else {
menu.showDeveloperMenubar();
}
}
};
export default lbry; export default lbry;

View file

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

View file

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