-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to React from react-lite #9263
Conversation
Waiting for tests to see remainers. So far verified on my local dev environment, farther testing is needed. Please build with |
if (!this.props.children || this.props.children.length === 0) { | ||
headerClasses = "listing-ct-empty"; | ||
headerRow = <tr><td>{this.props.emptyCaption}</td></tr>; | ||
} else if (this.props.columnTitles.length) { | ||
/* probably not needed, ListingRow.selected prop should be set to 'false' by default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping it here for simpler revert if I'm wrong.
Will be removed later if no issue found.
body: React.PropTypes.element.isRequired, | ||
footer: React.PropTypes.element.isRequired, | ||
id: React.PropTypes.string, | ||
title: PropTypes.string, // required, but show_modal_dialog provides it after initial rendering; TODO: fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to fix the modal dialog in a follow-up.
Maybe by using patternfly-react's component for it but various Cockpit's use cases needs to be considered.
pkg/machines/components/consoles.jsx
Outdated
</Select.StatelessSelect> | ||
</td> | ||
</tr> | ||
<tbody> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React is more strict about element nesting ...
test/verify/check-machines
Outdated
@@ -408,7 +408,7 @@ class TestMachines(MachineCase): | |||
b.wait_present("#slate-header") | |||
b.wait_in_text("#slate-header", "Virtualization Service (libvirt) is Not Active") | |||
b.wait_present("#enable-libvirt:checked") | |||
b.set_checked("#enable-libvirt", False) | |||
b.click("#enable-libvirt") # uncheck it ; ; TODO: fix this, do not assume initial state of the checkbox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer follow-up to fix this.
0cb84e4
to
f3f2694
Compare
Reactifying continues. This time |
Failing |
#9304 is merged, restarting tests |
aeb398c
to
811f96a
Compare
@mareklibra : Thanks for working on this! One hint, if you want to land this faster: A lot, or even most, commits also apply to react-lite, so they could land in a separate PR. This gets easier to review and validate in several smaller steps, and then the actual switch to React can happen separately. |
pkg/docker/containers-view.jsx
Outdated
var Listing = require('cockpit-components-listing.jsx'); | ||
var Select = require('cockpit-components-select.jsx'); | ||
var moment = require('moment'); | ||
|
||
var Dropdown = React.createClass({ | ||
var Dropdown = createReactClass({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already processed as ES6, so this could also just use the normal class .. extends React.Component
syntax, couldn't it? Also, it could use import
instead of var .. require
? Or does that require even more intrusive changes? If so, then fine to do this intermediate step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this PR is about to be split into smaller ones now, we can afford this kind of refactoring.
Originally I skipped that to ease review.
I hope I'm not wrong, but I expect just syntax changes with this replacement.
This task became much bigger than originally expected. This will help. |
React does this automatically in a high-performance way, so this call is not needed in this context.
PropTypes were moved to separate npm package 'prop-types' from core 'React'. This patch is part of "react-lite to React" series. So far, the PropTypes where just declared but not actually used. Bunch of inconsistencies are expected, fixes will follow in next patches.
The `React.createClass` has been removed from React. For legacy code, there's `create-react-class` npm package.
The react-lite library keeps compatibility with React 15.x which is slowly deprecating. Various Cockpit's npm dependencies are starting to require React 16 features, namely i.e. patternfly-react. Closes cockpit-project#9263
- More "key" properties - A <tbody> for each <table> - Don't bind methods
React wont allow it; setting the "value" attribute will not be reflected in the "value" property for arbitrary divs. So we make this more explicit by using a custom attribute.
Use Browser.set_input_text as appropriate.
Pushed a rebase to fix the current conflicts. |
I'm at an impasse with the console crash. This is known issue #9641 again, it just crashes a lot harder now. @patternfly/react-console 1.4.2 contains the fix, but it also pulls in @novnc/novnc, and that causes an error:
here in the generated machines.js webpack:
|
This fixes the pesky crash at last. This pulls in @novnc/novnc, which uses ES6 syntax in its *.js files. This leads to runtime errors like SyntaxError: export declarations may only appear at top level of a module as these are embedded in webpacks. Until we update to a less ancient weback, fix these by applying babel on the novnc sources.
I bent the new PF-reactconsole to my will, and it's behaving correctly now. Yay for that crash being gone at last! |
- Added "key" properties and "tbody" elements as necessary - "Listing" wants an array of actions - The "event" structure given to a handler is only valid while the handler runs
I can not reproduce this anymore. :-/ |
- "key" properties and "tbody" elements as necessary - Form elements must be re-rendered on every change - use StatelessSelect as required by the re-rendering - Use Browser.set_input_text instead of set_val
0e8fcba
to
3d3adde
Compare
- Use strings for "key" properties. - Construct a new dialog body when values change, a render() call is not enough. - Plumb "startVm" thtough the state as well to ensure re-rendering. - Be sure to set text input values always to a string (and not "undefined") so that React will always treat them as controlled components. - Use "className" instead of "extraClass", which is not a thing. The additional class doesn't seem to have any effect, though.
- Pass a empty values for required properties instead of "undefined".
Whee, all green and all TODOs done 🎉 Nice job everyone! |
The react-lite library keeps compatibility with React 15.x which is slowly deprecating. Various Cockpit's npm dependencies are starting to require React 16 features, namely i.e. patternfly-react. Closes #9263
The react-lite library keeps compatibility with React 15.x which is slowly deprecating. Various Cockpit's npm dependencies are starting to require React 16 features, namely i.e. patternfly-react. Closes cockpit-project#9263
The
react-lite
is slowly becoming obsolete compared to the recentreact
version 16.4 andthere are recently no plans to add support of
v16
features to thereact-lite
[1].Fixes to various so far found issues are provided.
One of the first benefits of this change is alignment of Cockpit with requirements of
paternfly-react
library.Some of the issues related to React
15 -> 16
upgrade can be found in [2] .To use development version of React:
[1] Lucifier129/react-lite#126
[2] https://reactjs.org/blog/2017/09/26/react-v16.0.html
List of follow-ups:
cockpit-components-listing.jsx
show_modal_dialog
check-{machines|ovir}
- provide infra for setting checkbox valuepkg/storage
- refactor component hierarchy ofLogsPanel
andcontent-views.jsx:block_rows()
test/check-*
- provide infra for setting form fields rendered by React - text input, checkbox, etc.PR split - following will be removed from here and merged separately:
key
to generated React children - PR cockpit-components-listing: React-related fixes #9340key
to generated React component list - added to PR apps: React-related fixes #9344Manual UI click arounds
Issues found so far
TypeError: this.state.terminal.renderer is undefined
(Oops happens with current master too, but at least the terminal appears)