cozy-ui 77.10.0 → 78.0.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 +21 -0
- package/package.json +3 -3
- package/react/Viewer/Panel/Qualification.jsx +39 -25
- package/react/Viewer/Panel/QualificationListItemDate.jsx +23 -2
- package/react/Viewer/Readme.md +10 -1
- package/react/Viewer/components/ExpirationAlert.jsx +81 -0
- package/react/Viewer/components/ExpirationAnnotation.jsx +38 -0
- package/react/Viewer/locales/en.json +7 -1
- package/react/Viewer/locales/fr.json +7 -1
- package/transpiled/react/Viewer/Panel/Qualification.js +17 -7
- package/transpiled/react/Viewer/Panel/QualificationListItemDate.js +18 -2
- package/transpiled/react/Viewer/components/ExpirationAlert.js +102 -0
- package/transpiled/react/Viewer/components/ExpirationAnnotation.js +38 -0
- package/transpiled/react/Viewer/hoc/withViewerLocales.js +14 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# [78.0.0](https://github.com/cozy/cozy-ui/compare/v77.10.0...v78.0.0) (2022-12-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Require `file` prop in `Qualification` ([c29f5c7](https://github.com/cozy/cozy-ui/commit/c29f5c7))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add an `ExpirationAlert` component ([9793851](https://github.com/cozy/cozy-ui/commit/9793851))
|
|
12
|
+
* Add an `ExpirationAnnotation` component ([50109bc](https://github.com/cozy/cozy-ui/commit/50109bc))
|
|
13
|
+
* Add expiration annotations to date qualifications ([a48496d](https://github.com/cozy/cozy-ui/commit/a48496d))
|
|
14
|
+
* Add the expiration alert to the qualification block ([651be00](https://github.com/cozy/cozy-ui/commit/651be00))
|
|
15
|
+
* Update `cozy-client` to 34.4.0 ([6bdaa34](https://github.com/cozy/cozy-ui/commit/6bdaa34))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### BREAKING CHANGES
|
|
19
|
+
|
|
20
|
+
* You need to update `cozy-client` to `>34.4.0`.
|
|
21
|
+
|
|
1
22
|
# [77.10.0](https://github.com/cozy/cozy-ui/compare/v77.9.2...v77.10.0) (2022-12-05)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "78.0.0",
|
|
4
4
|
"description": "Cozy apps UI SDK",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"babel-preset-cozy-app": "2.0.2",
|
|
91
91
|
"browserslist-config-cozy": "0.4.0",
|
|
92
92
|
"copyfiles": "2.4.1",
|
|
93
|
-
"cozy-client": "^
|
|
93
|
+
"cozy-client": "^34.4.0",
|
|
94
94
|
"cozy-device-helper": "2.0.0",
|
|
95
95
|
"cozy-flags": "^2.10.1",
|
|
96
96
|
"cozy-harvest-lib": "^6.7.3",
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
"rooks": "^5.11.2"
|
|
180
180
|
},
|
|
181
181
|
"peerDependencies": {
|
|
182
|
-
"cozy-client": ">=
|
|
182
|
+
"cozy-client": ">=34.4.0",
|
|
183
183
|
"cozy-device-helper": "^2.0.0",
|
|
184
184
|
"cozy-harvest-lib": "^6.7.3",
|
|
185
185
|
"cozy-intent": ">=1.3.0",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { useRef, useState, createRef, useMemo, useEffect } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
|
+
import { models } from 'cozy-client'
|
|
5
|
+
|
|
4
6
|
import List from '../../MuiCozyTheme/List'
|
|
5
7
|
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
6
8
|
import {
|
|
@@ -9,12 +11,15 @@ import {
|
|
|
9
11
|
knownInformationMetadataNames,
|
|
10
12
|
knownOtherMetadataNames
|
|
11
13
|
} from '../helpers'
|
|
14
|
+
import ExpirationAlert from '../components/ExpirationAlert'
|
|
12
15
|
import QualificationListItemContact from './QualificationListItemContact'
|
|
13
16
|
import ActionMenuWrapper from './ActionMenuWrapper'
|
|
14
17
|
import QualificationListItemDate from './QualificationListItemDate'
|
|
15
18
|
import QualificationListItemInformation from './QualificationListItemInformation'
|
|
16
19
|
import QualificationListItemOther from './QualificationListItemOther'
|
|
17
20
|
|
|
21
|
+
const { isExpiringSoon } = models.paper
|
|
22
|
+
|
|
18
23
|
const makeQualificationListItemComp = metadataName => {
|
|
19
24
|
if (knownDateMetadataNames.includes(metadataName)) {
|
|
20
25
|
return QualificationListItemDate
|
|
@@ -32,7 +37,11 @@ const makeQualificationListItemComp = metadataName => {
|
|
|
32
37
|
}
|
|
33
38
|
}
|
|
34
39
|
|
|
35
|
-
const
|
|
40
|
+
const isExpirationAlertHidden = file => {
|
|
41
|
+
return file?.metadata?.hideExpirationAlert ?? false
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const Qualification = ({ file }) => {
|
|
36
45
|
const { metadata = {} } = file
|
|
37
46
|
const actionBtnRef = useRef([])
|
|
38
47
|
const [optionFile, setOptionFile] = useState({
|
|
@@ -63,36 +72,41 @@ const Qualification = ({ file = {} }) => {
|
|
|
63
72
|
}, [formatedMetadataQualification])
|
|
64
73
|
|
|
65
74
|
return (
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
<>
|
|
76
|
+
{isExpiringSoon(file) && !isExpirationAlertHidden(file) && (
|
|
77
|
+
<ExpirationAlert file={file} />
|
|
78
|
+
)}
|
|
79
|
+
<List className={'u-pv-1'}>
|
|
80
|
+
{formatedMetadataQualification.map((meta, idx) => {
|
|
81
|
+
const { name } = meta
|
|
82
|
+
const QualificationListItemComp = makeQualificationListItemComp(name)
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<QualificationListItemComp
|
|
86
|
+
key={idx}
|
|
87
|
+
file={file}
|
|
88
|
+
ref={actionBtnRef.current[idx]}
|
|
89
|
+
formatedMetadataQualification={meta}
|
|
90
|
+
toggleActionsMenu={val => toggleActionsMenu(idx, name, val)}
|
|
91
|
+
/>
|
|
92
|
+
)
|
|
93
|
+
})}
|
|
94
|
+
|
|
95
|
+
{optionFile.name && (
|
|
96
|
+
<ActionMenuWrapper
|
|
97
|
+
onClose={hideActionsMenu}
|
|
74
98
|
file={file}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
toggleActionsMenu={val => toggleActionsMenu(idx, name, val)}
|
|
99
|
+
optionFile={optionFile}
|
|
100
|
+
ref={actionBtnRef.current[optionFile.id]}
|
|
78
101
|
/>
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
{optionFile.name && (
|
|
83
|
-
<ActionMenuWrapper
|
|
84
|
-
onClose={hideActionsMenu}
|
|
85
|
-
file={file}
|
|
86
|
-
optionFile={optionFile}
|
|
87
|
-
ref={actionBtnRef.current[optionFile.id]}
|
|
88
|
-
/>
|
|
89
|
-
)}
|
|
90
|
-
</List>
|
|
102
|
+
)}
|
|
103
|
+
</List>
|
|
104
|
+
</>
|
|
91
105
|
)
|
|
92
106
|
}
|
|
93
107
|
|
|
94
108
|
Qualification.propTypes = {
|
|
95
|
-
file: PropTypes.object
|
|
109
|
+
file: PropTypes.object.isRequired
|
|
96
110
|
}
|
|
97
111
|
|
|
98
112
|
export default withViewerLocales(Qualification)
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
|
+
import { models } from 'cozy-client'
|
|
5
|
+
|
|
4
6
|
import ListItem from '../../MuiCozyTheme/ListItem'
|
|
5
7
|
import ListItemSecondaryAction from '../../MuiCozyTheme/ListItemSecondaryAction'
|
|
6
8
|
import IconButton from '../../IconButton'
|
|
7
9
|
import Icon from '../../Icon'
|
|
8
10
|
import Dots from '../../Icons/Dots'
|
|
11
|
+
import Typography from '../../Typography'
|
|
12
|
+
import ExpirationAnnotation from '../components/ExpirationAnnotation'
|
|
9
13
|
import QualificationListItemText from './QualificationListItemText'
|
|
10
14
|
import { useI18n } from '../../I18n'
|
|
11
15
|
import { formatDate } from '../helpers'
|
|
12
16
|
|
|
17
|
+
const { isExpired, isExpiringSoon } = models.paper
|
|
18
|
+
|
|
13
19
|
const QualificationListItemDate = forwardRef(
|
|
14
|
-
({ formatedMetadataQualification, toggleActionsMenu }, ref) => {
|
|
20
|
+
({ file, formatedMetadataQualification, toggleActionsMenu }, ref) => {
|
|
15
21
|
const { t, f, lang } = useI18n()
|
|
16
22
|
const { name, value } = formatedMetadataQualification
|
|
17
23
|
const formattedDate = value
|
|
@@ -22,7 +28,21 @@ const QualificationListItemDate = forwardRef(
|
|
|
22
28
|
<ListItem className={'u-pl-2 u-pr-3'}>
|
|
23
29
|
<QualificationListItemText
|
|
24
30
|
primary={t(`Viewer.panel.qualification.date.title.${name}`)}
|
|
25
|
-
secondary={
|
|
31
|
+
secondary={
|
|
32
|
+
<>
|
|
33
|
+
<Typography component="span" variant="inherit">
|
|
34
|
+
{formattedDate}
|
|
35
|
+
</Typography>
|
|
36
|
+
{(isExpired(file) || isExpiringSoon(file)) && (
|
|
37
|
+
<>
|
|
38
|
+
<Typography component="span" variant="inherit">
|
|
39
|
+
{' · '}
|
|
40
|
+
</Typography>
|
|
41
|
+
<ExpirationAnnotation file={file} />
|
|
42
|
+
</>
|
|
43
|
+
)}
|
|
44
|
+
</>
|
|
45
|
+
}
|
|
26
46
|
disabled={!value}
|
|
27
47
|
/>
|
|
28
48
|
<ListItemSecondaryAction>
|
|
@@ -41,6 +61,7 @@ const QualificationListItemDate = forwardRef(
|
|
|
41
61
|
QualificationListItemDate.displayName = 'QualificationListItemDate'
|
|
42
62
|
|
|
43
63
|
QualificationListItemDate.propTypes = {
|
|
64
|
+
file: PropTypes.object.isRequired,
|
|
44
65
|
formatedMetadataQualification: PropTypes.shape({
|
|
45
66
|
name: PropTypes.string,
|
|
46
67
|
value: PropTypes.string
|
package/react/Viewer/Readme.md
CHANGED
|
@@ -122,7 +122,16 @@ const files = [
|
|
|
122
122
|
_id: 'image',
|
|
123
123
|
class: 'image',
|
|
124
124
|
name: 'Demo.jpg',
|
|
125
|
-
mime: 'image/jpg'
|
|
125
|
+
mime: 'image/jpg',
|
|
126
|
+
metadata: {
|
|
127
|
+
carbonCopy: true,
|
|
128
|
+
electronicSafe: true,
|
|
129
|
+
referencedDate: new Date(Date.now() - 357 * 24 * 60 * 60 * 1000).toISOString(),
|
|
130
|
+
datetimeLabel: "referencedDate",
|
|
131
|
+
qualification: {
|
|
132
|
+
label: 'personal_sporting_licence'
|
|
133
|
+
}
|
|
134
|
+
}
|
|
126
135
|
},
|
|
127
136
|
{
|
|
128
137
|
_id: 'none',
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
|
|
4
|
+
import { useClient, models } from 'cozy-client'
|
|
5
|
+
|
|
6
|
+
import Alert from '../../Alert'
|
|
7
|
+
import Button from '../../Buttons'
|
|
8
|
+
import Link from '../../Link'
|
|
9
|
+
import Typography from '../../Typography'
|
|
10
|
+
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
11
|
+
import { useI18n } from '../../I18n'
|
|
12
|
+
import { formatLocallyDistanceToNow } from '../../I18n/format'
|
|
13
|
+
|
|
14
|
+
const FILES_DOCTYPE = 'io.cozy.files'
|
|
15
|
+
|
|
16
|
+
const { computeExpirationDate, computeExpirationNoticeLink } = models.paper
|
|
17
|
+
|
|
18
|
+
const ExpirationAlert = ({ file }) => {
|
|
19
|
+
const { t } = useI18n()
|
|
20
|
+
const client = useClient()
|
|
21
|
+
const [isBusy, setIsBusy] = useState(false)
|
|
22
|
+
|
|
23
|
+
const handleClose = async () => {
|
|
24
|
+
setIsBusy(true)
|
|
25
|
+
await client.collection(FILES_DOCTYPE).updateMetadataAttribute(file.id, {
|
|
26
|
+
...file.metadata,
|
|
27
|
+
hideExpirationAlert: true
|
|
28
|
+
})
|
|
29
|
+
setIsBusy(false)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const expirationDate = computeExpirationDate(file)
|
|
33
|
+
const expirationNoticeLink = computeExpirationNoticeLink(file)
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Alert
|
|
37
|
+
severity="warning"
|
|
38
|
+
block
|
|
39
|
+
action={
|
|
40
|
+
<Button
|
|
41
|
+
color="warning"
|
|
42
|
+
variant="text"
|
|
43
|
+
size="small"
|
|
44
|
+
busy={isBusy}
|
|
45
|
+
label={t('Viewer.panel.expiration.dismiss')}
|
|
46
|
+
onClick={handleClose}
|
|
47
|
+
/>
|
|
48
|
+
}
|
|
49
|
+
className="u-mt-1 u-mh-1"
|
|
50
|
+
>
|
|
51
|
+
<Typography component="span" variant="inherit">
|
|
52
|
+
<Typography component="span" variant="inherit">
|
|
53
|
+
{t('Viewer.panel.expiration.description', {
|
|
54
|
+
duration: formatLocallyDistanceToNow(expirationDate)
|
|
55
|
+
})}
|
|
56
|
+
</Typography>
|
|
57
|
+
{expirationNoticeLink && (
|
|
58
|
+
<>
|
|
59
|
+
<Typography component="span" variant="inherit">
|
|
60
|
+
{' : '}
|
|
61
|
+
</Typography>
|
|
62
|
+
<Link
|
|
63
|
+
href={expirationNoticeLink}
|
|
64
|
+
rel="noreferrer"
|
|
65
|
+
target="_blank"
|
|
66
|
+
className="u-warning"
|
|
67
|
+
>
|
|
68
|
+
{new URL(expirationNoticeLink).hostname}
|
|
69
|
+
</Link>
|
|
70
|
+
</>
|
|
71
|
+
)}
|
|
72
|
+
</Typography>
|
|
73
|
+
</Alert>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
ExpirationAlert.propTypes = {
|
|
78
|
+
file: PropTypes.object.isRequired
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default withViewerLocales(ExpirationAlert)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
|
|
4
|
+
import { models } from 'cozy-client'
|
|
5
|
+
|
|
6
|
+
import Typography from '../../Typography'
|
|
7
|
+
import { useI18n } from '../../I18n'
|
|
8
|
+
import { formatLocallyDistanceToNow } from '../../I18n/format'
|
|
9
|
+
|
|
10
|
+
const { computeExpirationDate, isExpired } = models.paper
|
|
11
|
+
|
|
12
|
+
const ExpirationAnnotation = ({ file }) => {
|
|
13
|
+
const { t } = useI18n()
|
|
14
|
+
|
|
15
|
+
if (isExpired(file)) {
|
|
16
|
+
return (
|
|
17
|
+
<Typography component="span" variant="inherit" color="error">
|
|
18
|
+
{t('Viewer.panel.qualification.expired')}
|
|
19
|
+
</Typography>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const expirationDate = computeExpirationDate(file)
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Typography component="span" variant="inherit" className="u-warning">
|
|
27
|
+
{t('Viewer.panel.qualification.expiresIn', {
|
|
28
|
+
duration: formatLocallyDistanceToNow(expirationDate)
|
|
29
|
+
})}
|
|
30
|
+
</Typography>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ExpirationAnnotation.propTypes = {
|
|
35
|
+
file: PropTypes.object.isRequired
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default ExpirationAnnotation
|
|
@@ -72,7 +72,13 @@
|
|
|
72
72
|
"copy": "Copy",
|
|
73
73
|
"copyClipboard": "Copy to clipboard",
|
|
74
74
|
"edit": "Edit"
|
|
75
|
-
}
|
|
75
|
+
},
|
|
76
|
+
"expired": "Expired",
|
|
77
|
+
"expiresIn": "Expires in %{duration}"
|
|
78
|
+
},
|
|
79
|
+
"expiration": {
|
|
80
|
+
"description": "This document will expire in %{duration}, consider renewing it",
|
|
81
|
+
"dismiss": "I understood"
|
|
76
82
|
},
|
|
77
83
|
"title": "Useful information"
|
|
78
84
|
},
|
|
@@ -72,7 +72,13 @@
|
|
|
72
72
|
"copy": "Copier",
|
|
73
73
|
"copyClipboard": "Copier dans le presse-papier",
|
|
74
74
|
"edit": "Modifier"
|
|
75
|
-
}
|
|
75
|
+
},
|
|
76
|
+
"expired": "Expiré",
|
|
77
|
+
"expiresIn": "Expire dans %{duration}"
|
|
78
|
+
},
|
|
79
|
+
"expiration": {
|
|
80
|
+
"description": "Ce document expirera dans %{duration}, pensez à le renouveler",
|
|
81
|
+
"dismiss": "J'ai compris"
|
|
76
82
|
},
|
|
77
83
|
"title": "Informations utiles"
|
|
78
84
|
},
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { useRef, useState, createRef, useMemo, useEffect } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
+
import { models } from 'cozy-client';
|
|
4
5
|
import List from "cozy-ui/transpiled/react/MuiCozyTheme/List";
|
|
5
6
|
import { withViewerLocales } from "cozy-ui/transpiled/react/Viewer/hoc/withViewerLocales";
|
|
6
7
|
import { formatMetadataQualification, knownDateMetadataNames, knownInformationMetadataNames, knownOtherMetadataNames } from "cozy-ui/transpiled/react/Viewer/helpers";
|
|
8
|
+
import ExpirationAlert from "cozy-ui/transpiled/react/Viewer/components/ExpirationAlert";
|
|
7
9
|
import QualificationListItemContact from "cozy-ui/transpiled/react/Viewer/Panel/QualificationListItemContact";
|
|
8
10
|
import ActionMenuWrapper from "cozy-ui/transpiled/react/Viewer/Panel/ActionMenuWrapper";
|
|
9
11
|
import QualificationListItemDate from "cozy-ui/transpiled/react/Viewer/Panel/QualificationListItemDate";
|
|
10
12
|
import QualificationListItemInformation from "cozy-ui/transpiled/react/Viewer/Panel/QualificationListItemInformation";
|
|
11
13
|
import QualificationListItemOther from "cozy-ui/transpiled/react/Viewer/Panel/QualificationListItemOther";
|
|
14
|
+
var isExpiringSoon = models.paper.isExpiringSoon;
|
|
12
15
|
|
|
13
16
|
var makeQualificationListItemComp = function makeQualificationListItemComp(metadataName) {
|
|
14
17
|
if (knownDateMetadataNames.includes(metadataName)) {
|
|
@@ -28,11 +31,16 @@ var makeQualificationListItemComp = function makeQualificationListItemComp(metad
|
|
|
28
31
|
}
|
|
29
32
|
};
|
|
30
33
|
|
|
34
|
+
var isExpirationAlertHidden = function isExpirationAlertHidden(file) {
|
|
35
|
+
var _file$metadata$hideEx, _file$metadata;
|
|
36
|
+
|
|
37
|
+
return (_file$metadata$hideEx = file === null || file === void 0 ? void 0 : (_file$metadata = file.metadata) === null || _file$metadata === void 0 ? void 0 : _file$metadata.hideExpirationAlert) !== null && _file$metadata$hideEx !== void 0 ? _file$metadata$hideEx : false;
|
|
38
|
+
};
|
|
39
|
+
|
|
31
40
|
var Qualification = function Qualification(_ref) {
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
metadata = _file$metadata === void 0 ? {} : _file$metadata;
|
|
41
|
+
var file = _ref.file;
|
|
42
|
+
var _file$metadata2 = file.metadata,
|
|
43
|
+
metadata = _file$metadata2 === void 0 ? {} : _file$metadata2;
|
|
36
44
|
var actionBtnRef = useRef([]);
|
|
37
45
|
|
|
38
46
|
var _useState = useState({
|
|
@@ -77,7 +85,9 @@ var Qualification = function Qualification(_ref) {
|
|
|
77
85
|
return (_actionBtnRef$current = actionBtnRef.current[idx]) !== null && _actionBtnRef$current !== void 0 ? _actionBtnRef$current : /*#__PURE__*/createRef();
|
|
78
86
|
});
|
|
79
87
|
}, [formatedMetadataQualification]);
|
|
80
|
-
return /*#__PURE__*/React.createElement(
|
|
88
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isExpiringSoon(file) && !isExpirationAlertHidden(file) && /*#__PURE__*/React.createElement(ExpirationAlert, {
|
|
89
|
+
file: file
|
|
90
|
+
}), /*#__PURE__*/React.createElement(List, {
|
|
81
91
|
className: 'u-pv-1'
|
|
82
92
|
}, formatedMetadataQualification.map(function (meta, idx) {
|
|
83
93
|
var name = meta.name;
|
|
@@ -96,10 +106,10 @@ var Qualification = function Qualification(_ref) {
|
|
|
96
106
|
file: file,
|
|
97
107
|
optionFile: optionFile,
|
|
98
108
|
ref: actionBtnRef.current[optionFile.id]
|
|
99
|
-
}));
|
|
109
|
+
})));
|
|
100
110
|
};
|
|
101
111
|
|
|
102
112
|
Qualification.propTypes = {
|
|
103
|
-
file: PropTypes.object
|
|
113
|
+
file: PropTypes.object.isRequired
|
|
104
114
|
};
|
|
105
115
|
export default withViewerLocales(Qualification);
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import { models } from 'cozy-client';
|
|
3
4
|
import ListItem from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem";
|
|
4
5
|
import ListItemSecondaryAction from "cozy-ui/transpiled/react/MuiCozyTheme/ListItemSecondaryAction";
|
|
5
6
|
import IconButton from "cozy-ui/transpiled/react/IconButton";
|
|
6
7
|
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
7
8
|
import Dots from "cozy-ui/transpiled/react/Icons/Dots";
|
|
9
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
10
|
+
import ExpirationAnnotation from "cozy-ui/transpiled/react/Viewer/components/ExpirationAnnotation";
|
|
8
11
|
import QualificationListItemText from "cozy-ui/transpiled/react/Viewer/Panel/QualificationListItemText";
|
|
9
12
|
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
10
13
|
import { formatDate } from "cozy-ui/transpiled/react/Viewer/helpers";
|
|
14
|
+
var _models$paper = models.paper,
|
|
15
|
+
isExpired = _models$paper.isExpired,
|
|
16
|
+
isExpiringSoon = _models$paper.isExpiringSoon;
|
|
11
17
|
var QualificationListItemDate = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
12
|
-
var
|
|
18
|
+
var file = _ref.file,
|
|
19
|
+
formatedMetadataQualification = _ref.formatedMetadataQualification,
|
|
13
20
|
toggleActionsMenu = _ref.toggleActionsMenu;
|
|
14
21
|
|
|
15
22
|
var _useI18n = useI18n(),
|
|
@@ -28,7 +35,15 @@ var QualificationListItemDate = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
28
35
|
className: 'u-pl-2 u-pr-3'
|
|
29
36
|
}, /*#__PURE__*/React.createElement(QualificationListItemText, {
|
|
30
37
|
primary: t("Viewer.panel.qualification.date.title.".concat(name)),
|
|
31
|
-
secondary:
|
|
38
|
+
secondary: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
|
|
39
|
+
component: "span",
|
|
40
|
+
variant: "inherit"
|
|
41
|
+
}, formattedDate), (isExpired(file) || isExpiringSoon(file)) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
|
|
42
|
+
component: "span",
|
|
43
|
+
variant: "inherit"
|
|
44
|
+
}, ' · '), /*#__PURE__*/React.createElement(ExpirationAnnotation, {
|
|
45
|
+
file: file
|
|
46
|
+
}))),
|
|
32
47
|
disabled: !value
|
|
33
48
|
}), /*#__PURE__*/React.createElement(ListItemSecondaryAction, null, /*#__PURE__*/React.createElement(IconButton, {
|
|
34
49
|
ref: ref,
|
|
@@ -41,6 +56,7 @@ var QualificationListItemDate = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
41
56
|
});
|
|
42
57
|
QualificationListItemDate.displayName = 'QualificationListItemDate';
|
|
43
58
|
QualificationListItemDate.propTypes = {
|
|
59
|
+
file: PropTypes.object.isRequired,
|
|
44
60
|
formatedMetadataQualification: PropTypes.shape({
|
|
45
61
|
name: PropTypes.string,
|
|
46
62
|
value: PropTypes.string
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
|
+
|
|
10
|
+
import React, { useState } from 'react';
|
|
11
|
+
import PropTypes from 'prop-types';
|
|
12
|
+
import { useClient, models } from 'cozy-client';
|
|
13
|
+
import Alert from "cozy-ui/transpiled/react/Alert";
|
|
14
|
+
import Button from "cozy-ui/transpiled/react/Buttons";
|
|
15
|
+
import Link from "cozy-ui/transpiled/react/Link";
|
|
16
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
17
|
+
import { withViewerLocales } from "cozy-ui/transpiled/react/Viewer/hoc/withViewerLocales";
|
|
18
|
+
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
19
|
+
import { formatLocallyDistanceToNow } from "cozy-ui/transpiled/react/I18n/format";
|
|
20
|
+
var FILES_DOCTYPE = 'io.cozy.files';
|
|
21
|
+
var _models$paper = models.paper,
|
|
22
|
+
computeExpirationDate = _models$paper.computeExpirationDate,
|
|
23
|
+
computeExpirationNoticeLink = _models$paper.computeExpirationNoticeLink;
|
|
24
|
+
|
|
25
|
+
var ExpirationAlert = function ExpirationAlert(_ref) {
|
|
26
|
+
var file = _ref.file;
|
|
27
|
+
|
|
28
|
+
var _useI18n = useI18n(),
|
|
29
|
+
t = _useI18n.t;
|
|
30
|
+
|
|
31
|
+
var client = useClient();
|
|
32
|
+
|
|
33
|
+
var _useState = useState(false),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
isBusy = _useState2[0],
|
|
36
|
+
setIsBusy = _useState2[1];
|
|
37
|
+
|
|
38
|
+
var handleClose = /*#__PURE__*/function () {
|
|
39
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
40
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
41
|
+
while (1) {
|
|
42
|
+
switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
setIsBusy(true);
|
|
45
|
+
_context.next = 3;
|
|
46
|
+
return client.collection(FILES_DOCTYPE).updateMetadataAttribute(file.id, _objectSpread(_objectSpread({}, file.metadata), {}, {
|
|
47
|
+
hideExpirationAlert: true
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
case 3:
|
|
51
|
+
setIsBusy(false);
|
|
52
|
+
|
|
53
|
+
case 4:
|
|
54
|
+
case "end":
|
|
55
|
+
return _context.stop();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, _callee);
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
return function handleClose() {
|
|
62
|
+
return _ref2.apply(this, arguments);
|
|
63
|
+
};
|
|
64
|
+
}();
|
|
65
|
+
|
|
66
|
+
var expirationDate = computeExpirationDate(file);
|
|
67
|
+
var expirationNoticeLink = computeExpirationNoticeLink(file);
|
|
68
|
+
return /*#__PURE__*/React.createElement(Alert, {
|
|
69
|
+
severity: "warning",
|
|
70
|
+
block: true,
|
|
71
|
+
action: /*#__PURE__*/React.createElement(Button, {
|
|
72
|
+
color: "warning",
|
|
73
|
+
variant: "text",
|
|
74
|
+
size: "small",
|
|
75
|
+
busy: isBusy,
|
|
76
|
+
label: t('Viewer.panel.expiration.dismiss'),
|
|
77
|
+
onClick: handleClose
|
|
78
|
+
}),
|
|
79
|
+
className: "u-mt-1 u-mh-1"
|
|
80
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
81
|
+
component: "span",
|
|
82
|
+
variant: "inherit"
|
|
83
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
84
|
+
component: "span",
|
|
85
|
+
variant: "inherit"
|
|
86
|
+
}, t('Viewer.panel.expiration.description', {
|
|
87
|
+
duration: formatLocallyDistanceToNow(expirationDate)
|
|
88
|
+
})), expirationNoticeLink && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
|
|
89
|
+
component: "span",
|
|
90
|
+
variant: "inherit"
|
|
91
|
+
}, ' : '), /*#__PURE__*/React.createElement(Link, {
|
|
92
|
+
href: expirationNoticeLink,
|
|
93
|
+
rel: "noreferrer",
|
|
94
|
+
target: "_blank",
|
|
95
|
+
className: "u-warning"
|
|
96
|
+
}, new URL(expirationNoticeLink).hostname))));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
ExpirationAlert.propTypes = {
|
|
100
|
+
file: PropTypes.object.isRequired
|
|
101
|
+
};
|
|
102
|
+
export default withViewerLocales(ExpirationAlert);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { models } from 'cozy-client';
|
|
4
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
5
|
+
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
6
|
+
import { formatLocallyDistanceToNow } from "cozy-ui/transpiled/react/I18n/format";
|
|
7
|
+
var _models$paper = models.paper,
|
|
8
|
+
computeExpirationDate = _models$paper.computeExpirationDate,
|
|
9
|
+
isExpired = _models$paper.isExpired;
|
|
10
|
+
|
|
11
|
+
var ExpirationAnnotation = function ExpirationAnnotation(_ref) {
|
|
12
|
+
var file = _ref.file;
|
|
13
|
+
|
|
14
|
+
var _useI18n = useI18n(),
|
|
15
|
+
t = _useI18n.t;
|
|
16
|
+
|
|
17
|
+
if (isExpired(file)) {
|
|
18
|
+
return /*#__PURE__*/React.createElement(Typography, {
|
|
19
|
+
component: "span",
|
|
20
|
+
variant: "inherit",
|
|
21
|
+
color: "error"
|
|
22
|
+
}, t('Viewer.panel.qualification.expired'));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var expirationDate = computeExpirationDate(file);
|
|
26
|
+
return /*#__PURE__*/React.createElement(Typography, {
|
|
27
|
+
component: "span",
|
|
28
|
+
variant: "inherit",
|
|
29
|
+
className: "u-warning"
|
|
30
|
+
}, t('Viewer.panel.qualification.expiresIn', {
|
|
31
|
+
duration: formatLocallyDistanceToNow(expirationDate)
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
ExpirationAnnotation.propTypes = {
|
|
36
|
+
file: PropTypes.object.isRequired
|
|
37
|
+
};
|
|
38
|
+
export default ExpirationAnnotation;
|
|
@@ -73,7 +73,13 @@ var en = {
|
|
|
73
73
|
copy: "Copy",
|
|
74
74
|
copyClipboard: "Copy to clipboard",
|
|
75
75
|
edit: "Edit"
|
|
76
|
-
}
|
|
76
|
+
},
|
|
77
|
+
expired: "Expired",
|
|
78
|
+
expiresIn: "Expires in %{duration}"
|
|
79
|
+
},
|
|
80
|
+
expiration: {
|
|
81
|
+
description: "This document will expire in %{duration}, consider renewing it",
|
|
82
|
+
dismiss: "I understood"
|
|
77
83
|
},
|
|
78
84
|
title: "Useful information"
|
|
79
85
|
},
|
|
@@ -169,7 +175,13 @@ var fr = {
|
|
|
169
175
|
copy: "Copier",
|
|
170
176
|
copyClipboard: "Copier dans le presse-papier",
|
|
171
177
|
edit: "Modifier"
|
|
172
|
-
}
|
|
178
|
+
},
|
|
179
|
+
expired: "Expir\xE9",
|
|
180
|
+
expiresIn: "Expire dans %{duration}"
|
|
181
|
+
},
|
|
182
|
+
expiration: {
|
|
183
|
+
description: "Ce document expirera dans %{duration}, pensez \xE0 le renouveler",
|
|
184
|
+
dismiss: "J'ai compris"
|
|
173
185
|
},
|
|
174
186
|
title: "Informations utiles"
|
|
175
187
|
},
|