From 784e9c7b0b3137fc4c9b1595ddc247f63569a4ae Mon Sep 17 00:00:00 2001 From: Crash-- Date: Mon, 29 Aug 2022 08:56:24 +0200 Subject: [PATCH] fix: Don't rely on cozy-doctypes Cozy-doctypes is an old project that should not be used anymore. Almost all the contact's related methods have been moved to cozy-client so let's use them. We lose the Contact's proptype ATM, but it will come back with cozy-client's types pretty soon. --- package.json | 4 +--- react/ContactPicker/index.jsx | 5 +++-- react/ContactsList/ContactRow.jsx | 3 +-- react/ContactsList/Contacts/ContactIdentity.jsx | 4 ++-- react/ContactsListModal/ContactsListContent.jsx | 5 +++-- yarn.lock | 11 ----------- 6 files changed, 10 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 622d11b0d1..7d91a3f2fc 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,6 @@ "copyfiles": "2.4.1", "cozy-client": "^33.0.0", "cozy-device-helper": "2.0.0", - "cozy-doctypes": "^1.69.0", "cozy-flags": "^2.10.1", "cozy-harvest-lib": "^6.7.3", "cozy-intent": "1.16.1", @@ -180,7 +179,6 @@ "peerDependencies": { "cozy-client": ">=33.0.0", "cozy-device-helper": "^2.0.0", - "cozy-doctypes": "^1.69.0", "cozy-harvest-lib": "^6.7.3", "cozy-intent": ">=1.3.0", "cozy-sharing": "^3.10.0", @@ -252,4 +250,4 @@ "browserslist": [ "extends browserslist-config-cozy" ] -} +} \ No newline at end of file diff --git a/react/ContactPicker/index.jsx b/react/ContactPicker/index.jsx index 2972d66cc2..bd1a0a2ece 100644 --- a/react/ContactPicker/index.jsx +++ b/react/ContactPicker/index.jsx @@ -1,7 +1,8 @@ import React from 'react' import PropTypes from 'prop-types' import cx from 'classnames' -import { Contact } from 'cozy-doctypes' +import { models } from 'cozy-client' +const { getDisplayName } = models.contact import ContactsListModal from '../ContactsListModal' import styles from './styles.styl' @@ -58,7 +59,7 @@ class ContactPicker extends React.Component { return ( <> - {value ? Contact.getDisplayName(value) : placeholder} + {value ? getDisplayName(value) : placeholder} {opened && ( { } ContactRow.propTypes = { - contact: Contact.propType.isRequired, + contact: PropTypes.object.isRequired, onClick: PropTypes.func, divider: PropTypes.bool } diff --git a/react/ContactsList/Contacts/ContactIdentity.jsx b/react/ContactsList/Contacts/ContactIdentity.jsx index 81df1fc858..85f87b19cd 100644 --- a/react/ContactsList/Contacts/ContactIdentity.jsx +++ b/react/ContactsList/Contacts/ContactIdentity.jsx @@ -1,6 +1,6 @@ import React from 'react' -import { Contact } from 'cozy-doctypes' import { models } from 'cozy-client' +import PropTypes from 'prop-types' import { Avatar } from '../../Avatar' import { TableCell } from '../../Table' @@ -32,7 +32,7 @@ const ContactIdentity = ({ contact }) => { } ContactIdentity.propTypes = { - contact: Contact.propType.isRequired + contact: PropTypes.object.isRequired } export default ContactIdentity diff --git a/react/ContactsListModal/ContactsListContent.jsx b/react/ContactsListModal/ContactsListContent.jsx index c49a9eeb1c..7cd1690792 100644 --- a/react/ContactsListModal/ContactsListContent.jsx +++ b/react/ContactsListModal/ContactsListContent.jsx @@ -1,6 +1,7 @@ import React from 'react' -import { Contact } from 'cozy-doctypes' +import { models } from 'cozy-client' +const { getDisplayName } = models.contact import ContactsList from '../ContactsList' import Spinner from '../Spinner' @@ -15,7 +16,7 @@ const mkFilter = filterStr => contacts => { // TODO better filtering methods can be extracted from drive. See https://github.com/cozy/cozy-ui/pull/1273#discussion_r351845385 return contacts.filter(contact => { - const displayName = Contact.getDisplayName(contact) + const displayName = getDisplayName(contact) if (!displayName) { return false diff --git a/yarn.lock b/yarn.lock index 38632fcbb4..bb2e4088ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5879,17 +5879,6 @@ cozy-device-helper@^1.12.0: dependencies: lodash "^4.17.19" -cozy-doctypes@^1.69.0: - version "1.83.7" - resolved "https://registry.yarnpkg.com/cozy-doctypes/-/cozy-doctypes-1.83.7.tgz#258448aa5fa8f76d557c7635c148d9bfe54bbe33" - integrity sha512-sAMZ/xajc2rXWmBFB0fP4NWQmUDh6FmStRE2KFpMrq7UGM6wIBouVl1CYD7grdlompBh3/1kBNmAb5PuWRMnBQ== - dependencies: - cozy-logger "^1.9.0" - date-fns "^1.30.1" - es6-promise-pool "^2.5.0" - lodash "^4.17.19" - prop-types "^15.7.2" - cozy-doctypes@^1.82.3: version "1.82.3" resolved "https://registry.yarnpkg.com/cozy-doctypes/-/cozy-doctypes-1.82.3.tgz#e8e759c7698fb2718a35c06e46b24c000a2b3cd4"