diff --git a/packages/cozy-sharing/assets/icons/icon-cross-bold.svg b/packages/cozy-sharing/assets/icons/icon-cross-bold.svg index 4c60056ac7..44f9f48dbc 100644 --- a/packages/cozy-sharing/assets/icons/icon-cross-bold.svg +++ b/packages/cozy-sharing/assets/icons/icon-cross-bold.svg @@ -1,6 +1,5 @@ - - - - - + + diff --git a/packages/cozy-sharing/assets/icons/icon-eye-16.svg b/packages/cozy-sharing/assets/icons/icon-eye-16.svg index 7f332680b9..040b59faba 100644 --- a/packages/cozy-sharing/assets/icons/icon-eye-16.svg +++ b/packages/cozy-sharing/assets/icons/icon-eye-16.svg @@ -1,12 +1,12 @@ - + - + - + \ No newline at end of file diff --git a/packages/cozy-sharing/assets/icons/icon-hourglass-16.svg b/packages/cozy-sharing/assets/icons/icon-hourglass-16.svg index 4111f1e407..e1ad4590f5 100644 --- a/packages/cozy-sharing/assets/icons/icon-hourglass-16.svg +++ b/packages/cozy-sharing/assets/icons/icon-hourglass-16.svg @@ -1,14 +1,14 @@ - + - + - + - + \ No newline at end of file diff --git a/packages/cozy-sharing/assets/icons/icon-link-16.svg b/packages/cozy-sharing/assets/icons/icon-link-16.svg index b2e10fcd13..b53ced13ea 100644 --- a/packages/cozy-sharing/assets/icons/icon-link-16.svg +++ b/packages/cozy-sharing/assets/icons/icon-link-16.svg @@ -1,14 +1,14 @@ - + - + - + \ No newline at end of file diff --git a/packages/cozy-sharing/assets/icons/icon-link.svg b/packages/cozy-sharing/assets/icons/icon-link.svg index 9521511654..0eaf265911 100644 --- a/packages/cozy-sharing/assets/icons/icon-link.svg +++ b/packages/cozy-sharing/assets/icons/icon-link.svg @@ -1,14 +1,14 @@ - + - + - + \ No newline at end of file diff --git a/packages/cozy-sharing/assets/icons/icon-pen-write-16.svg b/packages/cozy-sharing/assets/icons/icon-pen-write-16.svg index 55e4a9bb97..c36643f642 100644 --- a/packages/cozy-sharing/assets/icons/icon-pen-write-16.svg +++ b/packages/cozy-sharing/assets/icons/icon-pen-write-16.svg @@ -1,12 +1,12 @@ - + - + - + \ No newline at end of file diff --git a/packages/cozy-sharing/babel.config.js b/packages/cozy-sharing/babel.config.js index 393e016db5..b0461ec49b 100644 --- a/packages/cozy-sharing/babel.config.js +++ b/packages/cozy-sharing/babel.config.js @@ -18,7 +18,20 @@ module.exports = { : '[name]__[local]___[hash:base64:5]' } ], - 'inline-react-svg' + [ + 'inline-react-svg', + { + svgo: { + plugins: [ + { + cleanupIDs: { + minify: false + } + } + ] + } + } + ] ], env: { test: { diff --git a/packages/cozy-sharing/package.json b/packages/cozy-sharing/package.json index db8cd5aea8..714168bf3b 100644 --- a/packages/cozy-sharing/package.json +++ b/packages/cozy-sharing/package.json @@ -41,6 +41,7 @@ "babel-plugin-css-modules-transform": "^1.6.2", "cozy-client": "^9.1.0", "cozy-ui": "^28.4.1", + "enzyme": "3.10.0", "enzyme-adapter-react-16": "^1.15.1", "enzyme-to-json": "^3.4.3", "react": "^16.12.0", diff --git a/packages/cozy-sharing/src/components/Recipient.jsx b/packages/cozy-sharing/src/components/Recipient.jsx index bf9834876e..6a971e4327 100644 --- a/packages/cozy-sharing/src/components/Recipient.jsx +++ b/packages/cozy-sharing/src/components/Recipient.jsx @@ -1,12 +1,7 @@ import React, { Component } from 'react' import classNames from 'classnames' import PropTypes from 'prop-types' -import { - Spinner, - MenuItem, - withBreakpoints, - Icon -} from 'cozy-ui/transpiled/react' +import { Spinner, MenuItem, withBreakpoints } from 'cozy-ui/transpiled/react' import MenuAwareMobile from './MenuAwareMobile' import { AvatarPlusX, AvatarLink, Avatar } from './Avatar' @@ -99,11 +94,11 @@ class Status extends Component { getStatusIcon = type => { switch (type) { case 'one-way': - return IconEye + return case 'two-way': - return IconPen + return default: - return IconHourglass + return } } @@ -138,7 +133,7 @@ class Status extends Component { }} name={name} > - }> + {status === 'ready' && type ? t(`Share.type.${type}`) : t(`Share.status.${status}`)} @@ -148,7 +143,7 @@ class Status extends Component { } + icon={} >
{isOwner diff --git a/packages/cozy-sharing/src/components/ShareAutosuggest.jsx b/packages/cozy-sharing/src/components/ShareAutosuggest.jsx index ec1017bdca..802ee9237c 100644 --- a/packages/cozy-sharing/src/components/ShareAutosuggest.jsx +++ b/packages/cozy-sharing/src/components/ShareAutosuggest.jsx @@ -1,7 +1,7 @@ import React, { Component } from 'react' import Autosuggest from 'react-autosuggest' -import { Icon, Spinner } from 'cozy-ui/transpiled/react' +import { Spinner } from 'cozy-ui/transpiled/react' import palette from 'cozy-ui/transpiled/react/palette' import styles from './autosuggest.styl' @@ -115,7 +115,7 @@ export default class ShareAutocomplete extends Component { className={styles['removeRecipient']} onClick={() => this.onRemove(recipient)} > - +
) diff --git a/packages/cozy-sharing/src/components/SharedDocuments.jsx b/packages/cozy-sharing/src/components/SharedDocuments.jsx index b75dea377b..36a258f8f6 100644 --- a/packages/cozy-sharing/src/components/SharedDocuments.jsx +++ b/packages/cozy-sharing/src/components/SharedDocuments.jsx @@ -1,17 +1,17 @@ import React from 'react' import PropTypes from 'prop-types' - +import uniq from 'lodash/uniq' import SharingContext from '../context' export const SharedDocuments = ({ children }) => ( - {({ sharings } = { sharings: [] }) => - children({ - sharedDocuments: sharings.map( - sharing => sharing.attributes.rules[0].values[0] - ) + {({ byDocId, hasLoadedAtLeastOnePage } = { byDocId: [] }) => { + const sharedDocuments = uniq(Object.keys(byDocId)) + return children({ + sharedDocuments, + hasLoadedAtLeastOnePage }) - } + }} ) diff --git a/packages/cozy-sharing/src/components/SharedStatus.jsx b/packages/cozy-sharing/src/components/SharedStatus.jsx index cf31326723..0987e18668 100644 --- a/packages/cozy-sharing/src/components/SharedStatus.jsx +++ b/packages/cozy-sharing/src/components/SharedStatus.jsx @@ -2,13 +2,12 @@ import React from 'react' import { translate } from 'cozy-ui/transpiled/react/I18n' import { SharingTooltip, TooltipRecipientList } from './Tooltip' import cx from 'classnames' -import Icon from 'cozy-ui/transpiled/react/Icon' import { Contact } from '../models' import styles from './status.styl' import LinkIcon from '../../assets/icons/icon-link.svg' -const SharedStatus = ({ className, docId, recipients, link, t }) => ( +export const SharedStatus = ({ className, docId, recipients, link, t }) => ( {recipients.length > 1 && ( ( /> )} - {link && } + {link && } ) diff --git a/packages/cozy-sharing/src/components/SharedStatus.spec.js b/packages/cozy-sharing/src/components/SharedStatus.spec.js new file mode 100644 index 0000000000..ec0ed44813 --- /dev/null +++ b/packages/cozy-sharing/src/components/SharedStatus.spec.js @@ -0,0 +1,45 @@ +import React from 'react' +import { mount } from 'enzyme' +import { SharedStatus } from './SharedStatus' +import AppLike from '../../test/AppLike' +describe('SharedStatus component', () => { + it('should just render a span if no sharing', () => { + const component = mount( + + + + ) + expect(component).toMatchSnapshot() + }) + + it('should have the right display if there is several recipients', () => { + const component = mount( + + x} + /> + + ) + expect(component).toMatchSnapshot() + }) + + it('should display the link if there is a link', () => { + const component = mount( + + x} link={true} /> + + ) + expect(component).toMatchSnapshot() + }) +}) diff --git a/packages/cozy-sharing/src/components/Tooltip.jsx b/packages/cozy-sharing/src/components/Tooltip.jsx index 5156054bbf..c95c7f9784 100644 --- a/packages/cozy-sharing/src/components/Tooltip.jsx +++ b/packages/cozy-sharing/src/components/Tooltip.jsx @@ -25,8 +25,8 @@ export class TooltipRecipientList extends React.Component { return (