Skip to content

Commit 751e831

Browse files
committed
Changing the monitor from the same window
1 parent 8a2f47e commit 751e831

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@
6262
"react-redux": "^4.4.5",
6363
"redux": "^3.5.2",
6464
"redux-devtools": "^3.3.1",
65-
"remotedev-app": "^0.3.8"
65+
"remotedev-app": "^0.4.0"
6666
}
6767
}

src/app/containers/App.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { cloneElement, Component, PropTypes } from 'react';
22
import { sendToBg } from 'crossmessaging';
33
import styles from 'remotedev-app/lib/styles';
4+
import enhance from 'remotedev-app/lib/hoc';
45
import DevTools from 'remotedev-app/lib/containers/DevTools';
56
import MonitorSelector from 'remotedev-app/lib/components/MonitorSelector';
67
import Instances from 'remotedev-app/lib/components/Instances';
@@ -15,26 +16,29 @@ import RightIcon from 'react-icons/lib/md/border-right';
1516
import BottomIcon from 'react-icons/lib/md/border-bottom';
1617
import RemoteIcon from 'react-icons/lib/go/radio-tower';
1718

18-
let monitorPosition;
19-
if (location.hash) monitorPosition = location.hash.substr(location.hash.indexOf('-') + 1);
19+
const monitorPosition = location.hash;
2020

21+
@enhance
2122
export default class App extends Component {
2223
static propTypes = {
2324
store: PropTypes.object
2425
};
2526

2627
state = {
27-
monitor: location.hash && location.hash.substr(1).split('/')[0],
28+
monitor: localStorage.getItem('monitor' + monitorPosition),
29+
instance: 'auto',
2830
dispatcherIsOpen: false,
2931
sliderIsOpen: false
3032
};
3133

32-
handleSelectMonitor = e => {
33-
this.setState({ monitor: e.target.value });
34+
handleSelectMonitor = (event, index, value) => {
35+
this.setState({ monitor: value });
36+
localStorage.setItem('monitor' + monitorPosition, value);
3437
};
3538

36-
handleSelectInstance = e => {
37-
this.props.store.setInstance(e.target.value);
39+
handleSelectInstance = (event, index, value) => {
40+
this.setState({ instance: value });
41+
this.props.store.setInstance(value);
3842
};
3943

4044
openWindow = (position) => {
@@ -52,23 +56,23 @@ export default class App extends Component {
5256
render() {
5357
const { store } = this.props;
5458
const instances = store.instances;
55-
const { monitor } = this.state;
59+
const { instance, monitor } = this.state;
5660
return (
5761
<div style={styles.container}>
58-
{instances &&
5962
<div style={styles.buttonBar}>
6063
<MonitorSelector selected={this.state.monitor} onSelect={this.handleSelectMonitor}/>
61-
<Instances instances={instances} onSelect={this.handleSelectInstance}/>
64+
{instances &&
65+
<Instances instances={instances} onSelect={this.handleSelectInstance} selected={instance} />
66+
}
6267
</div>
63-
}
64-
<DevTools monitor={monitor} store={store} key={`${monitor}-${store.instance}`} />
68+
<DevTools monitor={monitor} store={store} key={`${monitor}-${instance}`} />
6569
{this.state.sliderIsOpen && <div style={styles.sliderMonitor}>
66-
<DevTools monitor="SliderMonitor" store={store} key={`Slider-${store.instance}`} />
70+
<DevTools monitor="SliderMonitor" store={store} key={`Slider-${instance}`} />
6771
</div>}
6872
{this.state.dispatcherIsOpen &&
6973
<DevTools monitor="DispatchMonitor"
7074
store={store} dispatchFn={store.dispatch}
71-
key={`Dispatch-${store.instance}`}
75+
key={`Dispatch-${instance}`}
7276
/>
7377
}
7478
<div style={styles.buttonBar}>

src/browser/extension/background/openWindow.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import getMonitorName from '../options/getMonitorName';
21
let windows = {};
32
let lastPosition = null;
43

@@ -24,11 +23,9 @@ export default function openDevToolsWindow(position) {
2423
...customOptions
2524
};
2625
if (action === 'open') {
27-
getMonitorName(position, monitorName => {
28-
options.url = chrome.extension.getURL(url + (monitorName ? '#' + monitorName + '/' + position : ''));
29-
chrome.windows.create(options, (win) => {
30-
windows[position] = win.id;
31-
});
26+
options.url = chrome.extension.getURL(url + '#' + position.substr(position.indexOf('-') + 1));
27+
chrome.windows.create(options, (win) => {
28+
windows[position] = win.id;
3229
});
3330
}
3431
});
@@ -41,7 +38,7 @@ export default function openDevToolsWindow(position) {
4138
params.left = window.screen.availWidth - params.width;
4239
break;
4340
case 'devtools-bottom':
44-
params.height = 200;
41+
params.height = 300;
4542
params.top = window.screen.availHeight - params.height;
4643
params.width = window.screen.availWidth;
4744
break;

0 commit comments

Comments
 (0)