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 ra-ui-materialui to TypeScript (Part 1: auth) #2984

Merged
merged 6 commits into from
Apr 17, 2019

Conversation

djhi
Copy link
Contributor

@djhi djhi commented Mar 10, 2019

No description provided.

@Kmaschta
Copy link
Contributor

pray

@fzaninotto
Copy link
Member

The perimeter of this PR is ambitious - I'd prefer that you split the migration to avoid a large code review. As is, the perimeter of this PR is good enough - just get it working!

Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the first half. I really think you should try to change the code as little as possible to make the review easier. I see changes (like removal of rest props sanitization) that have nothing to see with a TypeScript migration.

packages/ra-ui-materialui/src/auth/Login.tsx Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/auth/Login.tsx Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/auth/Login.tsx Show resolved Hide resolved
@@ -85,16 +79,12 @@ class Login extends Component {
// the componentDidMount, but if the ref doesn't exist, it will try again
// on the following componentDidUpdate. The try will be done only once.
// @see https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element
updateBackgroundImage = (lastTry = false) => {
updateBackgroundImage = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove the lastTry? See the comment above the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, because this code does not work at all, read the original carefully and look where we were passing lastTry. Second because TypeScript agrees with me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then you should remove the comment above the method, too

packages/ra-ui-materialui/src/auth/Login.tsx Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/auth/Logout.tsx Show resolved Hide resolved
packages/ra-ui-materialui/src/auth/Logout.tsx Show resolved Hide resolved
packages/ra-ui-materialui/src/auth/Logout.tsx Show resolved Hide resolved
packages/ra-ui-materialui/src/auth/Logout.tsx Show resolved Hide resolved
packages/ra-ui-materialui/src/button/BulkDeleteButton.tsx Outdated Show resolved Hide resolved
@djhi djhi changed the title Migrate ra-ui-materialui to TypeScript Migrate ra-ui-materialui to TypeScript (Part 1: auth) Mar 27, 2019
@djhi djhi marked this pull request as ready for review March 27, 2019 15:33
backgroundColor: theme.palette.secondary[500],
},
});
interface Props extends HtmlHTMLAttributes<HTMLDivElement> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not extend from HtmlHTMLAttributes, but use an union type in the component definition:

class LoginView extends Component<Props & WithStyles<typeof styles> & HtmlHTMLAttributes<HTMLDivElement>>

I think having the Props type extending nothing makes the intent of the component clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not

@@ -85,16 +79,12 @@ class Login extends Component {
// the componentDidMount, but if the ref doesn't exist, it will try again
// on the following componentDidUpdate. The try will be done only once.
// @see https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element
updateBackgroundImage = (lastTry = false) => {
updateBackgroundImage = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then you should remove the comment above the method, too

className,
loginForm,
staticContext,
...rest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the props that were in sanitizeRestProps are missing here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because they were unnecessary. I checked

@@ -39,7 +61,12 @@ const renderInput = ({
const login = (auth, dispatch, { redirectTo }) =>
dispatch(userLogin(auth, redirectTo));

const LoginForm = ({ classes, isLoading, handleSubmit, translate }) => (
const LoginFormView: SFC<Props & EnhancedProps> = ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think SFC is deprecated in favor of FunctionalComponent

@fzaninotto fzaninotto merged commit 089bae3 into master Apr 17, 2019
@fzaninotto fzaninotto deleted the typescript-migration-mui branch April 17, 2019 09:19
@fzaninotto fzaninotto added this to the 2.8.6 milestone Apr 17, 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.

None yet

3 participants