cozy-ui 110.8.1 → 111.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 +20 -0
- package/jest.config.js +3 -1
- package/package.json +3 -3
- package/react/Viewer/components/ExpirationAlert.jsx +10 -8
- package/react/Viewer/components/ViewerControls.jsx +2 -2
- package/react/Viewer/components/ViewerControls.spec.jsx +54 -0
- package/transpiled/react/Viewer/components/ExpirationAlert.js +3 -6
- package/transpiled/react/Viewer/components/ViewerControls.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# [111.0.0](https://github.com/cozy/cozy-ui/compare/v110.8.2...v111.0.0) (2024-07-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **ExpirationAlert:** Do not display expiration link for foreign file ([dfeaa6e](https://github.com/cozy/cozy-ui/commit/dfeaa6e))
|
|
7
|
+
* Upgrade cozy-client to 48.8.0 ([03dbc6a](https://github.com/cozy/cozy-ui/commit/03dbc6a))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### BREAKING CHANGES
|
|
11
|
+
|
|
12
|
+
* you must have `cozy-client >= 48.8.0`
|
|
13
|
+
|
|
14
|
+
## [110.8.2](https://github.com/cozy/cozy-ui/compare/v110.8.1...v110.8.2) (2024-07-11)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **ViewerControls:** children can contain undefined values ([506fd4c](https://github.com/cozy/cozy-ui/commit/506fd4c))
|
|
20
|
+
|
|
1
21
|
## [110.8.1](https://github.com/cozy/cozy-ui/compare/v110.8.0...v110.8.1) (2024-07-10)
|
|
2
22
|
|
|
3
23
|
|
package/jest.config.js
CHANGED
|
@@ -14,7 +14,9 @@ module.exports = {
|
|
|
14
14
|
'react-pdf/dist/esm/entry.webpack': 'react-pdf',
|
|
15
15
|
'^cozy-client$': 'cozy-client/dist/index'
|
|
16
16
|
},
|
|
17
|
-
transformIgnorePatterns: [
|
|
17
|
+
transformIgnorePatterns: [
|
|
18
|
+
'node_modules/(?!(react-styleguidist|cozy-harvest-lib)/)'
|
|
19
|
+
],
|
|
18
20
|
testPathIgnorePatterns: ['/node_modules/', '/transpiled/', '/dist/'],
|
|
19
21
|
transform: {
|
|
20
22
|
'^.+\\.(ts|tsx|js|jsx)?$': 'babel-jest'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "111.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": "^48.8.0",
|
|
94
94
|
"cozy-device-helper": "2.0.0",
|
|
95
95
|
"cozy-flags": "^2.10.1",
|
|
96
96
|
"cozy-harvest-lib": "^6.7.3",
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
"rooks": "^5.11.2"
|
|
181
181
|
},
|
|
182
182
|
"peerDependencies": {
|
|
183
|
-
"cozy-client": ">=
|
|
183
|
+
"cozy-client": ">=48.8.0",
|
|
184
184
|
"cozy-device-helper": "^2.0.0",
|
|
185
185
|
"cozy-harvest-lib": "^6.7.3",
|
|
186
186
|
"cozy-intent": ">=1.3.0",
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
|
-
import { useClient
|
|
4
|
+
import { useClient } from 'cozy-client'
|
|
5
|
+
import {
|
|
6
|
+
isForeignPaper,
|
|
7
|
+
computeExpirationDate,
|
|
8
|
+
computeExpirationNoticeLink,
|
|
9
|
+
makeExpirationDescription
|
|
10
|
+
} from 'cozy-client/dist/models/paper'
|
|
5
11
|
|
|
6
12
|
import Alert from '../../Alert'
|
|
7
13
|
import Button from '../../Buttons'
|
|
@@ -12,12 +18,6 @@ import { useI18n } from '../../providers/I18n'
|
|
|
12
18
|
|
|
13
19
|
const FILES_DOCTYPE = 'io.cozy.files'
|
|
14
20
|
|
|
15
|
-
const {
|
|
16
|
-
computeExpirationDate,
|
|
17
|
-
computeExpirationNoticeLink,
|
|
18
|
-
makeExpirationDescription
|
|
19
|
-
} = models.paper
|
|
20
|
-
|
|
21
21
|
const ExpirationAlert = ({ file }) => {
|
|
22
22
|
const { t, lang } = useI18n()
|
|
23
23
|
const client = useClient()
|
|
@@ -33,7 +33,9 @@ const ExpirationAlert = ({ file }) => {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const expirationDate = computeExpirationDate(file)
|
|
36
|
-
const expirationNoticeLink =
|
|
36
|
+
const expirationNoticeLink = !isForeignPaper(file)
|
|
37
|
+
? computeExpirationNoticeLink(file)
|
|
38
|
+
: null
|
|
37
39
|
|
|
38
40
|
return (
|
|
39
41
|
<Alert
|
|
@@ -95,8 +95,8 @@ class ViewerControls extends Component {
|
|
|
95
95
|
|
|
96
96
|
return React.Children.map(children, child => {
|
|
97
97
|
if (
|
|
98
|
-
child
|
|
99
|
-
child
|
|
98
|
+
child?.type?.name === 'ViewerByFile' ||
|
|
99
|
+
child?.type?.displayName === 'ViewerByFile'
|
|
100
100
|
) {
|
|
101
101
|
return React.cloneElement(child, {
|
|
102
102
|
gestures: this.state.gestures,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render, screen } from '@testing-library/react'
|
|
3
|
+
|
|
4
|
+
import ViewerControls from './ViewerControls'
|
|
5
|
+
import ViewerByFile from './ViewerByFile'
|
|
6
|
+
|
|
7
|
+
jest.mock('../ViewersByFile/AudioViewer', () => () => <div>AudioViewer</div>)
|
|
8
|
+
jest.mock('../providers/EncryptedProvider', () => ({
|
|
9
|
+
useEncrypted: () => ({ url: 'random' })
|
|
10
|
+
}))
|
|
11
|
+
|
|
12
|
+
describe('ViewerControls', () => {
|
|
13
|
+
const file = {
|
|
14
|
+
_id: 'audio',
|
|
15
|
+
class: 'audio',
|
|
16
|
+
mime: 'audio/mp3',
|
|
17
|
+
name: 'sample.mp3'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const setup = ({ children } = {}) => {
|
|
21
|
+
render(
|
|
22
|
+
<ViewerControls
|
|
23
|
+
file={file}
|
|
24
|
+
onClose={() => {}}
|
|
25
|
+
hasPrevious={false}
|
|
26
|
+
hasNext={false}
|
|
27
|
+
onPrevious={() => {}}
|
|
28
|
+
onNext={() => {}}
|
|
29
|
+
expanded={false}
|
|
30
|
+
toolbarProps={{
|
|
31
|
+
showToolbar: false,
|
|
32
|
+
showClose: false,
|
|
33
|
+
showFilePath: false,
|
|
34
|
+
toolbarRef: undefined
|
|
35
|
+
}}
|
|
36
|
+
showNavigation={false}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</ViewerControls>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
it('should only render children if they are ViewerByFile', () => {
|
|
44
|
+
setup({
|
|
45
|
+
children: [
|
|
46
|
+
undefined,
|
|
47
|
+
<div key="notViewer">not ViewerByFile</div>,
|
|
48
|
+
<ViewerByFile key="viewer" file={file} onClose={() => {}} />
|
|
49
|
+
]
|
|
50
|
+
})
|
|
51
|
+
expect(screen.queryByText('not ViewerByFile')).not.toBeInTheDocument()
|
|
52
|
+
expect(screen.getByText('AudioViewer')).toBeInTheDocument()
|
|
53
|
+
})
|
|
54
|
+
})
|
|
@@ -9,7 +9,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
9
9
|
|
|
10
10
|
import React, { useState } from 'react';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
|
-
import { useClient
|
|
12
|
+
import { useClient } from 'cozy-client';
|
|
13
|
+
import { isForeignPaper, computeExpirationDate, computeExpirationNoticeLink, makeExpirationDescription } from 'cozy-client/dist/models/paper';
|
|
13
14
|
import Alert from "cozy-ui/transpiled/react/Alert";
|
|
14
15
|
import Button from "cozy-ui/transpiled/react/Buttons";
|
|
15
16
|
import Link from "cozy-ui/transpiled/react/Link";
|
|
@@ -17,10 +18,6 @@ import Typography from "cozy-ui/transpiled/react/Typography";
|
|
|
17
18
|
import { withViewerLocales } from "cozy-ui/transpiled/react/Viewer/hoc/withViewerLocales";
|
|
18
19
|
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
19
20
|
var FILES_DOCTYPE = 'io.cozy.files';
|
|
20
|
-
var _models$paper = models.paper,
|
|
21
|
-
computeExpirationDate = _models$paper.computeExpirationDate,
|
|
22
|
-
computeExpirationNoticeLink = _models$paper.computeExpirationNoticeLink,
|
|
23
|
-
makeExpirationDescription = _models$paper.makeExpirationDescription;
|
|
24
21
|
|
|
25
22
|
var ExpirationAlert = function ExpirationAlert(_ref) {
|
|
26
23
|
var file = _ref.file;
|
|
@@ -65,7 +62,7 @@ var ExpirationAlert = function ExpirationAlert(_ref) {
|
|
|
65
62
|
}();
|
|
66
63
|
|
|
67
64
|
var expirationDate = computeExpirationDate(file);
|
|
68
|
-
var expirationNoticeLink = computeExpirationNoticeLink(file);
|
|
65
|
+
var expirationNoticeLink = !isForeignPaper(file) ? computeExpirationNoticeLink(file) : null;
|
|
69
66
|
return /*#__PURE__*/React.createElement(Alert, {
|
|
70
67
|
severity: "warning",
|
|
71
68
|
block: true,
|
|
@@ -141,7 +141,9 @@ var ViewerControls = /*#__PURE__*/function (_Component) {
|
|
|
141
141
|
|
|
142
142
|
if (!children) return null;
|
|
143
143
|
return React.Children.map(children, function (child) {
|
|
144
|
-
|
|
144
|
+
var _child$type, _child$type2;
|
|
145
|
+
|
|
146
|
+
if ((child === null || child === void 0 ? void 0 : (_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.name) === 'ViewerByFile' || (child === null || child === void 0 ? void 0 : (_child$type2 = child.type) === null || _child$type2 === void 0 ? void 0 : _child$type2.displayName) === 'ViewerByFile') {
|
|
145
147
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
146
148
|
gestures: _this2.state.gestures,
|
|
147
149
|
gesturesRef: _this2.wrapped,
|