Skip to content

Commit 139f4ff

Browse files
wldcordeirojasonLaster
authored andcommitted
Merge pull request firefox-devtools#3507 from devtools-html/debugger.html/jsx-conversions
Convert App, SymbolModal and WelcomeBox components to JSX.
1 parent 25d1620 commit 139f4ff

8 files changed

Lines changed: 181 additions & 147 deletions

File tree

.eslintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"parserOptions": {
4141
"ecmaVersion": 2016,
4242
"sourceType": "module",
43-
"ecmaFeatures": {}
43+
"ecmaFeatures": { "jsx": true }
4444
},
4545
"env": {
4646
"es6": true,
@@ -61,6 +61,8 @@
6161

6262
// Rules from the React plugin
6363
"react/display-name": [2, { "ignoreTranspilerName": true }],
64+
"react/jsx-uses-react": [2],
65+
"react/jsx-uses-vars": [2],
6466
"react/no-danger": 1,
6567
"react/no-did-mount-set-state": 1,
6668
"react/no-did-update-set-state": 1,

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@
6161
"devtools-source-map": "0.10.0",
6262
"devtools-splitter": "^0.0.3",
6363
"fuzzaldrin-plus": "^0.4.1",
64-
"lodash.kebabcase": "^4.1.1",
6564
"lodash": "^4.17.4",
65+
"lodash.kebabcase": "^4.1.1",
6666
"md5": "^2.2.1",
6767
"parse-script-tags": "^0.1.1",
6868
"pretty-fast": "^0.2.0",
69-
"react-dom": "=15.3.2",
7069
"react": "=15.3.2",
70+
"react-dom": "=15.3.2",
7171
"redux-saga": "^0.15.4",
7272
"reselect": "^3.0.0",
7373
"svg-inline-react": "^1.0.2",
@@ -88,25 +88,27 @@
8888
"devtools-license-check": "^0.4.0",
8989
"documentation": "^4.0.0-beta11",
9090
"enzyme": "^2.9.1",
91+
"eslint": "^4.2.0",
9192
"eslint-config-prettier": "^2.3.0",
9293
"eslint-plugin-prettier": "^2.1.2",
93-
"eslint": "^4.2.0",
94+
"eslint-plugin-react": "^7.1.0",
9495
"expect.js": "^0.3.1",
9596
"flow-bin": "^0.52.0",
9697
"glob": "^7.0.3",
9798
"husky": "^0.14.2",
9899
"jest": "^20.0.1",
99-
"jest-localstorage-mock": "^1.1.1",
100100
"jest-junit-reporter": "^1.0.1",
101+
"jest-localstorage-mock": "^1.1.1",
101102
"jest-serializer-babel-ast": "^0.0.5",
102103
"lint-staged": "^4.0.1",
103-
"npm-run-all": "^4.0.2",
104104
"mocha": "^3.1.2",
105105
"mock-require": "^2.0.2",
106+
"npm-run-all": "^4.0.2",
106107
"prettier": "^1.5.2",
107108
"react-addons-perf": "15.3.2",
108109
"react-addons-test-utils": "=15.3.2",
109110
"remark-cli": "^4.0.0",
111+
"remark-lint": "^6.0.0",
110112
"remark-lint-list-item-bullet-indent": "^1.0.0",
111113
"remark-lint-list-item-indent": "^1.0.0",
112114
"remark-lint-no-shortcut-reference-image": "^1.0.0",
@@ -116,7 +118,6 @@
116118
"remark-lint-ordered-list-marker-style": "^1.0.0",
117119
"remark-lint-table-cell-padding": "^1.0.0",
118120
"remark-lint-table-pipes": "^1.0.0",
119-
"remark-lint": "^6.0.0",
120121
"remark-preset-lint-recommended": "^3.0.0",
121122
"remark-validate-links": "^6.1.0",
122123
"rimraf": "^2.6.1",

src/components/App.js

Lines changed: 92 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
22

3-
import { DOM as dom, PropTypes, Component, createFactory } from "react";
3+
import React, { PropTypes, Component } from "react";
44
import { connect } from "react-redux";
55
import { bindActionCreators } from "redux";
66
import actions from "../actions";
@@ -18,29 +18,21 @@ import "./App.css";
1818
import "./shared/menu.css";
1919
import "./shared/reps.css";
2020

21-
import _SplitBox from "devtools-splitter";
22-
const SplitBox = createFactory(_SplitBox);
21+
import SplitBox from "devtools-splitter";
2322

24-
import _ProjectSearch from "./ProjectSearch";
25-
const ProjectSearch = createFactory(_ProjectSearch);
23+
import ProjectSearch from "./ProjectSearch";
2624

27-
import _PrimaryPanes from "./PrimaryPanes";
28-
const PrimaryPanes = createFactory(_PrimaryPanes);
25+
import PrimaryPanes from "./PrimaryPanes";
2926

30-
import _Editor from "./Editor";
31-
const Editor = createFactory(_Editor);
27+
import Editor from "./Editor";
3228

33-
import _SecondaryPanes from "./SecondaryPanes";
34-
const SecondaryPanes = createFactory(_SecondaryPanes);
29+
import SecondaryPanes from "./SecondaryPanes";
3530

36-
import _WelcomeBox from "./WelcomeBox";
37-
const WelcomeBox = createFactory(_WelcomeBox);
31+
import WelcomeBox from "./WelcomeBox";
3832

39-
import _EditorTabs from "./Editor/Tabs";
40-
const EditorTabs = createFactory(_EditorTabs);
33+
import EditorTabs from "./Editor/Tabs";
4134

42-
import _SymbolModal from "./SymbolModal";
43-
const SymbolModal = createFactory(_SymbolModal);
35+
import SymbolModal from "./SymbolModal";
4436

4537
type Props = {
4638
selectSource: Function,
@@ -97,21 +89,28 @@ class App extends Component {
9789
renderEditorPane() {
9890
const { startPanelCollapsed, endPanelCollapsed } = this.props;
9991
const { horizontal, endPanelSize, startPanelSize } = this.state;
100-
return dom.div(
101-
{ className: "editor-pane" },
102-
dom.div(
103-
{ className: "editor-container" },
104-
EditorTabs({
105-
startPanelCollapsed,
106-
endPanelCollapsed,
107-
horizontal,
108-
endPanelSize,
109-
startPanelSize
110-
}),
111-
Editor({ horizontal, startPanelSize, endPanelSize }),
112-
!this.props.selectedSource ? WelcomeBox({ horizontal }) : null,
113-
ProjectSearch()
114-
)
92+
93+
return (
94+
<div className="editor-pane">
95+
<div className="editor-container">
96+
<EditorTabs
97+
startPanelCollapsed={startPanelCollapsed}
98+
endPanelCollapsed={endPanelCollapsed}
99+
horizontal={horizontal}
100+
startPanelSize={startPanelSize}
101+
endPanelSize={endPanelSize}
102+
/>
103+
<Editor
104+
horizontal={horizontal}
105+
startPanelSize={startPanelSize}
106+
endPanelSize={endPanelSize}
107+
/>
108+
{!this.props.selectedSource
109+
? <WelcomeBox horizontal={horizontal} />
110+
: null}
111+
<ProjectSearch />
112+
</div>
113+
</div>
115114
);
116115
}
117116

@@ -121,66 +120,78 @@ class App extends Component {
121120

122121
const overflowX = endPanelCollapsed ? "hidden" : "auto";
123122

124-
return SplitBox({
125-
style: { width: "100vw" },
126-
initialSize: "250px",
127-
minSize: 10,
128-
maxSize: "50%",
129-
splitterSize: 1,
130-
onResizeEnd: size => this.setState({ startPanelSize: size }),
131-
startPanel: PrimaryPanes({ horizontal }),
132-
startPanelCollapsed,
133-
endPanel: SplitBox({
134-
style: { overflowX },
135-
initialSize: "300px",
136-
minSize: 10,
137-
maxSize: "80%",
138-
splitterSize: 1,
139-
onResizeEnd: size => this.setState({ endPanelSize: size }),
140-
endPanelControl: true,
141-
startPanel: this.renderEditorPane(),
142-
endPanel: SecondaryPanes({ horizontal }),
143-
endPanelCollapsed,
144-
vert: horizontal
145-
})
146-
});
123+
return (
124+
<SplitBox
125+
style={{ width: "100vw" }}
126+
initialSize="250px"
127+
minSize={10}
128+
maxSize="50%"
129+
splitterSize={1}
130+
onResizeEnd={size => this.setState({ startPanelSize: size })}
131+
startPanel={<PrimaryPanes horizontal={horizontal} />}
132+
startPanelCollapsed={startPanelCollapsed}
133+
endPanel={
134+
<SplitBox
135+
style={{ overflowX }}
136+
initialSize="300px"
137+
minSize={10}
138+
maxSize="80%"
139+
splitterSize={1}
140+
onResizeEnd={size => this.setState({ endPanelSize: size })}
141+
endPanelControl={true}
142+
startPanel={this.renderEditorPane()}
143+
endPanel={<SecondaryPanes horizontal={horizontal} />}
144+
endPanelCollapsed={endPanelCollapsed}
145+
vert={horizontal}
146+
/>
147+
}
148+
/>
149+
);
147150
}
148151

149152
renderVerticalLayout() {
150153
const { startPanelCollapsed, endPanelCollapsed } = this.props;
151154
const { horizontal } = this.state;
152155

153-
return SplitBox({
154-
style: { width: "100vw" },
155-
initialSize: "300px",
156-
minSize: 30,
157-
maxSize: "99%",
158-
splitterSize: 1,
159-
vert: horizontal,
160-
startPanel: SplitBox({
161-
style: { width: "100vw" },
162-
initialSize: "250px",
163-
minSize: 10,
164-
maxSize: "40%",
165-
splitterSize: 1,
166-
startPanelCollapsed,
167-
startPanel: PrimaryPanes({ horizontal }),
168-
endPanel: this.renderEditorPane()
169-
}),
170-
endPanel: SecondaryPanes({ horizontal }),
171-
endPanelCollapsed
172-
});
156+
return (
157+
<SplitBox
158+
style={{ width: "100vw" }}
159+
initialSize="300px"
160+
minSize={30}
161+
maxSize="99%"
162+
splitterSize={1}
163+
vert={horizontal}
164+
startPanel={
165+
<SplitBox
166+
style={{ width: "100vw" }}
167+
initialSize="250px"
168+
minSize={10}
169+
maxSize="40%"
170+
splitterSize={1}
171+
startPanelCollapsed={startPanelCollapsed}
172+
startPanel={<PrimaryPanes horizontal={horizontal} />}
173+
endPanel={this.renderEditorPane()}
174+
/>
175+
}
176+
endPanel={<SecondaryPanes horizontal={horizontal} />}
177+
endPanelCollapsed={endPanelCollapsed}
178+
/>
179+
);
173180
}
174181

175182
render() {
176183
const { selectSource, selectedSource } = this.props;
177184

178-
return dom.div(
179-
{ className: "debugger" },
180-
this.state.horizontal
181-
? this.renderHorizontalLayout()
182-
: this.renderVerticalLayout(),
183-
SymbolModal({ selectSource, selectedSource })
185+
return (
186+
<div className="debugger">
187+
{this.state.horizontal
188+
? this.renderHorizontalLayout()
189+
: this.renderVerticalLayout()}
190+
<SymbolModal
191+
selectSource={selectSource}
192+
selectedSource={selectedSource}
193+
/>
194+
</div>
184195
);
185196
}
186197
}

src/components/ProjectSearch/SourceSearch.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ const Autocomplete = createFactory(_Autocomplete);
99
import type { SourcesMap } from "../../reducers/sources";
1010

1111
export default class SourceSearch extends Component {
12+
props: {
13+
closeActiveSearch: () => any,
14+
selectSource: string => any,
15+
sources: Object,
16+
searchBottomBar: Object
17+
};
18+
1219
onEscape: Function;
1320
close: Function;
1421
toggleSourceSearch: Function;
@@ -59,10 +66,10 @@ export default class SourceSearch extends Component {
5966
}
6067

6168
render() {
62-
const { sources, searchBottomBar } = this.props;
69+
const { sources, searchBottomBar, selectSource } = this.props;
6370
return Autocomplete({
6471
selectItem: (e, result) => {
65-
this.props.selectSource(result.id);
72+
selectSource(result.id);
6673
this.close();
6774
},
6875
close: this.close,

0 commit comments

Comments
 (0)