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

Update MUI v4 #793

Merged
merged 5 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@
"stylint": "2.0.0"
},
"dependencies": {
"@material-ui/core": "3.9.4",
"@material-ui/core": "4",
"@testing-library/react": "10.4.9",
"classnames": "2.2.6",
"cozy-bar": "7.16.0",
"cozy-client": "16.17.0",
"cozy-doctypes": "1.75.1",
"cozy-flags": "1.10.0",
"cozy-logger": "1.6.0",
"cozy-ui": "44.2.0",
"cozy-ui": "45.0.0-beta.4",
"cozy-vcard": "0.2.18",
"final-form": "4.10.0",
"final-form-arrays": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/ContactCard/ContactForm/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('ContactForm', () => {
}

Object.keys(fields).forEach(fieldName => {
const candidates = form.find(`TextField[name='${fieldName}']`)
const candidates = form.find(`ForwardRef(TextField)[name='${fieldName}']`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Mouais, OK, mais je pense qu'il faut plutot utiliser @testing-library/react dans ces cas là. C'est pas l'objet de la PR en soi, donc OK.

Copy link
Contributor Author

@JF-Cozy JF-Cozy Feb 17, 2021

Choose a reason for hiding this comment

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

Ok je fais une issue pour ne pas l'oublier : #795

const field = candidates.length === 1 ? candidates : candidates.first()
field.props().onChange({ target: { value: fields[fieldName] } })
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ Array [
className="u-mb-half u-breakword"
>
<p
className="MuiTypography-root-1 MuiTypography-body1-10"
className="MuiTypography-root MuiTypography-body1"
>
Google
</p>
<span
className="MuiTypography-root-1 MuiTypography-caption-11 MuiTypography-colorTextSecondary-34"
className="MuiTypography-root MuiTypography-caption MuiTypography-colorTextSecondary"
>
[email protected]
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ContactsList/Contacts/ContactIdentity.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ContactIdentity = ({ contact }) => {
const isMyself = contact.metadata ? !!contact.metadata.me : false

return (
<TableCell className="contact-identity u-ellipsis">
<TableCell className="contact-identity u-flex u-flex-items-center u-ellipsis">
<Avatar text={getInitials(contact)} size="small" />
<ContactName displayName={displayName} familyName={name.familyName} />
{isMyself && <MyselfMarker />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`ContactListItem should match the contact snapshot 1`] = `
<li
className="MuiListItem-root-1 MuiListItem-default-4 MuiListItem-gutters-9 u-c-pointer"
className="MuiListItem-root u-c-pointer MuiListItem-gutters"
data-testid="contact-listItem"
disabled={false}
onClick={[Function]}
Expand All @@ -23,7 +23,7 @@ exports[`ContactListItem should match the contact snapshot 1`] = `
</span>
</div>
<div
className="styles__TableCell___yJCq7 contact-identity u-ellipsis"
className="styles__TableCell___yJCq7 contact-identity u-flex u-flex-items-center u-ellipsis"
>
<div
className="styles__c-avatar___PpDI- styles__c-avatar--text___2dvna"
Expand All @@ -42,7 +42,8 @@ exports[`ContactListItem should match the contact snapshot 1`] = `
</span>
</div>
<p
className="MuiTypography-root-13 MuiTypography-body1-22 MuiTypography-noWrap-39 MuiTypography-gutterBottom-40 MuiTypography-inline-48 u-ml-1"
className="MuiTypography-root u-ml-1 MuiTypography-body1 MuiTypography-noWrap MuiTypography-gutterBottom"
inline={true}
>
<span
className=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,12 @@ Array [
className="u-mb-half u-breakword"
>
<p
className="MuiTypography-root-1 MuiTypography-body1-10"
className="MuiTypography-root MuiTypography-body1"
>
Google
</p>
<span
className="MuiTypography-root-1 MuiTypography-caption-11 MuiTypography-colorTextSecondary-34"
className="MuiTypography-root MuiTypography-caption MuiTypography-colorTextSecondary"
>
[email protected]
</span>
Expand Down Expand Up @@ -525,12 +525,12 @@ Array [
className="u-mb-half u-breakword"
>
<p
className="MuiTypography-root-1 MuiTypography-body1-10"
className="MuiTypography-root MuiTypography-body1"
>
Google
</p>
<span
className="MuiTypography-root-1 MuiTypography-caption-11 MuiTypography-colorTextSecondary-34"
className="MuiTypography-root MuiTypography-caption MuiTypography-colorTextSecondary"
>
[email protected]
</span>
Expand Down
43 changes: 30 additions & 13 deletions src/targets/browser/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import 'cozy-ui/transpiled/react/stylesheet.css'
import React from 'react'
import { Provider } from 'react-redux'
import { render } from 'react-dom'
import {
StylesProvider,
createGenerateClassName
} from '@material-ui/core/styles'

import { CozyProvider } from 'cozy-client'
import { I18n } from 'cozy-ui/transpiled/react/I18n'
Expand All @@ -15,24 +19,37 @@ import setupApp from './setupApp'
import { SelectedGroupProvider } from '../../components/Contexts/SelectedGroup'
import { SearchProvider } from '../../components/Contexts/Search'

/*
With MUI V4, it is possible to generate deterministic class names.
In the case of multiple react roots, it is necessary to disable this
feature. Since we have the cozy-bar root, we need to disable the
feature.
https://material-ui.com/styles/api/#stylesprovider
*/
const generateClassName = createGenerateClassName({
disableGlobal: true
})

const init = () => {
const { root, store, client, lang, polyglot } = setupApp()

render(
<Provider store={store}>
<CozyProvider client={client}>
<I18n lang={lang} polyglot={polyglot}>
<MuiCozyTheme>
<BreakpointsProvider>
<SelectedGroupProvider>
<SearchProvider>
<App />
</SearchProvider>
</SelectedGroupProvider>
</BreakpointsProvider>
</MuiCozyTheme>
</I18n>
</CozyProvider>
<StylesProvider generateClassName={generateClassName}>
<CozyProvider client={client}>
<I18n lang={lang} polyglot={polyglot}>
<MuiCozyTheme>
<BreakpointsProvider>
<SelectedGroupProvider>
<SearchProvider>
<App />
</SearchProvider>
</SelectedGroupProvider>
</BreakpointsProvider>
</MuiCozyTheme>
</I18n>
</CozyProvider>
</StylesProvider>
</Provider>,
root
)
Expand Down
Loading