Closed
Bug 1409064
Opened 7 years ago
Closed 7 years ago
Network Monitor needs to use ES6 classes so that we can switch it over to PureComponent
Categories
(DevTools :: Netmonitor, enhancement, P2)
DevTools
Netmonitor
Tracking
(firefox57 fix-optional, firefox58 fixed)
RESOLVED
FIXED
Firefox 58
Tracking | Status | |
---|---|---|
firefox57 | --- | fix-optional |
firefox58 | --- | fixed |
People
(Reporter: miker, Assigned: miker)
References
Details
Attachments
(1 file, 1 obsolete file)
jlast pointed me at https://github.com/reactjs/react-codemod that can help automate these changes.
Updated•7 years ago
|
status-firefox57:
--- → fix-optional
Assignee | ||
Comment 1•7 years ago
|
||
The codemod jlast pointed me at uses ES6 class arrow functions, static properties and a bunch of other features that are currently only supported by babel.
I have made significant changes to the AST to get it working with our code base but I think it is fine... at least, after converting the Network Monitor it still seems to work fine.
Assignee | ||
Comment 2•7 years ago
|
||
Comment hidden (mozreview-request) |
Assignee | ||
Comment 4•7 years ago
|
||
try is green so asked Honza for review.
Comment 5•7 years ago
|
||
@Mike: The patch needs to be rebased.
unable to find 'devtools/client/netmonitor/src/components/headers-panel.js' for patching
4 out of 4 hunks FAILED -- saving rejects to file devtools/client/netmonitor/src/components/headers-panel.js.rej
unable to find 'devtools/client/netmonitor/src/components/monitor-panel.js' for patching
4 out of 4 hunks FAILED -- saving rejects to file devtools/client/netmonitor/src/components/monitor-panel.js.rej
unable to find 'devtools/client/netmonitor/src/components/properties-view.js' for patching
5 out of 5 hunks FAILED -- saving rejects to file devtools/client/netmonitor/src/components/properties-view.js.rej
unable to find 'devtools/client/netmonitor/src/components/request-list-column-cause.js' for patching
2 out of 2 hunks FAILED -- saving rejects to file devtools/client/netmonitor/src/components/request-list-column-cause.js.rej
unable to find 'devtools/client/netmonitor/src/components/request-list-column-content-size.js' for patching
etc..
The file-names changed. E.g. headers-panel.js => HeadersPanel.js
(to follow CamelCase standard for React component files)
Honza
Assignee | ||
Comment 6•7 years ago
|
||
No problem... the network panel was converted in less than 10 seconds so I can recreate the patch any time.
Comment 7•7 years ago
|
||
mozreview-review |
Comment on attachment 8920156 [details]
Bug 1409064 - Network Monitor swith to ES6 classes
https://reviewboard.mozilla.org/r/191124/#review197108
::: devtools/client/netmonitor/src/components/headers-panel.js:276
(Diff revision 1)
> )
> );
> }
> -});
> +}
> +
> +HeadersPanel.displayName = "HeadersPanel";
displayName is useless after converting to ES6 Classes. Please remove it.
https://reactjs.org/docs/react-component.html#displayname
::: devtools/client/netmonitor/src/components/headers-panel.js:278
(Diff revision 1)
> }
> -});
> +}
> +
> +HeadersPanel.displayName = "HeadersPanel";
> +
> +HeadersPanel.propTypes = {
Can we move propType into Component and use static prop instead?
class HeadersPanel extends Component {
static defaultProp = {
...
};
static propTypes = {
...
};
}
Plus, we can also define `state` out of constructor like this:
class HeadersPanel extends Component {
state = {
...
};
}
Assignee | ||
Comment 8•7 years ago
|
||
mozreview-review-reply |
Comment on attachment 8920156 [details]
Bug 1409064 - Network Monitor swith to ES6 classes
https://reviewboard.mozilla.org/r/191124/#review197108
> displayName is useless after converting to ES6 Classes. Please remove it.
>
> https://reactjs.org/docs/react-component.html#displayname
It isn't needed when using createClass() either.
We can't remove it without the team agreeing that we will no longer use it so I have created an RFC:
https://github.com/devtools-html/rfcs/issues/25
> Can we move propType into Component and use static prop instead?
>
>
> class HeadersPanel extends Component {
> static defaultProp = {
> ...
> };
>
> static propTypes = {
> ...
> };
> }
>
> Plus, we can also define `state` out of constructor like this:
>
> class HeadersPanel extends Component {
> state = {
> ...
> };
> }
> Can we move propType into Component and use static prop instead?
>
> class HeadersPanel extends Component {
> static defaultProp = {
> ...
> };
>
> static propTypes = {
> ...
> };
> }
No, the majority of our code is not transpiled and class properties are not part of ES7. From what I understand, this is because static getters are supported.
I have changed the AST transformer to use static getters instead.
> Plus, we can also define state out of constructor like this:
>
> class HeadersPanel extends Component {
> state = {
> ...
> };
> }
Again, class properties are not part of ES7 so we can't do that.
Comment hidden (mozreview-request) |
Assignee | ||
Updated•7 years ago
|
Attachment #8920156 -
Attachment is obsolete: true
Attachment #8920156 -
Flags: review?(odvarko)
Comment 10•7 years ago
|
||
mozreview-review |
Comment on attachment 8921435 [details]
Bug 1409064 - Network Monitor to ES6 classes
https://reviewboard.mozilla.org/r/192464/#review198082
I like the patch, thanks Mike!
R+ assuming try is green.
Honza
Attachment #8921435 -
Flags: review?(odvarko) → review+
Comment 11•7 years ago
|
||
Pushed by mratcliffe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5a6a0703724e
Network Monitor to ES6 classes r=Honza
Comment 12•7 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox58:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 58
Assignee | ||
Updated•7 years ago
|
Updated•7 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•