Skip to content

Commit c65eb4e

Browse files
skv-headlessFacebook Github Bot
authored andcommitted
open in editor button for yellow box
Summary: Here is the demo https://www.dropbox.com/s/ljh7f9654sqgdqc/demo.mov?dl=0 Closes facebook#8418 Differential Revision: D3499515 Pulled By: frantic fbshipit-source-id: 1bd4cd79770f1bf1b82723ad803359df177ca3c5
1 parent 91ff686 commit c65eb4e

File tree

3 files changed

+45
-15
lines changed

3 files changed

+45
-15
lines changed

Libraries/Inspector/ElementProperties.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var {fetch} = require('fetch');
2424

2525
var flattenStyle = require('flattenStyle');
2626
var mapWithSeparator = require('mapWithSeparator');
27-
var getDevServer = require('getDevServer');
27+
var openFileInEditor = require('openFileInEditor');
2828

2929
var ElementProperties = React.createClass({
3030
propTypes: {
@@ -52,7 +52,7 @@ var ElementProperties = React.createClass({
5252
openFileButton = (
5353
<TouchableHighlight
5454
style={styles.openButton}
55-
onPress={this._openFile.bind(null, fileName, lineNumber)}>
55+
onPress={openFileInEditor.bind(null, fileName, lineNumber)}>
5656
<Text style={styles.openButtonTitle} numberOfLines={1}>
5757
{fileNameShort}:{lineNumber}
5858
</Text>
@@ -95,13 +95,6 @@ var ElementProperties = React.createClass({
9595
</TouchableWithoutFeedback>
9696
);
9797
},
98-
99-
_openFile: function(fileName: string, lineNumber: number) {
100-
fetch(getDevServer().url + 'open-stack-frame', {
101-
method: 'POST',
102-
body: JSON.stringify({file: fileName, lineNumber}),
103-
});
104-
},
10598
});
10699

107100
function getInstanceName(instance) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @providesModule openFileInEditor
10+
* @flow
11+
*/
12+
'use strict';
13+
14+
const getDevServer = require('getDevServer');
15+
16+
function openFileInEditor(file: string, lineNumber: number) {
17+
fetch(getDevServer().url + 'open-stack-frame', {
18+
method: 'POST',
19+
body: JSON.stringify({file, lineNumber}),
20+
});
21+
}
22+
23+
module.exports = openFileInEditor;

Libraries/ReactIOS/YellowBox.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const StyleSheet = require('StyleSheet');
1919
const infoLog = require('infoLog');
2020
const parseErrorStack = require('parseErrorStack');
2121
const symbolicateStackTrace = require('symbolicateStackTrace');
22+
const openFileInEditor = require('openFileInEditor');
2223

2324
import type EmitterSubscription from 'EmitterSubscription';
2425
import type {StackFrame} from 'parseErrorStack';
@@ -172,12 +173,21 @@ const WarningRow = ({count, warning, onPress}) => {
172173
type StackRowProps = { frame: StackFrame };
173174
const StackRow = ({frame}: StackRowProps) => {
174175
const Text = require('Text');
175-
const fileParts = frame.file.split('/');
176+
const TouchableHighlight = require('TouchableHighlight');
177+
const {file, lineNumber} = frame;
178+
const fileParts = file.split('/');
176179
const fileName = fileParts[fileParts.length - 1];
180+
177181
return (
178-
<Text style={styles.inspectorCountText}>
179-
{`${fileName}:${frame.lineNumber}`}
180-
</Text>
182+
<TouchableHighlight
183+
activeOpacity={0.5}
184+
style={styles.openInEditorButton}
185+
underlayColor="transparent"
186+
onPress={openFileInEditor.bind(null, file, lineNumber)}>
187+
<Text style={styles.inspectorCountText}>
188+
{fileName}:{lineNumber}
189+
</Text>
190+
</TouchableHighlight>
181191
);
182192
};
183193

@@ -220,7 +230,7 @@ const WarningInspector = ({
220230
<TouchableHighlight
221231
activeOpacity={0.5}
222232
onPress={toggleStacktrace}
223-
style={styles.stacktraceButton}
233+
style={styles.toggleStacktraceButton}
224234
underlayColor="transparent">
225235
<Text style={styles.inspectorButtonText}>
226236
{stacktraceVisible ? 'Hide' : 'Show'} Stacktrace
@@ -394,7 +404,7 @@ var styles = StyleSheet.create({
394404
padding: 22,
395405
backgroundColor: backgroundColor(1),
396406
},
397-
stacktraceButton: {
407+
toggleStacktraceButton: {
398408
flex: 1,
399409
padding: 5,
400410
},
@@ -411,6 +421,10 @@ var styles = StyleSheet.create({
411421
flex: 1,
412422
paddingTop: 5,
413423
},
424+
openInEditorButton: {
425+
paddingTop: 5,
426+
paddingBottom: 5,
427+
},
414428
inspectorCount: {
415429
padding: 15,
416430
paddingBottom: 0,

0 commit comments

Comments
 (0)