From 44f561a683b8139cf92176b7d450dc68e29e6e29 Mon Sep 17 00:00:00 2001 From: Hilal Alsibai Date: Tue, 3 Jul 2018 16:25:25 -0700 Subject: [PATCH] Add ability to dynamically extend the layout inspector sidebar Summary: This adds the ability to extend the layout inspector's sidebar via SidebarExtensions Reviewed By: sjkirby Differential Revision: D8677332 fbshipit-source-id: 1880d5d2185306290a278e8a48e965ad94b98cc0 --- src/fb-stubs/LayoutInspectorSidebarExtensions.js | 7 +++++++ src/ui/components/elements-inspector/sidebar.js | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/fb-stubs/LayoutInspectorSidebarExtensions.js diff --git a/src/fb-stubs/LayoutInspectorSidebarExtensions.js b/src/fb-stubs/LayoutInspectorSidebarExtensions.js new file mode 100644 index 000000000..1bbba7a49 --- /dev/null +++ b/src/fb-stubs/LayoutInspectorSidebarExtensions.js @@ -0,0 +1,7 @@ +/** + * Copyright 2018-present Facebook. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * @format + */ +export default []; diff --git a/src/ui/components/elements-inspector/sidebar.js b/src/ui/components/elements-inspector/sidebar.js index f6fc618c5..d39e1e307 100644 --- a/src/ui/components/elements-inspector/sidebar.js +++ b/src/ui/components/elements-inspector/sidebar.js @@ -12,6 +12,7 @@ import ManagedDataInspector from '../data-inspector/ManagedDataInspector.js'; import {Component} from 'react'; import {Console} from '../console'; import {GK} from 'sonar'; +import SidebarExtensions from '../../../fb-stubs/LayoutInspectorSidebarExtensions.js'; const deepEqual = require('deep-equal'); @@ -109,7 +110,10 @@ export class InspectorSidebar extends Component { return null; } - const sections = []; + const sections = SidebarExtensions.map(ext => + ext(this.props.client, element.id), + ); + for (const key in element.data) { sections.push(