From 4a02041fa148f38e7a817c3bb676b6399eaff39e Mon Sep 17 00:00:00 2001 From: Dimple Jethani Date: Wed, 7 Nov 2018 12:43:48 -0800 Subject: [PATCH] adding tree structure to layout inspector for NT subsection Summary: Added JSON parsing to make tree structure for NT subsection in layout inspector Reviewed By: danielbuechele Differential Revision: D12938117 fbshipit-source-id: 43967d2e970ff2ce7e9b2e05a99d58a95a71b650 --- .../components/elements-inspector/sidebar.js | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/ui/components/elements-inspector/sidebar.js b/src/ui/components/elements-inspector/sidebar.js index eab4a8f46..55c4ea757 100644 --- a/src/ui/components/elements-inspector/sidebar.js +++ b/src/ui/components/elements-inspector/sidebar.js @@ -131,15 +131,39 @@ export class InspectorSidebar extends Component { []; for (const key in element.data) { - sections.push( - , - ); + if (key === 'Extra Sections') { + for (const extraSection in element.data[key]) { + let data = element.data[key][extraSection]; + + // data might be sent as stringified JSON, we want to parse it for a nicer persentation. + if (typeof data === 'string') { + try { + data = JSON.parse(data); + } catch (e) { + // data was not a valid JSON, using string instead + } + } + sections.push( + , + ); + } + } else { + sections.push( + , + ); + } } if (GK.get('sonar_show_console_plugin') && this.state.isConsoleEnabled) {