Skip to content

Commit 6803c1e

Browse files
committed
Add buttons for opening monotor windows
1 parent b4dbe97 commit 6803c1e

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

src/app/containers/App.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import React, { cloneElement, Component, PropTypes } from 'react';
2+
import { sendToBg } from 'crossmessaging';
23
import styles from 'remotedev-app/lib/styles';
34
import Instances from 'remotedev-app/lib/components/Instances';
45
import Button from 'remotedev-app/lib/components/Button';
56
import SettingsIcon from 'react-icons/lib/md/settings';
7+
import LeftIcon from 'react-icons/lib/md/border-left';
8+
import RightIcon from 'react-icons/lib/md/border-right';
9+
import BottomIcon from 'react-icons/lib/md/border-bottom';
610
import Monitor from './Monitor';
711

12+
let monitorPosition;
13+
if (location.hash) monitorPosition = location.hash.substr(location.hash.indexOf('-') + 1);
14+
815
export default class App extends Component {
916
static propTypes = {
1017
store: PropTypes.object
@@ -17,6 +24,10 @@ export default class App extends Component {
1724
this.props.store.setInstance(this.props.store.instance, true);
1825
};
1926

27+
openWindow = (position) => {
28+
sendToBg({ type: 'OPEN', position });
29+
};
30+
2031
render() {
2132
const { store, ...childProps } = this.props;
2233
return (
@@ -29,6 +40,24 @@ export default class App extends Component {
2940
<Monitor {...childProps} />
3041
{chrome.runtime.openOptionsPage ?
3142
<div style={styles.buttonBar}>
43+
{monitorPosition !== 'left' ?
44+
<Button
45+
Icon={LeftIcon}
46+
onClick={() => { this.openWindow('left'); }}
47+
/>
48+
: null }
49+
{monitorPosition !== 'right' ?
50+
<Button
51+
Icon={RightIcon}
52+
onClick={() => { this.openWindow('right'); }}
53+
/>
54+
: null }
55+
{monitorPosition !== 'bottom' ?
56+
<Button
57+
Icon={BottomIcon}
58+
onClick={() => { this.openWindow('bottom'); }}
59+
/>
60+
: null }
3261
<Button
3362
Icon={SettingsIcon}
3463
onClick={() => { chrome.runtime.openOptionsPage(); }}

src/app/containers/Monitor.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import ChartMonitor from 'redux-devtools-chart-monitor';
55
import SliderMonitor from 'redux-slider-monitor';
66

77
function getMonitor() {
8-
const monitorType = location.hash.substr(1);
9-
switch (monitorType) {
8+
if (!location.hash) return LogMonitor;
9+
const monitorTypes = location.hash.substr(1).split('/');
10+
switch (monitorTypes[0]) {
1011
case 'SliderMonitor': return SliderMonitor;
1112
case 'ChartMonitor': return ChartMonitor;
1213
default: return LogMonitor;

src/browser/extension/background/openWindow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function openDevToolsWindow(position) {
2525
};
2626
if (action === 'open') {
2727
getMonitorName(position, monitorName => {
28-
options.url = chrome.extension.getURL(url + '#' + monitorName);
28+
options.url = chrome.extension.getURL(url + '#' + monitorName + '/' + position);
2929
chrome.windows.create(options, (win) => {
3030
windows[position] = win.id;
3131
});

0 commit comments

Comments
 (0)