Skip to content
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

Migrate away from reactCreateClass #955

Merged
merged 6 commits into from
Jan 18, 2019
Merged

Migrate away from reactCreateClass #955

merged 6 commits into from
Jan 18, 2019

Conversation

wincent
Copy link
Contributor

@wincent wincent commented Jan 16, 2019

For: https://issues.liferay.com/browse/IFI-409

This PR ports us away from the four places where we're using createReactClass.

@wincent wincent changed the title Create class kill Migrate away from reactCreateClass Jan 16, 2019
@wincent
Copy link
Contributor Author

wincent commented Jan 17, 2019

@julien: this one is ready for review now.

I'm working on https://issues.liferay.com/browse/IFI-409 and wasn't
entirely confident that the Karma tests exercising the related
components were actually running. Switching to the
karma-verbose-reporter enables you to see what tests are being executed:

https://gist.github.com/wincent/55910d693db6d3d72b171406460398de

For example, here I can see the richcombo-bridge.jsx tests
(corresponding to the first component that I'm porting) running:

```
 - RichComboBridge :
   * should create a rich combo and invoke its initialization methods : ok
   * should render just the menu button when not expanded : ok
   * should show a dropdown with the action buttons when expanded : 2 skipped
   * should execute the onClick method with the item value when clicking on an item : skipped
```
Test run output (same before and after):

```
 - MenuButtonBridge :
   * should create a menu button : ok
   * should render just the menuButton button when not expanded : ok
   * should show a dropdown with the menu items that have a valid group when expanded : skipped
   * should execute the onClick or command methods of the menu items when clicked : skipped
```

Sorry for the whitespace changes in this diff; my editor applied a lot
of these automatically. To see the change without whitespace, look at
the diff with the `-b` switch to `git`.

Related: https://issues.liferay.com/browse/IFI-409
Test output:

```
 - ButtonBridge :
   * should name buttons based on their input params : ok
   * should create a button with a command in its definition : ok
   * should create a button with an onClick handler in its definition : ok
   * should prevent button definitions from overriding existing buttons : ok
   * should render the button icon with css class or style if it exists in ckeditor : ok
```

Just like the previous commit. Only difference is the `_handleClick`
callback needs to access `this` but it is not autobound by default, so
turn it into an arrow function member on the instance.

Related: https://issues.liferay.com/browse/IFI-409
This is much like the preceding commits in this PR, but not we had to
move the `getInitialState()` logic into the constructor to avoid this
warning:

```
Warning: getInitialState was defined on %s, a plain JavaScript
class. This is only supported for classes created using
React.createClass. Did you mean to define a state property instead?
```

Test output:

```
 - RichComboBridge :
   * should create a rich combo and invoke its initialization methods : ok
   * should render just the menu button when not expanded : ok
   * should show a dropdown with the action buttons when expanded : 2 skipped
   * should execute the onClick method with the item value when clicking on an item : skipped
```

Related: https://issues.liferay.com/browse/IFI-409
Test output:

```
 - PanelMenuButtonBridge :
   * should create a panel menu button : ok
   * should render just the menu button when not expanded : ok
   * should show a dropdown with the panel css class and panel contents when expanded : skipped
```

Related: https://issues.liferay.com/browse/IFI-409
@wincent
Copy link
Contributor Author

wincent commented Jan 18, 2019

Rebased on top of current "2.x-develop".

@wincent wincent merged commit 95cb446 into liferay:2.x-develop Jan 18, 2019
@wincent wincent deleted the create-class-kill branch January 24, 2019 14:28
@wincent wincent mentioned this pull request Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant