cozy-ui 81.8.0 → 81.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/react/MuiCozyTheme/List/Readme.md +11 -2
- package/react/MuiCozyTheme/ListItem/ExpandedAttributes/index.jsx +1 -1
- package/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/ActionMenuItemWrapper.jsx +81 -0
- package/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/call.js +29 -0
- package/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/emailTo.js +29 -0
- package/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/hr.js +10 -0
- package/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/modify.js +41 -0
- package/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/smsTo.js +29 -0
- package/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/viewInContacts.js +41 -0
- package/react/MuiCozyTheme/ListItem/ListItemBase/Renaming/RenameDialog.jsx +1 -1
- package/react/MuiCozyTheme/ListItem/ListItemBase/index.jsx +4 -2
- package/react/MuiCozyTheme/ListItem/ListItemContact/index.jsx +9 -1
- package/react/MuiCozyTheme/ListItem/ListItemContact/useActions.jsx +39 -0
- package/react/MuiCozyTheme/ListItem/ListItemFile/ExpirationAnnotation.jsx +1 -1
- package/react/MuiCozyTheme/ListItem/ListItemFile/PrimaryText.jsx +1 -1
- package/react/MuiCozyTheme/ListItem/hoc/withListItemLocales.jsx +1 -1
- package/react/MuiCozyTheme/ListItem/locales/en.json +7 -7
- package/react/MuiCozyTheme/ListItem/locales/fr.json +7 -6
- package/release.config.js +20 -13
- package/transpiled/react/MuiCozyTheme/ListItem/ExpandedAttributes/index.js +1 -1
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/ActionMenuItemWrapper.js +63 -0
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/call.js +29 -0
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/emailTo.js +29 -0
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/hr.js +9 -0
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/modify.js +39 -0
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/smsTo.js +29 -0
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/viewInContacts.js +39 -0
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/Renaming/RenameDialog.js +1 -1
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/index.js +8 -4
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemContact/index.js +12 -1
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemContact/useActions.js +41 -0
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemFile/ExpirationAnnotation.js +1 -1
- package/transpiled/react/MuiCozyTheme/ListItem/ListItemFile/PrimaryText.js +1 -1
- package/transpiled/react/MuiCozyTheme/ListItem/hoc/withListItemLocales.js +15 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [81.9.0](https://github.com/cozy/cozy-ui/compare/v81.8.0...v81.9.0) (2023-03-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **ListItemBase:** Clicking on actions wasn't toggling the menu ([3fbfa31](https://github.com/cozy/cozy-ui/commit/3fbfa31))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add ActionMenuItemWrapper for actions menus item ([068f247](https://github.com/cozy/cozy-ui/commit/068f247))
|
|
12
|
+
* **ListItemContact:** Add action menu header ([633ecf8](https://github.com/cozy/cozy-ui/commit/633ecf8))
|
|
13
|
+
* **ListItemContact:** Add default actions ([9164e87](https://github.com/cozy/cozy-ui/commit/9164e87))
|
|
14
|
+
|
|
1
15
|
# [81.8.0](https://github.com/cozy/cozy-ui/compare/v81.7.0...v81.8.0) (2023-03-22)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -296,17 +296,26 @@ const mockClient = {
|
|
|
296
296
|
unsubscribe: () => {},
|
|
297
297
|
unsubscribeAll: () => {}
|
|
298
298
|
}
|
|
299
|
-
}
|
|
299
|
+
},
|
|
300
|
+
getStackClient: () => ({
|
|
301
|
+
uri: 'https://cozy.io/'
|
|
302
|
+
}),
|
|
303
|
+
getInstanceOptions: () => ({
|
|
304
|
+
subdomain: ''
|
|
305
|
+
})
|
|
300
306
|
}
|
|
301
307
|
|
|
302
308
|
const contacts = [
|
|
303
309
|
{
|
|
310
|
+
_id: 'id01',
|
|
304
311
|
_type: 'io.cozy.contacts',
|
|
305
312
|
displayName: 'John Doe',
|
|
306
313
|
birthday: '25/10/2022',
|
|
307
|
-
email: [{ address: 'johndoe@cozy.cc', primary: true }]
|
|
314
|
+
email: [{ address: 'johndoe@cozy.cc', primary: true }],
|
|
315
|
+
phone: [{ number: '0102030405', primary: true }]
|
|
308
316
|
},
|
|
309
317
|
{
|
|
318
|
+
_id: 'id02',
|
|
310
319
|
_type: 'io.cozy.contacts',
|
|
311
320
|
displayName: 'Jason Bourne',
|
|
312
321
|
birthday: '01/01/2020',
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
|
|
4
4
|
import Snackbar from '../../../Snackbar'
|
|
5
5
|
import Alert from '../../../Alert'
|
|
6
|
-
import
|
|
6
|
+
import withListItemLocales from '../hoc/withListItemLocales'
|
|
7
7
|
import ExpandedAttribute from './ExpandedAttribute'
|
|
8
8
|
import { useI18n } from '../../../I18n'
|
|
9
9
|
import { makeAttrsKeyAndFormatedValue } from './helpers'
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import cx from 'classnames'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
|
|
5
|
+
import { makeStyles } from '../../../../styles'
|
|
6
|
+
import Typography from '../../../../Typography'
|
|
7
|
+
import Icon, { iconPropType } from '../../../../Icon'
|
|
8
|
+
import { ActionMenuItem } from '../../../../ActionMenu'
|
|
9
|
+
|
|
10
|
+
const useStyles = makeStyles(theme => ({
|
|
11
|
+
disabledItem: {
|
|
12
|
+
cursor: 'default',
|
|
13
|
+
'&:hover': {
|
|
14
|
+
backgroundColor: 'initial'
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
disabledIcon: {
|
|
18
|
+
fill: theme.palette.text.disabled
|
|
19
|
+
},
|
|
20
|
+
disabledTypography: {
|
|
21
|
+
color: theme.palette.text.disabled
|
|
22
|
+
}
|
|
23
|
+
}))
|
|
24
|
+
|
|
25
|
+
const ActionMenuItemWrapper = ({
|
|
26
|
+
icon,
|
|
27
|
+
className,
|
|
28
|
+
isEnabled,
|
|
29
|
+
componentsProps,
|
|
30
|
+
children,
|
|
31
|
+
onClick
|
|
32
|
+
}) => {
|
|
33
|
+
const styles = useStyles()
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ActionMenuItem
|
|
37
|
+
className={cx(`u-flex-items-center ${className}`, {
|
|
38
|
+
[styles.disabledItem]: !isEnabled
|
|
39
|
+
})}
|
|
40
|
+
left={
|
|
41
|
+
<Icon
|
|
42
|
+
icon={icon}
|
|
43
|
+
className={cx({
|
|
44
|
+
[styles.disabledIcon]: !isEnabled
|
|
45
|
+
})}
|
|
46
|
+
{...componentsProps?.iconProps}
|
|
47
|
+
/>
|
|
48
|
+
}
|
|
49
|
+
onClick={onClick}
|
|
50
|
+
>
|
|
51
|
+
<Typography
|
|
52
|
+
className={cx({
|
|
53
|
+
[styles.disabledTypography]: !isEnabled
|
|
54
|
+
})}
|
|
55
|
+
{...componentsProps?.typographyProps}
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
58
|
+
</Typography>
|
|
59
|
+
</ActionMenuItem>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
ActionMenuItemWrapper.defaultProps = {
|
|
64
|
+
className: '',
|
|
65
|
+
isEnabled: true,
|
|
66
|
+
componentsProps: {}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
ActionMenuItemWrapper.propTypes = {
|
|
70
|
+
icon: iconPropType,
|
|
71
|
+
className: PropTypes.string,
|
|
72
|
+
isEnabled: PropTypes.bool,
|
|
73
|
+
componentsProps: PropTypes.shape({
|
|
74
|
+
iconProps: PropTypes.object,
|
|
75
|
+
typographyProps: PropTypes.object
|
|
76
|
+
}),
|
|
77
|
+
children: PropTypes.node,
|
|
78
|
+
onClick: PropTypes.func
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default ActionMenuItemWrapper
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { useI18n } from '../../../../../I18n'
|
|
4
|
+
import TelephoneIcon from '../../../../../Icons/Telephone'
|
|
5
|
+
import withListItemLocales from '../../../hoc/withListItemLocales'
|
|
6
|
+
import ActionMenuItemWrapper from '../ActionMenuItemWrapper'
|
|
7
|
+
|
|
8
|
+
export const call = () => {
|
|
9
|
+
return {
|
|
10
|
+
name: 'call',
|
|
11
|
+
action: docs => {
|
|
12
|
+
const phoneNumber = docs?.[0]?.phone?.[0]?.number
|
|
13
|
+
!!phoneNumber && window.open(`tel:${phoneNumber}`, '_self')
|
|
14
|
+
},
|
|
15
|
+
Component: withListItemLocales(({ className, onClick }) => {
|
|
16
|
+
const { t } = useI18n()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ActionMenuItemWrapper
|
|
20
|
+
className={className}
|
|
21
|
+
icon={TelephoneIcon}
|
|
22
|
+
onClick={onClick}
|
|
23
|
+
>
|
|
24
|
+
{t('ListItem.actions.call')}
|
|
25
|
+
</ActionMenuItemWrapper>
|
|
26
|
+
)
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { useI18n } from '../../../../../I18n'
|
|
4
|
+
import EmailIcon from '../../../../../Icons/Email'
|
|
5
|
+
import withListItemLocales from '../../../hoc/withListItemLocales'
|
|
6
|
+
import ActionMenuItemWrapper from '../ActionMenuItemWrapper'
|
|
7
|
+
|
|
8
|
+
export const emailTo = () => {
|
|
9
|
+
return {
|
|
10
|
+
name: 'emailTo',
|
|
11
|
+
action: docs => {
|
|
12
|
+
const emailAddress = docs?.[0]?.email?.[0]?.address
|
|
13
|
+
!!emailAddress && window.open(`mailto:${emailAddress}`, '_self')
|
|
14
|
+
},
|
|
15
|
+
Component: withListItemLocales(({ className, onClick }) => {
|
|
16
|
+
const { t } = useI18n()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ActionMenuItemWrapper
|
|
20
|
+
className={className}
|
|
21
|
+
icon={EmailIcon}
|
|
22
|
+
onClick={onClick}
|
|
23
|
+
>
|
|
24
|
+
{t('ListItem.actions.emailTo')}
|
|
25
|
+
</ActionMenuItemWrapper>
|
|
26
|
+
)
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { generateWebLink, useClient } from 'cozy-client'
|
|
4
|
+
|
|
5
|
+
import Link from '../../../../../Link'
|
|
6
|
+
import { useI18n } from '../../../../../I18n'
|
|
7
|
+
import PenIcon from '../../../../../Icons/Pen'
|
|
8
|
+
import withListItemLocales from '../../../hoc/withListItemLocales'
|
|
9
|
+
import ActionMenuItemWrapper from '../ActionMenuItemWrapper'
|
|
10
|
+
|
|
11
|
+
export const modify = () => {
|
|
12
|
+
return {
|
|
13
|
+
name: 'modify',
|
|
14
|
+
Component: withListItemLocales(({ className, docs, onClick }) => {
|
|
15
|
+
const { t } = useI18n()
|
|
16
|
+
const client = useClient()
|
|
17
|
+
|
|
18
|
+
const contactId = docs[0]._id
|
|
19
|
+
|
|
20
|
+
const webLink = generateWebLink({
|
|
21
|
+
slug: 'contacts',
|
|
22
|
+
cozyUrl: client.getStackClient().uri,
|
|
23
|
+
subDomainType: client.getInstanceOptions().subdomain,
|
|
24
|
+
pathname: '/',
|
|
25
|
+
hash: `/${contactId}/edit`
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ActionMenuItemWrapper
|
|
30
|
+
className={className}
|
|
31
|
+
icon={PenIcon}
|
|
32
|
+
onClick={onClick}
|
|
33
|
+
>
|
|
34
|
+
<Link className="u-p-0" href={webLink} target="_blank">
|
|
35
|
+
{t('ListItem.actions.modify')}
|
|
36
|
+
</Link>
|
|
37
|
+
</ActionMenuItemWrapper>
|
|
38
|
+
)
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { useI18n } from '../../../../../I18n'
|
|
4
|
+
import CommentIcon from '../../../../../Icons/Comment'
|
|
5
|
+
import withListItemLocales from '../../../hoc/withListItemLocales'
|
|
6
|
+
import ActionMenuItemWrapper from '../ActionMenuItemWrapper'
|
|
7
|
+
|
|
8
|
+
export const smsTo = () => {
|
|
9
|
+
return {
|
|
10
|
+
name: 'smsTo',
|
|
11
|
+
action: docs => {
|
|
12
|
+
const phoneNumber = docs?.[0]?.phone?.[0]?.number
|
|
13
|
+
!!phoneNumber && window.open(`sms:${phoneNumber}`, '_self')
|
|
14
|
+
},
|
|
15
|
+
Component: withListItemLocales(({ className, onClick }) => {
|
|
16
|
+
const { t } = useI18n()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ActionMenuItemWrapper
|
|
20
|
+
className={className}
|
|
21
|
+
icon={CommentIcon}
|
|
22
|
+
onClick={onClick}
|
|
23
|
+
>
|
|
24
|
+
{t('ListItem.actions.smsTo')}
|
|
25
|
+
</ActionMenuItemWrapper>
|
|
26
|
+
)
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { generateWebLink, useClient } from 'cozy-client'
|
|
4
|
+
|
|
5
|
+
import Link from '../../../../../Link'
|
|
6
|
+
import { useI18n } from '../../../../../I18n'
|
|
7
|
+
import OpenappIcon from '../../../../../Icons/Openapp'
|
|
8
|
+
import withListItemLocales from '../../../hoc/withListItemLocales'
|
|
9
|
+
import ActionMenuItemWrapper from '../ActionMenuItemWrapper'
|
|
10
|
+
|
|
11
|
+
export const viewInContacts = () => {
|
|
12
|
+
return {
|
|
13
|
+
name: 'viewInContacts',
|
|
14
|
+
Component: withListItemLocales(({ className, docs, onClick }) => {
|
|
15
|
+
const { t } = useI18n()
|
|
16
|
+
const client = useClient()
|
|
17
|
+
|
|
18
|
+
const contactId = docs[0]._id
|
|
19
|
+
|
|
20
|
+
const webLink = generateWebLink({
|
|
21
|
+
slug: 'contacts',
|
|
22
|
+
cozyUrl: client.getStackClient().uri,
|
|
23
|
+
subDomainType: client.getInstanceOptions().subdomain,
|
|
24
|
+
pathname: '/',
|
|
25
|
+
hash: `/${contactId}`
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ActionMenuItemWrapper
|
|
30
|
+
className={className}
|
|
31
|
+
icon={OpenappIcon}
|
|
32
|
+
onClick={onClick}
|
|
33
|
+
>
|
|
34
|
+
<Link className="u-p-0" href={webLink} target="_blank">
|
|
35
|
+
{t('ListItem.actions.viewInContacts')}
|
|
36
|
+
</Link>
|
|
37
|
+
</ActionMenuItemWrapper>
|
|
38
|
+
)
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -5,7 +5,7 @@ import Button from '../../../../Buttons'
|
|
|
5
5
|
import { ConfirmDialog } from '../../../../CozyDialogs'
|
|
6
6
|
import { useI18n } from '../../../../I18n'
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import withListItemLocales from '../../hoc/withListItemLocales'
|
|
9
9
|
|
|
10
10
|
const RenameDialog = ({ onSubmit, onCancel }) => {
|
|
11
11
|
const { t } = useI18n()
|
|
@@ -14,7 +14,7 @@ import { ActionMenuHeader } from '../../../ActionMenu'
|
|
|
14
14
|
import ActionsItems from './ActionsMenu/ActionsItems'
|
|
15
15
|
import useBreakpoints from '../../../hooks/useBreakpoints'
|
|
16
16
|
import RenameInput from './Renaming/RenameInput'
|
|
17
|
-
import
|
|
17
|
+
import withListItemLocales from '../hoc/withListItemLocales'
|
|
18
18
|
import Checkbox from '../../../Checkbox'
|
|
19
19
|
|
|
20
20
|
const ListItemBase = ({
|
|
@@ -33,6 +33,8 @@ const ListItemBase = ({
|
|
|
33
33
|
const anchorRef = useRef()
|
|
34
34
|
const { isMobile } = useBreakpoints()
|
|
35
35
|
|
|
36
|
+
const toggleMenu = () => setShowActionMenu(v => !v)
|
|
37
|
+
|
|
36
38
|
const showActionMenuHeader = isMobile && actionMenuComp?.Header
|
|
37
39
|
const isButton = !isRenaming && !!onClick
|
|
38
40
|
const handleClick =
|
|
@@ -57,7 +59,7 @@ const ListItemBase = ({
|
|
|
57
59
|
)}
|
|
58
60
|
{actions && !isSelectActive && (
|
|
59
61
|
<ListItemSecondaryAction>
|
|
60
|
-
<IconButton ref={anchorRef} onClick={
|
|
62
|
+
<IconButton ref={anchorRef} onClick={toggleMenu}>
|
|
61
63
|
<Icon icon={DotsIcon} />
|
|
62
64
|
</IconButton>
|
|
63
65
|
</ListItemSecondaryAction>
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
|
+
import Filename from '../../../Filename'
|
|
4
5
|
import Icon from '../../../Icon'
|
|
5
6
|
import ContactsIcon from '../../../Icons/Contacts'
|
|
6
7
|
import ListItemBase from '../ListItemBase'
|
|
7
8
|
|
|
8
9
|
import { makeDefaultExpandedAttributes } from '../ExpandedAttributes/helpers'
|
|
10
|
+
import useActions from './useActions'
|
|
9
11
|
|
|
10
12
|
const ListItemContact = ({
|
|
11
13
|
contact,
|
|
@@ -17,6 +19,7 @@ const ListItemContact = ({
|
|
|
17
19
|
expandedAttributesProps: { isExpandedAttributesActive, expandedAttributes },
|
|
18
20
|
onClick
|
|
19
21
|
}) => {
|
|
22
|
+
const defaultActions = useActions(contact)
|
|
20
23
|
const primaryText = primary || contact.displayName
|
|
21
24
|
const secondaryText = secondary || contact.email?.[0]?.address
|
|
22
25
|
const itemIcon = icon || <Icon icon={ContactsIcon} width="32" height="32" />
|
|
@@ -25,6 +28,7 @@ const ListItemContact = ({
|
|
|
25
28
|
contact,
|
|
26
29
|
expandedAttributes
|
|
27
30
|
)
|
|
31
|
+
const itemActions = defaultActions.concat(actions)
|
|
28
32
|
|
|
29
33
|
return (
|
|
30
34
|
<ListItemBase
|
|
@@ -32,7 +36,10 @@ const ListItemContact = ({
|
|
|
32
36
|
primary={primaryText}
|
|
33
37
|
secondary={secondaryText}
|
|
34
38
|
icon={itemIcon}
|
|
35
|
-
actions={
|
|
39
|
+
actions={itemActions}
|
|
40
|
+
actionMenuComp={{
|
|
41
|
+
Header: <Filename icon={ContactsIcon} filename={primaryText} />
|
|
42
|
+
}}
|
|
36
43
|
selectProps={selectProps}
|
|
37
44
|
expandedAttributesProps={{
|
|
38
45
|
isExpandedAttributesActive,
|
|
@@ -44,6 +51,7 @@ const ListItemContact = ({
|
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
ListItemContact.defaultProps = {
|
|
54
|
+
actions: [],
|
|
47
55
|
expandedAttributesProps: {
|
|
48
56
|
isExpandedAttributesActive: false
|
|
49
57
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
|
|
3
|
+
import { makeActions } from '../ListItemBase/ActionsMenu/helpers'
|
|
4
|
+
import { hr } from '../ListItemBase/ActionsMenu/Actions/hr'
|
|
5
|
+
import { emailTo } from '../ListItemBase/ActionsMenu/Actions/emailTo'
|
|
6
|
+
import { smsTo } from '../ListItemBase/ActionsMenu/Actions/smsTo'
|
|
7
|
+
import { call } from '../ListItemBase/ActionsMenu/Actions/call'
|
|
8
|
+
import { modify } from '../ListItemBase/ActionsMenu/Actions/modify'
|
|
9
|
+
import { viewInContacts } from '../ListItemBase/ActionsMenu/Actions/viewInContacts'
|
|
10
|
+
|
|
11
|
+
const makeOptionalActions = contact => {
|
|
12
|
+
const optionalActions = [hr, call, smsTo, emailTo]
|
|
13
|
+
|
|
14
|
+
const hasPhoneAction = contact.phone?.length > 0
|
|
15
|
+
const hasEmailAction = contact.email?.length > 0
|
|
16
|
+
const hasMessageActions = hasPhoneAction || hasEmailAction
|
|
17
|
+
|
|
18
|
+
const conditions = {
|
|
19
|
+
hr: hasMessageActions,
|
|
20
|
+
call: hasPhoneAction,
|
|
21
|
+
smsTo: hasPhoneAction,
|
|
22
|
+
emailTo: hasEmailAction
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return optionalActions.filter(action => conditions[action.name])
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const useActions = contact => {
|
|
29
|
+
const optionalActions = useMemo(() => makeOptionalActions(contact), [contact])
|
|
30
|
+
const finalActions = useMemo(
|
|
31
|
+
() => [modify, viewInContacts].concat(optionalActions),
|
|
32
|
+
[optionalActions]
|
|
33
|
+
)
|
|
34
|
+
const actions = useMemo(() => makeActions(finalActions), [finalActions])
|
|
35
|
+
|
|
36
|
+
return actions
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default useActions
|
|
@@ -6,7 +6,7 @@ import { computeExpirationDate, isExpired } from 'cozy-client/dist/models/paper'
|
|
|
6
6
|
import Typography from '../../../Typography'
|
|
7
7
|
import { useI18n } from '../../../I18n'
|
|
8
8
|
import { formatLocallyDistanceToNowStrict } from '../../../I18n/format'
|
|
9
|
-
import
|
|
9
|
+
import withListItemLocales from '../hoc/withListItemLocales'
|
|
10
10
|
|
|
11
11
|
const ExpirationAnnotation = ({ file }) => {
|
|
12
12
|
const { t } = useI18n()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types'
|
|
2
2
|
|
|
3
3
|
import { useI18n } from '../../../I18n'
|
|
4
|
-
import
|
|
4
|
+
import withListItemLocales from '../hoc/withListItemLocales'
|
|
5
5
|
|
|
6
6
|
const PrimaryText = ({ primary, file }) => {
|
|
7
7
|
const { t } = useI18n()
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"ListItem": {
|
|
3
|
+
"actions": {
|
|
4
|
+
"viewInContacts": "View in Cozy Contacts",
|
|
5
|
+
"modify": "Modify",
|
|
6
|
+
"emailTo": "Send an email",
|
|
7
|
+
"smsTo": "Send a message",
|
|
8
|
+
"call": "Call"
|
|
9
|
+
},
|
|
3
10
|
"attributes": {
|
|
4
11
|
"birthday": "Birthday",
|
|
5
12
|
"address": "Address",
|
|
@@ -31,13 +38,6 @@
|
|
|
31
38
|
}
|
|
32
39
|
}
|
|
33
40
|
},
|
|
34
|
-
"contact": {
|
|
35
|
-
"birthday": "Birthday",
|
|
36
|
-
"actions": {
|
|
37
|
-
"copy": "Copy",
|
|
38
|
-
"delete": "Delete"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
41
|
"file": {
|
|
42
42
|
"expired": "Expired",
|
|
43
43
|
"expiresIn": "Expires in %{duration}",
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"ListItem": {
|
|
3
|
+
"actions": {
|
|
4
|
+
"viewInContacts": "Voir dans Cozy Contacts",
|
|
5
|
+
"modify": "Modifier",
|
|
6
|
+
"emailTo": "Envoyer un e-mail",
|
|
7
|
+
"smsTo": "Envoyer un message",
|
|
8
|
+
"call": "Appeler"
|
|
9
|
+
},
|
|
3
10
|
"attributes": {
|
|
4
11
|
"birthday": "Date de naissance",
|
|
5
12
|
"address": "Adresse",
|
|
@@ -31,12 +38,6 @@
|
|
|
31
38
|
}
|
|
32
39
|
}
|
|
33
40
|
},
|
|
34
|
-
"contact": {
|
|
35
|
-
"actions": {
|
|
36
|
-
"copy": "Copier",
|
|
37
|
-
"delete": "Supprimer"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
41
|
"file": {
|
|
41
42
|
"expired": "Expiré",
|
|
42
43
|
"expiresIn": "Expire dans %{duration}",
|
package/release.config.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
branch: 'master',
|
|
3
|
+
plugins: [
|
|
4
|
+
'@semantic-release/commit-analyzer',
|
|
5
|
+
'@semantic-release/release-notes-generator',
|
|
6
|
+
[
|
|
7
|
+
'@semantic-release/changelog',
|
|
8
|
+
{
|
|
9
|
+
changelogFile: 'CHANGELOG.md'
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
[
|
|
13
|
+
'@semantic-release/git',
|
|
14
|
+
{
|
|
15
|
+
assets: ['CHANGELOG.md', 'package.json'],
|
|
16
|
+
message:
|
|
17
|
+
'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
'@semantic-release/npm',
|
|
21
|
+
'@semantic-release/github'
|
|
15
22
|
]
|
|
16
23
|
}
|
|
@@ -3,7 +3,7 @@ import React, { useState } from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import Snackbar from "cozy-ui/transpiled/react/Snackbar";
|
|
5
5
|
import Alert from "cozy-ui/transpiled/react/Alert";
|
|
6
|
-
import
|
|
6
|
+
import withListItemLocales from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/hoc/withListItemLocales";
|
|
7
7
|
import ExpandedAttribute from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ExpandedAttributes/ExpandedAttribute";
|
|
8
8
|
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
9
9
|
import { makeAttrsKeyAndFormatedValue } from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ExpandedAttributes/helpers";
|
package/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/ActionMenuItemWrapper.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import cx from 'classnames';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { makeStyles } from "cozy-ui/transpiled/react/styles";
|
|
7
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
8
|
+
import Icon, { iconPropType } from "cozy-ui/transpiled/react/Icon";
|
|
9
|
+
import { ActionMenuItem } from "cozy-ui/transpiled/react/ActionMenu";
|
|
10
|
+
var useStyles = makeStyles(function (theme) {
|
|
11
|
+
return {
|
|
12
|
+
disabledItem: {
|
|
13
|
+
cursor: 'default',
|
|
14
|
+
'&:hover': {
|
|
15
|
+
backgroundColor: 'initial'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
disabledIcon: {
|
|
19
|
+
fill: theme.palette.text.disabled
|
|
20
|
+
},
|
|
21
|
+
disabledTypography: {
|
|
22
|
+
color: theme.palette.text.disabled
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
var ActionMenuItemWrapper = function ActionMenuItemWrapper(_ref) {
|
|
28
|
+
var icon = _ref.icon,
|
|
29
|
+
className = _ref.className,
|
|
30
|
+
isEnabled = _ref.isEnabled,
|
|
31
|
+
componentsProps = _ref.componentsProps,
|
|
32
|
+
children = _ref.children,
|
|
33
|
+
onClick = _ref.onClick;
|
|
34
|
+
var styles = useStyles();
|
|
35
|
+
return /*#__PURE__*/React.createElement(ActionMenuItem, {
|
|
36
|
+
className: cx("u-flex-items-center ".concat(className), _defineProperty({}, styles.disabledItem, !isEnabled)),
|
|
37
|
+
left: /*#__PURE__*/React.createElement(Icon, _extends({
|
|
38
|
+
icon: icon,
|
|
39
|
+
className: cx(_defineProperty({}, styles.disabledIcon, !isEnabled))
|
|
40
|
+
}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.iconProps)),
|
|
41
|
+
onClick: onClick
|
|
42
|
+
}, /*#__PURE__*/React.createElement(Typography, _extends({
|
|
43
|
+
className: cx(_defineProperty({}, styles.disabledTypography, !isEnabled))
|
|
44
|
+
}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.typographyProps), children));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
ActionMenuItemWrapper.defaultProps = {
|
|
48
|
+
className: '',
|
|
49
|
+
isEnabled: true,
|
|
50
|
+
componentsProps: {}
|
|
51
|
+
};
|
|
52
|
+
ActionMenuItemWrapper.propTypes = {
|
|
53
|
+
icon: iconPropType,
|
|
54
|
+
className: PropTypes.string,
|
|
55
|
+
isEnabled: PropTypes.bool,
|
|
56
|
+
componentsProps: PropTypes.shape({
|
|
57
|
+
iconProps: PropTypes.object,
|
|
58
|
+
typographyProps: PropTypes.object
|
|
59
|
+
}),
|
|
60
|
+
children: PropTypes.node,
|
|
61
|
+
onClick: PropTypes.func
|
|
62
|
+
};
|
|
63
|
+
export default ActionMenuItemWrapper;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
3
|
+
import TelephoneIcon from "cozy-ui/transpiled/react/Icons/Telephone";
|
|
4
|
+
import withListItemLocales from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/hoc/withListItemLocales";
|
|
5
|
+
import ActionMenuItemWrapper from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/ActionMenuItemWrapper";
|
|
6
|
+
export var call = function call() {
|
|
7
|
+
return {
|
|
8
|
+
name: 'call',
|
|
9
|
+
action: function action(docs) {
|
|
10
|
+
var _docs$, _docs$$phone, _docs$$phone$;
|
|
11
|
+
|
|
12
|
+
var phoneNumber = docs === null || docs === void 0 ? void 0 : (_docs$ = docs[0]) === null || _docs$ === void 0 ? void 0 : (_docs$$phone = _docs$.phone) === null || _docs$$phone === void 0 ? void 0 : (_docs$$phone$ = _docs$$phone[0]) === null || _docs$$phone$ === void 0 ? void 0 : _docs$$phone$.number;
|
|
13
|
+
!!phoneNumber && window.open("tel:".concat(phoneNumber), '_self');
|
|
14
|
+
},
|
|
15
|
+
Component: withListItemLocales(function (_ref) {
|
|
16
|
+
var className = _ref.className,
|
|
17
|
+
onClick = _ref.onClick;
|
|
18
|
+
|
|
19
|
+
var _useI18n = useI18n(),
|
|
20
|
+
t = _useI18n.t;
|
|
21
|
+
|
|
22
|
+
return /*#__PURE__*/React.createElement(ActionMenuItemWrapper, {
|
|
23
|
+
className: className,
|
|
24
|
+
icon: TelephoneIcon,
|
|
25
|
+
onClick: onClick
|
|
26
|
+
}, t('ListItem.actions.call'));
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
3
|
+
import EmailIcon from "cozy-ui/transpiled/react/Icons/Email";
|
|
4
|
+
import withListItemLocales from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/hoc/withListItemLocales";
|
|
5
|
+
import ActionMenuItemWrapper from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/ActionMenuItemWrapper";
|
|
6
|
+
export var emailTo = function emailTo() {
|
|
7
|
+
return {
|
|
8
|
+
name: 'emailTo',
|
|
9
|
+
action: function action(docs) {
|
|
10
|
+
var _docs$, _docs$$email, _docs$$email$;
|
|
11
|
+
|
|
12
|
+
var emailAddress = docs === null || docs === void 0 ? void 0 : (_docs$ = docs[0]) === null || _docs$ === void 0 ? void 0 : (_docs$$email = _docs$.email) === null || _docs$$email === void 0 ? void 0 : (_docs$$email$ = _docs$$email[0]) === null || _docs$$email$ === void 0 ? void 0 : _docs$$email$.address;
|
|
13
|
+
!!emailAddress && window.open("mailto:".concat(emailAddress), '_self');
|
|
14
|
+
},
|
|
15
|
+
Component: withListItemLocales(function (_ref) {
|
|
16
|
+
var className = _ref.className,
|
|
17
|
+
onClick = _ref.onClick;
|
|
18
|
+
|
|
19
|
+
var _useI18n = useI18n(),
|
|
20
|
+
t = _useI18n.t;
|
|
21
|
+
|
|
22
|
+
return /*#__PURE__*/React.createElement(ActionMenuItemWrapper, {
|
|
23
|
+
className: className,
|
|
24
|
+
icon: EmailIcon,
|
|
25
|
+
onClick: onClick
|
|
26
|
+
}, t('ListItem.actions.emailTo'));
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { generateWebLink, useClient } from 'cozy-client';
|
|
3
|
+
import Link from "cozy-ui/transpiled/react/Link";
|
|
4
|
+
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
5
|
+
import PenIcon from "cozy-ui/transpiled/react/Icons/Pen";
|
|
6
|
+
import withListItemLocales from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/hoc/withListItemLocales";
|
|
7
|
+
import ActionMenuItemWrapper from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/ActionMenuItemWrapper";
|
|
8
|
+
export var modify = function modify() {
|
|
9
|
+
return {
|
|
10
|
+
name: 'modify',
|
|
11
|
+
Component: withListItemLocales(function (_ref) {
|
|
12
|
+
var className = _ref.className,
|
|
13
|
+
docs = _ref.docs,
|
|
14
|
+
onClick = _ref.onClick;
|
|
15
|
+
|
|
16
|
+
var _useI18n = useI18n(),
|
|
17
|
+
t = _useI18n.t;
|
|
18
|
+
|
|
19
|
+
var client = useClient();
|
|
20
|
+
var contactId = docs[0]._id;
|
|
21
|
+
var webLink = generateWebLink({
|
|
22
|
+
slug: 'contacts',
|
|
23
|
+
cozyUrl: client.getStackClient().uri,
|
|
24
|
+
subDomainType: client.getInstanceOptions().subdomain,
|
|
25
|
+
pathname: '/',
|
|
26
|
+
hash: "/".concat(contactId, "/edit")
|
|
27
|
+
});
|
|
28
|
+
return /*#__PURE__*/React.createElement(ActionMenuItemWrapper, {
|
|
29
|
+
className: className,
|
|
30
|
+
icon: PenIcon,
|
|
31
|
+
onClick: onClick
|
|
32
|
+
}, /*#__PURE__*/React.createElement(Link, {
|
|
33
|
+
className: "u-p-0",
|
|
34
|
+
href: webLink,
|
|
35
|
+
target: "_blank"
|
|
36
|
+
}, t('ListItem.actions.modify')));
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
3
|
+
import CommentIcon from "cozy-ui/transpiled/react/Icons/Comment";
|
|
4
|
+
import withListItemLocales from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/hoc/withListItemLocales";
|
|
5
|
+
import ActionMenuItemWrapper from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/ActionMenuItemWrapper";
|
|
6
|
+
export var smsTo = function smsTo() {
|
|
7
|
+
return {
|
|
8
|
+
name: 'smsTo',
|
|
9
|
+
action: function action(docs) {
|
|
10
|
+
var _docs$, _docs$$phone, _docs$$phone$;
|
|
11
|
+
|
|
12
|
+
var phoneNumber = docs === null || docs === void 0 ? void 0 : (_docs$ = docs[0]) === null || _docs$ === void 0 ? void 0 : (_docs$$phone = _docs$.phone) === null || _docs$$phone === void 0 ? void 0 : (_docs$$phone$ = _docs$$phone[0]) === null || _docs$$phone$ === void 0 ? void 0 : _docs$$phone$.number;
|
|
13
|
+
!!phoneNumber && window.open("sms:".concat(phoneNumber), '_self');
|
|
14
|
+
},
|
|
15
|
+
Component: withListItemLocales(function (_ref) {
|
|
16
|
+
var className = _ref.className,
|
|
17
|
+
onClick = _ref.onClick;
|
|
18
|
+
|
|
19
|
+
var _useI18n = useI18n(),
|
|
20
|
+
t = _useI18n.t;
|
|
21
|
+
|
|
22
|
+
return /*#__PURE__*/React.createElement(ActionMenuItemWrapper, {
|
|
23
|
+
className: className,
|
|
24
|
+
icon: CommentIcon,
|
|
25
|
+
onClick: onClick
|
|
26
|
+
}, t('ListItem.actions.smsTo'));
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
};
|
package/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/viewInContacts.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { generateWebLink, useClient } from 'cozy-client';
|
|
3
|
+
import Link from "cozy-ui/transpiled/react/Link";
|
|
4
|
+
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
5
|
+
import OpenappIcon from "cozy-ui/transpiled/react/Icons/Openapp";
|
|
6
|
+
import withListItemLocales from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/hoc/withListItemLocales";
|
|
7
|
+
import ActionMenuItemWrapper from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/ActionMenuItemWrapper";
|
|
8
|
+
export var viewInContacts = function viewInContacts() {
|
|
9
|
+
return {
|
|
10
|
+
name: 'viewInContacts',
|
|
11
|
+
Component: withListItemLocales(function (_ref) {
|
|
12
|
+
var className = _ref.className,
|
|
13
|
+
docs = _ref.docs,
|
|
14
|
+
onClick = _ref.onClick;
|
|
15
|
+
|
|
16
|
+
var _useI18n = useI18n(),
|
|
17
|
+
t = _useI18n.t;
|
|
18
|
+
|
|
19
|
+
var client = useClient();
|
|
20
|
+
var contactId = docs[0]._id;
|
|
21
|
+
var webLink = generateWebLink({
|
|
22
|
+
slug: 'contacts',
|
|
23
|
+
cozyUrl: client.getStackClient().uri,
|
|
24
|
+
subDomainType: client.getInstanceOptions().subdomain,
|
|
25
|
+
pathname: '/',
|
|
26
|
+
hash: "/".concat(contactId)
|
|
27
|
+
});
|
|
28
|
+
return /*#__PURE__*/React.createElement(ActionMenuItemWrapper, {
|
|
29
|
+
className: className,
|
|
30
|
+
icon: OpenappIcon,
|
|
31
|
+
onClick: onClick
|
|
32
|
+
}, /*#__PURE__*/React.createElement(Link, {
|
|
33
|
+
className: "u-p-0",
|
|
34
|
+
href: webLink,
|
|
35
|
+
target: "_blank"
|
|
36
|
+
}, t('ListItem.actions.viewInContacts')));
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import Button from "cozy-ui/transpiled/react/Buttons";
|
|
4
4
|
import { ConfirmDialog } from "cozy-ui/transpiled/react/CozyDialogs";
|
|
5
5
|
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
6
|
-
import
|
|
6
|
+
import withListItemLocales from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/hoc/withListItemLocales";
|
|
7
7
|
|
|
8
8
|
var RenameDialog = function RenameDialog(_ref) {
|
|
9
9
|
var onSubmit = _ref.onSubmit,
|
|
@@ -14,7 +14,7 @@ import { ActionMenuHeader } from "cozy-ui/transpiled/react/ActionMenu";
|
|
|
14
14
|
import ActionsItems from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/ActionsItems";
|
|
15
15
|
import useBreakpoints from "cozy-ui/transpiled/react/hooks/useBreakpoints";
|
|
16
16
|
import RenameInput from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/Renaming/RenameInput";
|
|
17
|
-
import
|
|
17
|
+
import withListItemLocales from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/hoc/withListItemLocales";
|
|
18
18
|
import Checkbox from "cozy-ui/transpiled/react/Checkbox";
|
|
19
19
|
|
|
20
20
|
var ListItemBase = function ListItemBase(_ref) {
|
|
@@ -48,6 +48,12 @@ var ListItemBase = function ListItemBase(_ref) {
|
|
|
48
48
|
var _useBreakpoints = useBreakpoints(),
|
|
49
49
|
isMobile = _useBreakpoints.isMobile;
|
|
50
50
|
|
|
51
|
+
var toggleMenu = function toggleMenu() {
|
|
52
|
+
return setShowActionMenu(function (v) {
|
|
53
|
+
return !v;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
51
57
|
var showActionMenuHeader = isMobile && (actionMenuComp === null || actionMenuComp === void 0 ? void 0 : actionMenuComp.Header);
|
|
52
58
|
var isButton = !isRenaming && !!onClick;
|
|
53
59
|
var handleClick = !isRenaming && !isSelected && onClick ? onClick : undefined;
|
|
@@ -70,9 +76,7 @@ var ListItemBase = function ListItemBase(_ref) {
|
|
|
70
76
|
secondary: secondary
|
|
71
77
|
}), actions && !isSelectActive && /*#__PURE__*/React.createElement(ListItemSecondaryAction, null, /*#__PURE__*/React.createElement(IconButton, {
|
|
72
78
|
ref: anchorRef,
|
|
73
|
-
onClick:
|
|
74
|
-
return setShowActionMenu(true);
|
|
75
|
-
}
|
|
79
|
+
onClick: toggleMenu
|
|
76
80
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
77
81
|
icon: DotsIcon
|
|
78
82
|
})))), isExpandedAttributesActive && /*#__PURE__*/React.createElement(ExpandedAttributes, {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import Filename from "cozy-ui/transpiled/react/Filename";
|
|
3
4
|
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
4
5
|
import ContactsIcon from "cozy-ui/transpiled/react/Icons/Contacts";
|
|
5
6
|
import ListItemBase from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase";
|
|
6
7
|
import { makeDefaultExpandedAttributes } from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ExpandedAttributes/helpers";
|
|
8
|
+
import useActions from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemContact/useActions";
|
|
7
9
|
|
|
8
10
|
var ListItemContact = function ListItemContact(_ref) {
|
|
9
11
|
var _contact$email, _contact$email$;
|
|
@@ -18,6 +20,7 @@ var ListItemContact = function ListItemContact(_ref) {
|
|
|
18
20
|
isExpandedAttributesActive = _ref$expandedAttribut.isExpandedAttributesActive,
|
|
19
21
|
expandedAttributes = _ref$expandedAttribut.expandedAttributes,
|
|
20
22
|
onClick = _ref.onClick;
|
|
23
|
+
var defaultActions = useActions(contact);
|
|
21
24
|
var primaryText = primary || contact.displayName;
|
|
22
25
|
var secondaryText = secondary || ((_contact$email = contact.email) === null || _contact$email === void 0 ? void 0 : (_contact$email$ = _contact$email[0]) === null || _contact$email$ === void 0 ? void 0 : _contact$email$.address);
|
|
23
26
|
var itemIcon = icon || /*#__PURE__*/React.createElement(Icon, {
|
|
@@ -26,12 +29,19 @@ var ListItemContact = function ListItemContact(_ref) {
|
|
|
26
29
|
height: "32"
|
|
27
30
|
});
|
|
28
31
|
var itemExpandedAttributes = makeDefaultExpandedAttributes(contact, expandedAttributes);
|
|
32
|
+
var itemActions = defaultActions.concat(actions);
|
|
29
33
|
return /*#__PURE__*/React.createElement(ListItemBase, {
|
|
30
34
|
doc: contact,
|
|
31
35
|
primary: primaryText,
|
|
32
36
|
secondary: secondaryText,
|
|
33
37
|
icon: itemIcon,
|
|
34
|
-
actions:
|
|
38
|
+
actions: itemActions,
|
|
39
|
+
actionMenuComp: {
|
|
40
|
+
Header: /*#__PURE__*/React.createElement(Filename, {
|
|
41
|
+
icon: ContactsIcon,
|
|
42
|
+
filename: primaryText
|
|
43
|
+
})
|
|
44
|
+
},
|
|
35
45
|
selectProps: selectProps,
|
|
36
46
|
expandedAttributesProps: {
|
|
37
47
|
isExpandedAttributesActive: isExpandedAttributesActive,
|
|
@@ -42,6 +52,7 @@ var ListItemContact = function ListItemContact(_ref) {
|
|
|
42
52
|
};
|
|
43
53
|
|
|
44
54
|
ListItemContact.defaultProps = {
|
|
55
|
+
actions: [],
|
|
45
56
|
expandedAttributesProps: {
|
|
46
57
|
isExpandedAttributesActive: false
|
|
47
58
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { makeActions } from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/helpers";
|
|
3
|
+
import { hr } from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/hr";
|
|
4
|
+
import { emailTo } from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/emailTo";
|
|
5
|
+
import { smsTo } from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/smsTo";
|
|
6
|
+
import { call } from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/call";
|
|
7
|
+
import { modify } from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/modify";
|
|
8
|
+
import { viewInContacts } from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemBase/ActionsMenu/Actions/viewInContacts";
|
|
9
|
+
|
|
10
|
+
var makeOptionalActions = function makeOptionalActions(contact) {
|
|
11
|
+
var _contact$phone, _contact$email;
|
|
12
|
+
|
|
13
|
+
var optionalActions = [hr, call, smsTo, emailTo];
|
|
14
|
+
var hasPhoneAction = ((_contact$phone = contact.phone) === null || _contact$phone === void 0 ? void 0 : _contact$phone.length) > 0;
|
|
15
|
+
var hasEmailAction = ((_contact$email = contact.email) === null || _contact$email === void 0 ? void 0 : _contact$email.length) > 0;
|
|
16
|
+
var hasMessageActions = hasPhoneAction || hasEmailAction;
|
|
17
|
+
var conditions = {
|
|
18
|
+
hr: hasMessageActions,
|
|
19
|
+
call: hasPhoneAction,
|
|
20
|
+
smsTo: hasPhoneAction,
|
|
21
|
+
emailTo: hasEmailAction
|
|
22
|
+
};
|
|
23
|
+
return optionalActions.filter(function (action) {
|
|
24
|
+
return conditions[action.name];
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var useActions = function useActions(contact) {
|
|
29
|
+
var optionalActions = useMemo(function () {
|
|
30
|
+
return makeOptionalActions(contact);
|
|
31
|
+
}, [contact]);
|
|
32
|
+
var finalActions = useMemo(function () {
|
|
33
|
+
return [modify, viewInContacts].concat(optionalActions);
|
|
34
|
+
}, [optionalActions]);
|
|
35
|
+
var actions = useMemo(function () {
|
|
36
|
+
return makeActions(finalActions);
|
|
37
|
+
}, [finalActions]);
|
|
38
|
+
return actions;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default useActions;
|
|
@@ -4,7 +4,7 @@ import { computeExpirationDate, isExpired } from 'cozy-client/dist/models/paper'
|
|
|
4
4
|
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
5
5
|
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
6
6
|
import { formatLocallyDistanceToNowStrict } from "cozy-ui/transpiled/react/I18n/format";
|
|
7
|
-
import
|
|
7
|
+
import withListItemLocales from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/hoc/withListItemLocales";
|
|
8
8
|
|
|
9
9
|
var ExpirationAnnotation = function ExpirationAnnotation(_ref) {
|
|
10
10
|
var file = _ref.file;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
3
|
-
import
|
|
3
|
+
import withListItemLocales from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/hoc/withListItemLocales";
|
|
4
4
|
|
|
5
5
|
var PrimaryText = function PrimaryText(_ref) {
|
|
6
6
|
var _file$metadata, _file$metadata$qualif;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import withLocales from "cozy-ui/transpiled/react/I18n/withLocales";
|
|
2
2
|
var en = {
|
|
3
3
|
ListItem: {
|
|
4
|
+
actions: {
|
|
5
|
+
viewInContacts: "View in Cozy Contacts",
|
|
6
|
+
modify: "Modify",
|
|
7
|
+
emailTo: "Send an email",
|
|
8
|
+
smsTo: "Send a message",
|
|
9
|
+
call: "Call"
|
|
10
|
+
},
|
|
4
11
|
attributes: {
|
|
5
12
|
birthday: "Birthday",
|
|
6
13
|
address: "Address",
|
|
@@ -32,13 +39,6 @@ var en = {
|
|
|
32
39
|
}
|
|
33
40
|
}
|
|
34
41
|
},
|
|
35
|
-
contact: {
|
|
36
|
-
birthday: "Birthday",
|
|
37
|
-
actions: {
|
|
38
|
-
copy: "Copy",
|
|
39
|
-
"delete": "Delete"
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
42
|
file: {
|
|
43
43
|
expired: "Expired",
|
|
44
44
|
expiresIn: "Expires in %{duration}",
|
|
@@ -63,6 +63,13 @@ var en = {
|
|
|
63
63
|
};
|
|
64
64
|
var fr = {
|
|
65
65
|
ListItem: {
|
|
66
|
+
actions: {
|
|
67
|
+
viewInContacts: "Voir dans Cozy Contacts",
|
|
68
|
+
modify: "Modifier",
|
|
69
|
+
emailTo: "Envoyer un e-mail",
|
|
70
|
+
smsTo: "Envoyer un message",
|
|
71
|
+
call: "Appeler"
|
|
72
|
+
},
|
|
66
73
|
attributes: {
|
|
67
74
|
birthday: "Date de naissance",
|
|
68
75
|
address: "Adresse",
|
|
@@ -94,12 +101,6 @@ var fr = {
|
|
|
94
101
|
}
|
|
95
102
|
}
|
|
96
103
|
},
|
|
97
|
-
contact: {
|
|
98
|
-
actions: {
|
|
99
|
-
copy: "Copier",
|
|
100
|
-
"delete": "Supprimer"
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
104
|
file: {
|
|
104
105
|
expired: "Expir\xE9",
|
|
105
106
|
expiresIn: "Expire dans %{duration}",
|
|
@@ -126,4 +127,4 @@ export var locales = {
|
|
|
126
127
|
en: en,
|
|
127
128
|
fr: fr
|
|
128
129
|
};
|
|
129
|
-
export
|
|
130
|
+
export default withLocales(locales);
|