From c65eb4ef19ae07e99ff5c6f172bcd431ba05d6b8 Mon Sep 17 00:00:00 2001 From: Sokovikov Date: Wed, 13 Jul 2016 04:34:52 -0700 Subject: [PATCH] open in editor button for yellow box Summary: Here is the demo https://www.dropbox.com/s/ljh7f9654sqgdqc/demo.mov?dl=0 Closes https://github.com/facebook/react-native/pull/8418 Differential Revision: D3499515 Pulled By: frantic fbshipit-source-id: 1bd4cd79770f1bf1b82723ad803359df177ca3c5 --- Libraries/Inspector/ElementProperties.js | 11 ++------ .../Initialization/openFileInEditor.js | 23 ++++++++++++++++ Libraries/ReactIOS/YellowBox.js | 26 ++++++++++++++----- 3 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 Libraries/JavaScriptAppEngine/Initialization/openFileInEditor.js diff --git a/Libraries/Inspector/ElementProperties.js b/Libraries/Inspector/ElementProperties.js index 9170a62f1..a8e7cb37f 100644 --- a/Libraries/Inspector/ElementProperties.js +++ b/Libraries/Inspector/ElementProperties.js @@ -24,7 +24,7 @@ var {fetch} = require('fetch'); var flattenStyle = require('flattenStyle'); var mapWithSeparator = require('mapWithSeparator'); -var getDevServer = require('getDevServer'); +var openFileInEditor = require('openFileInEditor'); var ElementProperties = React.createClass({ propTypes: { @@ -52,7 +52,7 @@ var ElementProperties = React.createClass({ openFileButton = ( + onPress={openFileInEditor.bind(null, fileName, lineNumber)}> {fileNameShort}:{lineNumber} @@ -95,13 +95,6 @@ var ElementProperties = React.createClass({ ); }, - - _openFile: function(fileName: string, lineNumber: number) { - fetch(getDevServer().url + 'open-stack-frame', { - method: 'POST', - body: JSON.stringify({file: fileName, lineNumber}), - }); - }, }); function getInstanceName(instance) { diff --git a/Libraries/JavaScriptAppEngine/Initialization/openFileInEditor.js b/Libraries/JavaScriptAppEngine/Initialization/openFileInEditor.js new file mode 100644 index 000000000..650cb5683 --- /dev/null +++ b/Libraries/JavaScriptAppEngine/Initialization/openFileInEditor.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule openFileInEditor + * @flow + */ +'use strict'; + +const getDevServer = require('getDevServer'); + +function openFileInEditor(file: string, lineNumber: number) { + fetch(getDevServer().url + 'open-stack-frame', { + method: 'POST', + body: JSON.stringify({file, lineNumber}), + }); +} + +module.exports = openFileInEditor; diff --git a/Libraries/ReactIOS/YellowBox.js b/Libraries/ReactIOS/YellowBox.js index 82507b56f..f9fc498cb 100644 --- a/Libraries/ReactIOS/YellowBox.js +++ b/Libraries/ReactIOS/YellowBox.js @@ -19,6 +19,7 @@ const StyleSheet = require('StyleSheet'); const infoLog = require('infoLog'); const parseErrorStack = require('parseErrorStack'); const symbolicateStackTrace = require('symbolicateStackTrace'); +const openFileInEditor = require('openFileInEditor'); import type EmitterSubscription from 'EmitterSubscription'; import type {StackFrame} from 'parseErrorStack'; @@ -172,12 +173,21 @@ const WarningRow = ({count, warning, onPress}) => { type StackRowProps = { frame: StackFrame }; const StackRow = ({frame}: StackRowProps) => { const Text = require('Text'); - const fileParts = frame.file.split('/'); + const TouchableHighlight = require('TouchableHighlight'); + const {file, lineNumber} = frame; + const fileParts = file.split('/'); const fileName = fileParts[fileParts.length - 1]; + return ( - - {`${fileName}:${frame.lineNumber}`} - + + + {fileName}:{lineNumber} + + ); }; @@ -220,7 +230,7 @@ const WarningInspector = ({ {stacktraceVisible ? 'Hide' : 'Show'} Stacktrace @@ -394,7 +404,7 @@ var styles = StyleSheet.create({ padding: 22, backgroundColor: backgroundColor(1), }, - stacktraceButton: { + toggleStacktraceButton: { flex: 1, padding: 5, }, @@ -411,6 +421,10 @@ var styles = StyleSheet.create({ flex: 1, paddingTop: 5, }, + openInEditorButton: { + paddingTop: 5, + paddingBottom: 5, + }, inspectorCount: { padding: 15, paddingBottom: 0,