Closed
Bug 1314931
Opened 9 years ago
Closed 9 years ago
LayoutView should be browserRequire as the root component
Categories
(DevTools :: Inspector, defect, P3)
DevTools
Inspector
Tracking
(firefox52 verified)
RESOLVED
FIXED
Firefox 52
Tracking | Status | |
---|---|---|
firefox52 | --- | verified |
People
(Reporter: gl, Assigned: gl)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 1 obsolete file)
5.13 KB,
patch
|
Honza
:
review+
|
Details | Diff | Splinter Review |
We should use browserRequire to only load the root component in the Layout View. In this case, the LayoutViewTool should browserRequire CssLayoutView component. The root component can consequently load the entire tree of component using the standard require, and help with consuming any webpack bundles in the Layout View.
Assignee | ||
Comment 1•9 years ago
|
||
Attachment #8807139 -
Flags: review?(odvarko)
Assignee | ||
Comment 2•9 years ago
|
||
Comment 3•9 years ago
|
||
Comment on attachment 8807139 [details] [diff] [review]
1314931.patch [1.0]
Review of attachment 8807139 [details] [diff] [review]:
-----------------------------------------------------------------
What is actually the main purpose of LayoutViewTool and CssLayoutView objects?
The existing side-panels are using similar structure, but it's there mainly because there are not yet converted to React. In case a new side-panel that is fully implemented on top of React (like yours) those objects seem to be redundant. Unless I am missing something.
If the whole point of these objects is to just render content of the side panel using React component than I think we could use the following and simpler construct (in inspector.js, or in layout/main.js as a single exported function):
var MyTabPanel = React.createClass({
render: function () {
return (
div({className: "tab-panel"},
"Hello From Side Panel!"
)
);
}
});
var myTabPanel = React.createFactory(MyTabPanel);
inspector.addSidebarTab(
"my-tab-panel", // ID
"My Tab", // Title
myTabPanel, // A component rendering panel's content
false // not selected by default
);
You can also see this simple add-on example that appends a new side-panel to the Inspector panel.
https://github.com/janodvarko/prototypes/blob/master/inspector-sidebar/index.js
Honza
Attachment #8807139 -
Flags: review?(odvarko)
Assignee | ||
Updated•9 years ago
|
Summary: LayoutViewTool should browserRequire the root CssLayoutView component → LayoutView should be browserRequire as the root component
Assignee | ||
Comment 4•9 years ago
|
||
I have removed the concepts of LayoutViewTool and CssLayoutView here. Originally, we had main.js (LayoutViewTool) which basically did the browserRequire of the root component, but we can simply browserRequire from inspector.js. I renamed CssLayoutView to LayoutView which is still needed to initialize the react/redux app.
Attachment #8807139 -
Attachment is obsolete: true
Attachment #8807165 -
Flags: review?(odvarko)
Comment 5•9 years ago
|
||
Comment on attachment 8807165 [details] [diff] [review]
1314931.patch [2.0]
Review of attachment 8807165 [details] [diff] [review]:
-----------------------------------------------------------------
Yes, this is step in the right direction and I am thinking to move it yet one step further. I am specifically thinking about removing the explicit `ReactDOM.render` call. Rendering of the panel content should be responsibility of the Sidebar component (it should render its children automatically). Note that in regular React app, there is just one `ReactDOM.render` call - the one that renders the root component and we should go towards it.
So, what about rename the layout.js to main.js and export just a single function. This function would create the root component and append it directly into the sidebar.
exports.addSidebarTab = (inspector, defaultTab) => {
let store = Store();
let provider = createElement(Provider, {
store,
id: "layoutview",
title: INSPECTOR_L10N.getStr("inspector.sidebar.layoutViewTitle"),
key: "layoutview",
}, App());
inspector.addSidebarTab(
null,
null,
provider,
defaultTab == "layoutview
);
}
The inspector.js would call that function as follows:
if (Services.prefs.getBoolPref("devtools.layoutview.enabled")) {
const {addSidebarTab} = this.browserRequire("devtools/client/inspector/layout/main");
addSidebarTab(this, defaultTab);
}
Comments:
- I am not sure if 'addSidebarTab' is the best name for the function, you might find better name (e.g. registerLayoutPanel, etc.)
- You can remove the helper node in inspector.xul
- In case the `addSidebarTab` is actually part of inspector.js (a method of Inspector object) you shouldn't need to modify the BROWSER_BASED_DIRS and you don't need the main.js at all.
- Finally, we might want to improve the API and avoid the two 'null' arguments. At least we could introduce the following method in Inspector object:
addSidebarComponent: function (component, selected) {
this.sidebar.addTab(undefined, undefined, component, selected);
}
... but this might be a follow up.
What do you think?
Honza
Attachment #8807165 -
Flags: review?(odvarko)
Assignee | ||
Comment 6•9 years ago
|
||
(In reply to Jan Honza Odvarko [:Honza] from comment #5)
> Comment on attachment 8807165 [details] [diff] [review]
> 1314931.patch [2.0]
>
> Review of attachment 8807165 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Yes, this is step in the right direction and I am thinking to move it yet
> one step further. I am specifically thinking about removing the explicit
> `ReactDOM.render` call. Rendering of the panel content should be
> responsibility of the Sidebar component (it should render its children
> automatically). Note that in regular React app, there is just one
> `ReactDOM.render` call - the one that renders the root component and we
> should go towards it.
>
> So, what about rename the layout.js to main.js and export just a single
> function. This function would create the root component and append it
> directly into the sidebar.
>
> exports.addSidebarTab = (inspector, defaultTab) => {
> let store = Store();
> let provider = createElement(Provider, {
> store,
> id: "layoutview",
> title: INSPECTOR_L10N.getStr("inspector.sidebar.layoutViewTitle"),
> key: "layoutview",
> }, App());
>
> inspector.addSidebarTab(
> null,
> null,
> provider,
> defaultTab == "layoutview
> );
> }
>
> The inspector.js would call that function as follows:
>
> if (Services.prefs.getBoolPref("devtools.layoutview.enabled")) {
> const {addSidebarTab} =
> this.browserRequire("devtools/client/inspector/layout/main");
> addSidebarTab(this, defaultTab);
> }
>
> Comments:
> - I am not sure if 'addSidebarTab' is the best name for the function, you
> might find better name (e.g. registerLayoutPanel, etc.)
> - You can remove the helper node in inspector.xul
> - In case the `addSidebarTab` is actually part of inspector.js (a method of
> Inspector object) you shouldn't need to modify the BROWSER_BASED_DIRS and
> you don't need the main.js at all.
> - Finally, we might want to improve the API and avoid the two 'null'
> arguments. At least we could introduce the following method in Inspector
> object:
>
> addSidebarComponent: function (component, selected) {
> this.sidebar.addTab(undefined, undefined, component, selected);
> }
>
> ... but this might be a follow up.
>
>
> What do you think?
>
> Honza
Honza, let's move this to a separate bug in the future. I want to see the LayoutView mature a little bit after implementing some non-trivial features to see what the code looks like. I am sure similar to the rule and computed view we will listen to various inspector selection events and dispatch events to update the layout state. I think we will have a better idea of how to refactor out some pieces afterwards.
Assignee | ||
Updated•9 years ago
|
Attachment #8807165 -
Flags: review?(odvarko)
Comment 7•9 years ago
|
||
Comment on attachment 8807165 [details] [diff] [review]
1314931.patch [2.0]
Review of attachment 8807165 [details] [diff] [review]:
-----------------------------------------------------------------
(In reply to Gabriel Luong [:gl][1 biz day review guarantee] (ΦωΦ) from comment #6)
> Honza, let's move this to a separate bug in the future. I want to see the
> LayoutView mature a little bit after implementing some non-trivial features
> to see what the code looks like. I am sure similar to the rule and computed
> view we will listen to various inspector selection events and dispatch
> events to update the layout state. I think we will have a better idea of how
> to refactor out some pieces afterwards.
OK, doing this in a follow up is fine. Note that the important thing for me is that we get rid of the explicit `ReactDOM.render` call.
R+ assuming there is a follow-up report filed.
Thanks you!
Honza
Attachment #8807165 -
Flags: review?(odvarko) → review+
Assignee | ||
Comment 8•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/3d032c10f6cc6d16ee04533ea7a218bf1ec4491d
Bug 1314931 - LayoutView should be browserRequire as the root component r=Honza
Comment 9•9 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox52:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 52
Updated•7 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•