cozy-ui 75.4.0 → 75.5.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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [75.5.0](https://github.com/cozy/cozy-ui/compare/v75.4.1...v75.5.0) (2022-09-29)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Viewer:** Add new condition for isEditableAttribute helper ([af99054](https://github.com/cozy/cozy-ui/commit/af99054))
7
+
8
+ ## [75.4.1](https://github.com/cozy/cozy-ui/compare/v75.4.0...v75.4.1) (2022-09-27)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Rename componentWill* to UNSAFE_componentWill* ([10b5fba](https://github.com/cozy/cozy-ui/commit/10b5fba))
14
+
1
15
  # [75.4.0](https://github.com/cozy/cozy-ui/compare/v75.3.0...v75.4.0) (2022-09-26)
2
16
 
3
17
 
package/CODEOWNERS CHANGED
@@ -1,2 +1,2 @@
1
1
  # General code owners
2
- * @JF-Cozy @Merkur39 @trollepierre @Ldoppea
2
+ * @JF-Cozy @Merkur39 @Ldoppea
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "75.4.0",
3
+ "version": "75.5.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -6,19 +6,18 @@ import { useAppLinkWithStoreFallback, useClient } from 'cozy-client'
6
6
  import useBreakpoints from '../../hooks/useBreakpoints'
7
7
  import { useI18n } from '../../I18n'
8
8
  import useViewerSnackbar from '../providers/ViewerSnackbarProvider'
9
- import { buildEditAttributePath, getCurrentModel } from '../helpers'
9
+ import {
10
+ buildEditAttributePath,
11
+ isEditableAttribute,
12
+ getCurrentModel
13
+ } from '../helpers'
10
14
  import useActionMenuContext from '../providers/ActionMenuProvider'
11
15
  import ActionMenuMobile from './ActionMenuMobile'
12
16
  import ActionMenuDesktop from './ActionMenuDesktop'
13
17
 
14
18
  const mespapiersAppSlug = 'mespapiers'
15
19
 
16
- const checkEditableAttribute = name => {
17
- const isNotEditableAttributes = ['datetime', 'qualification']
18
- return !isNotEditableAttributes.includes(name)
19
- }
20
-
21
- const ActionMenuWrapper = forwardRef(({ onClose, optionFile }, ref) => {
20
+ const ActionMenuWrapper = forwardRef(({ onClose, file, optionFile }, ref) => {
22
21
  const { name, value } = optionFile
23
22
  const editPathByModelProps = useActionMenuContext()
24
23
  const { isMobile } = useBreakpoints()
@@ -26,7 +25,6 @@ const ActionMenuWrapper = forwardRef(({ onClose, optionFile }, ref) => {
26
25
  const { showViewerSnackbar } = useViewerSnackbar()
27
26
  const client = useClient()
28
27
 
29
- const isEditableAttribute = checkEditableAttribute(name)
30
28
  const currentModel = getCurrentModel(name)
31
29
  const editPath = buildEditAttributePath(
32
30
  editPathByModelProps,
@@ -65,7 +63,7 @@ const ActionMenuWrapper = forwardRef(({ onClose, optionFile }, ref) => {
65
63
  return (
66
64
  <ActionMenuMobile
67
65
  onClose={onClose}
68
- isEditable={Boolean(editPath) && isEditableAttribute}
66
+ isEditable={Boolean(editPath) && isEditableAttribute(name, file)}
69
67
  actions={{ handleCopy, handleEdit }}
70
68
  appLink={url}
71
69
  appSlug={mespapiersAppSlug}
@@ -77,7 +75,7 @@ const ActionMenuWrapper = forwardRef(({ onClose, optionFile }, ref) => {
77
75
  <ActionMenuDesktop
78
76
  ref={ref}
79
77
  onClose={onClose}
80
- isEditable={Boolean(editPath) && isEditableAttribute}
78
+ isEditable={Boolean(editPath) && isEditableAttribute(name, file)}
81
79
  actions={{ handleCopy, handleEdit }}
82
80
  appLink={url}
83
81
  appSlug={mespapiersAppSlug}
@@ -88,6 +86,7 @@ ActionMenuWrapper.displayName = 'ActionMenuWrapper'
88
86
 
89
87
  ActionMenuWrapper.propTypes = {
90
88
  onClose: PropTypes.func,
89
+ file: PropTypes.object,
91
90
  optionFile: PropTypes.shape({
92
91
  name: PropTypes.string,
93
92
  value: PropTypes.string
@@ -1,13 +1,11 @@
1
1
  import KonnectorBlock from 'cozy-harvest-lib/dist/components/KonnectorBlock'
2
+ import { models } from 'cozy-client'
2
3
 
3
- import {
4
- hasCertifications,
5
- hasQualifications,
6
- isFromKonnector
7
- } from '../helpers'
8
4
  import Certifications from './Certifications'
9
5
  import Qualification from './Qualification'
10
6
 
7
+ const { isFromKonnector, hasQualifications, hasCertifications } = models.file
8
+
11
9
  export const panelBlocksSpecs = {
12
10
  qualifications: {
13
11
  condition: hasQualifications,
@@ -27,7 +25,7 @@ const getPanelBlocks = ({ panelBlocksSpecs, file }) => {
27
25
  const panelBlocks = []
28
26
 
29
27
  Object.values(panelBlocksSpecs).forEach(panelBlock => {
30
- panelBlock.condition({ file }) && panelBlocks.push(panelBlock.component)
28
+ panelBlock.condition(file) && panelBlocks.push(panelBlock.component)
31
29
  })
32
30
 
33
31
  return panelBlocks
@@ -36,7 +36,7 @@ class ImageViewer extends Component {
36
36
  }
37
37
  }
38
38
 
39
- componentWillReceiveProps(nextProps) {
39
+ UNSAFE_componentWillReceiveProps(nextProps) {
40
40
  if (
41
41
  nextProps.file &&
42
42
  this.props.file &&
@@ -2,10 +2,11 @@ import React, { useMemo } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
 
4
4
  import { isMobile as isMobileDevice } from 'cozy-device-helper'
5
+ import { models } from 'cozy-client'
6
+
5
7
  import { FileDoctype } from '../../proptypes'
6
8
  import withBreakpoints from '../../helpers/withBreakpoints'
7
9
 
8
- import { isPlainText } from '../helpers'
9
10
  import ImageViewer from '../ViewersByFile/ImageViewer'
10
11
  import AudioViewer from '../ViewersByFile/AudioViewer'
11
12
  import VideoViewer from '../ViewersByFile/VideoViewer'
@@ -18,6 +19,8 @@ import OnlyOfficeViewer from '../ViewersByFile/OnlyOfficeViewer'
18
19
 
19
20
  import { useEncrypted } from '../providers/EncryptedProvider'
20
21
 
22
+ const { isPlainText } = models.file
23
+
21
24
  export const getViewerComponentName = ({
22
25
  file,
23
26
  isDesktop,
@@ -1,6 +1,10 @@
1
- import has from 'lodash/has'
2
1
  import { models } from 'cozy-client'
3
- const { isEncrypted } = models.file
2
+ const {
3
+ isEncrypted,
4
+ isFromKonnector,
5
+ hasQualifications,
6
+ hasCertifications
7
+ } = models.file
4
8
 
5
9
  export const knownDateMetadataNames = [
6
10
  'AObtentionDate',
@@ -41,25 +45,6 @@ export const getCurrentModel = metadataName => {
41
45
  * @property {string} type - doctype of the document
42
46
  */
43
47
 
44
- // TODO : should be in file model of cozy-client
45
- export const isPlainText = (mimeType = '', fileName = '') => {
46
- return mimeType ? /^text\//.test(mimeType) : /\.(txt|md)$/.test(fileName)
47
- }
48
-
49
- export const hasQualifications = ({ file }) => {
50
- return has(file, 'metadata.qualification')
51
- }
52
-
53
- export const hasCertifications = ({ file }) => {
54
- return (
55
- has(file, 'metadata.carbonCopy') || has(file, 'metadata.electronicSafe')
56
- )
57
- }
58
-
59
- export const isFromKonnector = ({ file }) => {
60
- return has(file, 'cozyMetadata.sourceAccount')
61
- }
62
-
63
48
  /**
64
49
  * Checks if the file matches one of the following conditions:
65
50
  * - Is certified
@@ -72,9 +57,7 @@ export const isFromKonnector = ({ file }) => {
72
57
  */
73
58
  export const isValidForPanel = ({ file }) => {
74
59
  return (
75
- hasCertifications({ file }) ||
76
- hasQualifications({ file }) ||
77
- isFromKonnector({ file })
60
+ hasCertifications(file) || hasQualifications(file) || isFromKonnector(file)
78
61
  )
79
62
  }
80
63
 
@@ -165,3 +148,12 @@ export const buildEditAttributePath = (
165
148
  const currentPath = editPathByModelProps[currentModel]
166
149
  return currentPath?.replace(/__NAME__/, name) ?? ''
167
150
  }
151
+
152
+ export const isEditableAttribute = (name, file) => {
153
+ const isNotEditableAttributes = ['datetime', 'qualification']
154
+
155
+ return (
156
+ !isNotEditableAttributes.includes(name) &&
157
+ ((name === 'issueDate' && !isFromKonnector(file)) || name !== 'issueDate')
158
+ )
159
+ }
@@ -2,12 +2,12 @@ import { createMockClient } from 'cozy-client'
2
2
 
3
3
  import {
4
4
  downloadFile,
5
- isPlainText,
6
5
  formatMetadataQualification,
7
6
  getCurrentModel,
8
7
  buildEditAttributePath,
9
8
  knownDateMetadataNames,
10
- knownInformationMetadataNames
9
+ knownInformationMetadataNames,
10
+ isEditableAttribute
11
11
  } from './helpers'
12
12
 
13
13
  const fakeMetadata = {
@@ -50,50 +50,6 @@ const computedMetadata = [
50
50
  ]
51
51
 
52
52
  describe('helpers', () => {
53
- describe('isPlainText', () => {
54
- describe('using mime types', () => {
55
- it('should match mime types starting with "text/"', () => {
56
- expect(isPlainText('text/plain')).toBe(true)
57
- expect(isPlainText('text/markdown')).toBe(true)
58
- expect(isPlainText('application/text')).toBe(false)
59
- expect(isPlainText('something/text/else')).toBe(false)
60
- expect(isPlainText('text/vnd.cozy.note+markdown')).toBe(true)
61
- })
62
-
63
- it('should not match complex text formats', () => {
64
- expect(isPlainText('application/msword')).toBe(false)
65
- expect(isPlainText('application/vnd.oasis.opendocument.text')).toBe(
66
- false
67
- )
68
- expect(isPlainText('application/x-iwork-pages-sffpages')).toBe(false)
69
- })
70
-
71
- it('should not use the filename if a mime type is present', () => {
72
- expect(isPlainText('application/msword', 'iswearitstext.txt')).toBe(
73
- false
74
- )
75
- })
76
- })
77
-
78
- describe('using file names', () => {
79
- it('should match txt files', () => {
80
- expect(isPlainText(undefined, 'iswearitstext.txt')).toBe(true)
81
- })
82
-
83
- it('should match md files', () => {
84
- expect(isPlainText(undefined, 'markdown.md')).toBe(true)
85
- })
86
-
87
- it('should not match anything else', () => {
88
- expect(isPlainText(undefined, 'file.doc')).toBe(false)
89
- expect(isPlainText(undefined, 'file.docx')).toBe(false)
90
- expect(isPlainText(undefined, 'file.pages')).toBe(false)
91
- expect(isPlainText(undefined, 'file.odt')).toBe(false)
92
- expect(isPlainText(undefined, 'file.csv')).toBe(false)
93
- expect(isPlainText(undefined, 'file.vcf')).toBe(false)
94
- })
95
- })
96
- })
97
53
  describe('download', () => {
98
54
  const client = new createMockClient({})
99
55
  const mockDownload = jest.fn()
@@ -156,4 +112,53 @@ describe('helpers', () => {
156
112
  expect(buildPagePath).toBe('#/paper/edit/page/01?backgroundPath=/path')
157
113
  })
158
114
  })
115
+ describe('isEditableAttribute', () => {
116
+ const makeFile = ({ fromConnector } = {}) => ({
117
+ _id: '00',
118
+ name: 'file',
119
+ cozyMetadata: fromConnector ? { sourceAccount: '123' } : {}
120
+ })
121
+ describe('file provided by a Connector', () => {
122
+ it('"issueDate" should not be a editable attribute', () => {
123
+ const issueDate = isEditableAttribute(
124
+ 'issueDate',
125
+ makeFile({ fromConnector: true })
126
+ )
127
+ expect(issueDate).toBe(false)
128
+ })
129
+ it('"cardNumber" should be an editable attribute', () => {
130
+ const cardNumber = isEditableAttribute(
131
+ 'cardNumber',
132
+ makeFile({ fromConnector: true })
133
+ )
134
+ expect(cardNumber).toBe(true)
135
+ })
136
+ it('"datetime" should not be an editable attribute', () => {
137
+ const datetime = isEditableAttribute('datetime', makeFile())
138
+ expect(datetime).toBe(false)
139
+ })
140
+ it('"qualification" should not be an editable attribute', () => {
141
+ const qualification = isEditableAttribute('qualification', makeFile())
142
+ expect(qualification).toBe(false)
143
+ })
144
+ })
145
+ describe('file NOT provided by a Connector', () => {
146
+ it('"issueDate" should not be a editable attribute', () => {
147
+ const issueDate = isEditableAttribute('issueDate', makeFile())
148
+ expect(issueDate).toBe(true)
149
+ })
150
+ it('"cardNumber" should be a editable attribute', () => {
151
+ const cardNumber = isEditableAttribute('cardNumber', makeFile())
152
+ expect(cardNumber).toBe(true)
153
+ })
154
+ it('"datetime" should not be an editable attribute', () => {
155
+ const datetime = isEditableAttribute('datetime', makeFile())
156
+ expect(datetime).toBe(false)
157
+ })
158
+ it('"qualification" should not be an editable attribute', () => {
159
+ const qualification = isEditableAttribute('qualification', makeFile())
160
+ expect(qualification).toBe(false)
161
+ })
162
+ })
163
+ })
159
164
  })
@@ -20,11 +20,11 @@ const withFileUrl = BaseComponent =>
20
20
  static contextTypes = {
21
21
  client: PropTypes.object.isRequired
22
22
  }
23
- componentWillMount() {
23
+ UNSAFE_componentWillMount() {
24
24
  this.loadDownloadUrl()
25
25
  }
26
26
 
27
- componentWillReceiveProps(nextProps) {
27
+ UNSAFE_componentWillReceiveProps(nextProps) {
28
28
  if (
29
29
  nextProps.file.id !== this.props.file.id ||
30
30
  nextProps.url !== this.props.url
@@ -4,19 +4,14 @@ import { useAppLinkWithStoreFallback, useClient } from 'cozy-client';
4
4
  import useBreakpoints from "cozy-ui/transpiled/react/hooks/useBreakpoints";
5
5
  import { useI18n } from "cozy-ui/transpiled/react/I18n";
6
6
  import useViewerSnackbar from "cozy-ui/transpiled/react/Viewer/providers/ViewerSnackbarProvider";
7
- import { buildEditAttributePath, getCurrentModel } from "cozy-ui/transpiled/react/Viewer/helpers";
7
+ import { buildEditAttributePath, isEditableAttribute, getCurrentModel } from "cozy-ui/transpiled/react/Viewer/helpers";
8
8
  import useActionMenuContext from "cozy-ui/transpiled/react/Viewer/providers/ActionMenuProvider";
9
9
  import ActionMenuMobile from "cozy-ui/transpiled/react/Viewer/Panel/ActionMenuMobile";
10
10
  import ActionMenuDesktop from "cozy-ui/transpiled/react/Viewer/Panel/ActionMenuDesktop";
11
11
  var mespapiersAppSlug = 'mespapiers';
12
-
13
- var checkEditableAttribute = function checkEditableAttribute(name) {
14
- var isNotEditableAttributes = ['datetime', 'qualification'];
15
- return !isNotEditableAttributes.includes(name);
16
- };
17
-
18
12
  var ActionMenuWrapper = /*#__PURE__*/forwardRef(function (_ref, ref) {
19
13
  var onClose = _ref.onClose,
14
+ file = _ref.file,
20
15
  optionFile = _ref.optionFile;
21
16
  var name = optionFile.name,
22
17
  value = optionFile.value;
@@ -32,7 +27,6 @@ var ActionMenuWrapper = /*#__PURE__*/forwardRef(function (_ref, ref) {
32
27
  showViewerSnackbar = _useViewerSnackbar.showViewerSnackbar;
33
28
 
34
29
  var client = useClient();
35
- var isEditableAttribute = checkEditableAttribute(name);
36
30
  var currentModel = getCurrentModel(name);
37
31
  var editPath = buildEditAttributePath(editPathByModelProps, currentModel, optionFile.name);
38
32
 
@@ -65,7 +59,7 @@ var ActionMenuWrapper = /*#__PURE__*/forwardRef(function (_ref, ref) {
65
59
  if (isMobile) {
66
60
  return /*#__PURE__*/React.createElement(ActionMenuMobile, {
67
61
  onClose: onClose,
68
- isEditable: Boolean(editPath) && isEditableAttribute,
62
+ isEditable: Boolean(editPath) && isEditableAttribute(name, file),
69
63
  actions: {
70
64
  handleCopy: handleCopy,
71
65
  handleEdit: handleEdit
@@ -78,7 +72,7 @@ var ActionMenuWrapper = /*#__PURE__*/forwardRef(function (_ref, ref) {
78
72
  return /*#__PURE__*/React.createElement(ActionMenuDesktop, {
79
73
  ref: ref,
80
74
  onClose: onClose,
81
- isEditable: Boolean(editPath) && isEditableAttribute,
75
+ isEditable: Boolean(editPath) && isEditableAttribute(name, file),
82
76
  actions: {
83
77
  handleCopy: handleCopy,
84
78
  handleEdit: handleEdit
@@ -90,6 +84,7 @@ var ActionMenuWrapper = /*#__PURE__*/forwardRef(function (_ref, ref) {
90
84
  ActionMenuWrapper.displayName = 'ActionMenuWrapper';
91
85
  ActionMenuWrapper.propTypes = {
92
86
  onClose: PropTypes.func,
87
+ file: PropTypes.object,
93
88
  optionFile: PropTypes.shape({
94
89
  name: PropTypes.string,
95
90
  value: PropTypes.string
@@ -1,7 +1,11 @@
1
1
  import KonnectorBlock from 'cozy-harvest-lib/dist/components/KonnectorBlock';
2
- import { hasCertifications, hasQualifications, isFromKonnector } from "cozy-ui/transpiled/react/Viewer/helpers";
2
+ import { models } from 'cozy-client';
3
3
  import Certifications from "cozy-ui/transpiled/react/Viewer/Panel/Certifications";
4
4
  import Qualification from "cozy-ui/transpiled/react/Viewer/Panel/Qualification";
5
+ var _models$file = models.file,
6
+ isFromKonnector = _models$file.isFromKonnector,
7
+ hasQualifications = _models$file.hasQualifications,
8
+ hasCertifications = _models$file.hasCertifications;
5
9
  export var panelBlocksSpecs = {
6
10
  qualifications: {
7
11
  condition: hasQualifications,
@@ -22,9 +26,7 @@ var getPanelBlocks = function getPanelBlocks(_ref) {
22
26
  file = _ref.file;
23
27
  var panelBlocks = [];
24
28
  Object.values(panelBlocksSpecs).forEach(function (panelBlock) {
25
- panelBlock.condition({
26
- file: file
27
- }) && panelBlocks.push(panelBlock.component);
29
+ panelBlock.condition(file) && panelBlocks.push(panelBlock.component);
28
30
  });
29
31
  return panelBlocks;
30
32
  };
@@ -116,8 +116,8 @@ var ImageViewer = /*#__PURE__*/function (_Component) {
116
116
  }
117
117
 
118
118
  _createClass(ImageViewer, [{
119
- key: "componentWillReceiveProps",
120
- value: function componentWillReceiveProps(nextProps) {
119
+ key: "UNSAFE_componentWillReceiveProps",
120
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
121
121
  if (nextProps.file && this.props.file && nextProps.file.id !== this.props.file.id) {
122
122
  this.tearDownGestures();
123
123
  this.setState({
@@ -1,9 +1,9 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { isMobile as isMobileDevice } from 'cozy-device-helper';
4
+ import { models } from 'cozy-client';
4
5
  import { FileDoctype } from "cozy-ui/transpiled/react/proptypes";
5
6
  import withBreakpoints from "cozy-ui/transpiled/react/helpers/withBreakpoints";
6
- import { isPlainText } from "cozy-ui/transpiled/react/Viewer/helpers";
7
7
  import ImageViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/ImageViewer";
8
8
  import AudioViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/AudioViewer";
9
9
  import VideoViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/VideoViewer";
@@ -14,6 +14,7 @@ import NoViewer from "cozy-ui/transpiled/react/Viewer/NoViewer";
14
14
  import ShortcutViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/ShortcutViewer";
15
15
  import OnlyOfficeViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/OnlyOfficeViewer";
16
16
  import { useEncrypted } from "cozy-ui/transpiled/react/Viewer/providers/EncryptedProvider";
17
+ var isPlainText = models.file.isPlainText;
17
18
  export var getViewerComponentName = function getViewerComponentName(_ref) {
18
19
  var file = _ref.file,
19
20
  isDesktop = _ref.isDesktop,
@@ -1,9 +1,12 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- import has from 'lodash/has';
5
4
  import { models } from 'cozy-client';
6
- var isEncrypted = models.file.isEncrypted;
5
+ var _models$file = models.file,
6
+ isEncrypted = _models$file.isEncrypted,
7
+ isFromKonnector = _models$file.isFromKonnector,
8
+ hasQualifications = _models$file.hasQualifications,
9
+ hasCertifications = _models$file.hasCertifications;
7
10
  export var knownDateMetadataNames = ['AObtentionDate', 'BObtentionDate', 'CObtentionDate', 'DObtentionDate', 'obtentionDate', 'expirationDate', 'referencedDate', 'issueDate', 'shootingDate', 'date', 'datetime'];
8
11
  export var knownInformationMetadataNames = ['number', 'cardNumber', 'vinNumber', 'ibanNumber', 'country'];
9
12
  export var knownOtherMetadataNames = ['contact', 'page', 'qualification'];
@@ -20,25 +23,7 @@ export var getCurrentModel = function getCurrentModel(metadataName) {
20
23
  * @property {string} id - id of the document
21
24
  * @property {string} type - doctype of the document
22
25
  */
23
- // TODO : should be in file model of cozy-client
24
26
 
25
- export var isPlainText = function isPlainText() {
26
- var mimeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
27
- var fileName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
28
- return mimeType ? /^text\//.test(mimeType) : /\.(txt|md)$/.test(fileName);
29
- };
30
- export var hasQualifications = function hasQualifications(_ref) {
31
- var file = _ref.file;
32
- return has(file, 'metadata.qualification');
33
- };
34
- export var hasCertifications = function hasCertifications(_ref2) {
35
- var file = _ref2.file;
36
- return has(file, 'metadata.carbonCopy') || has(file, 'metadata.electronicSafe');
37
- };
38
- export var isFromKonnector = function isFromKonnector(_ref3) {
39
- var file = _ref3.file;
40
- return has(file, 'cozyMetadata.sourceAccount');
41
- };
42
27
  /**
43
28
  * Checks if the file matches one of the following conditions:
44
29
  * - Is certified
@@ -50,24 +35,18 @@ export var isFromKonnector = function isFromKonnector(_ref3) {
50
35
  * @returns {boolean}
51
36
  */
52
37
 
53
- export var isValidForPanel = function isValidForPanel(_ref4) {
54
- var file = _ref4.file;
55
- return hasCertifications({
56
- file: file
57
- }) || hasQualifications({
58
- file: file
59
- }) || isFromKonnector({
60
- file: file
61
- });
38
+ export var isValidForPanel = function isValidForPanel(_ref) {
39
+ var file = _ref.file;
40
+ return hasCertifications(file) || hasQualifications(file) || isFromKonnector(file);
62
41
  };
63
42
  export var downloadFile = /*#__PURE__*/function () {
64
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref5) {
43
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
65
44
  var client, file, url;
66
45
  return _regeneratorRuntime.wrap(function _callee$(_context) {
67
46
  while (1) {
68
47
  switch (_context.prev = _context.next) {
69
48
  case 0:
70
- client = _ref5.client, file = _ref5.file, url = _ref5.url;
49
+ client = _ref2.client, file = _ref2.file, url = _ref2.url;
71
50
 
72
51
  if (!isEncrypted(file)) {
73
52
  _context.next = 3;
@@ -88,17 +67,17 @@ export var downloadFile = /*#__PURE__*/function () {
88
67
  }));
89
68
 
90
69
  return function downloadFile(_x) {
91
- return _ref6.apply(this, arguments);
70
+ return _ref3.apply(this, arguments);
92
71
  };
93
72
  }();
94
73
  export var isFileEncrypted = function isFileEncrypted(file) {
95
74
  return isEncrypted(file);
96
75
  };
97
76
 
98
- var makeMetadataQualification = function makeMetadataQualification(_ref7) {
99
- var metadata = _ref7.metadata,
100
- knownMetadataName = _ref7.knownMetadataName,
101
- value = _ref7.value;
77
+ var makeMetadataQualification = function makeMetadataQualification(_ref4) {
78
+ var metadata = _ref4.metadata,
79
+ knownMetadataName = _ref4.knownMetadataName,
80
+ value = _ref4.value;
102
81
  var shouldReturnThisMetadata = Object.keys(metadata).includes(knownMetadataName);
103
82
 
104
83
  if (shouldReturnThisMetadata) {
@@ -144,10 +123,10 @@ export var formatMetadataQualification = function formatMetadataQualification(me
144
123
  }).filter(Boolean);
145
124
  return [].concat(_toConsumableArray(dates), _toConsumableArray(informations), _toConsumableArray(others));
146
125
  };
147
- export var formatDate = function formatDate(_ref8) {
148
- var f = _ref8.f,
149
- lang = _ref8.lang,
150
- date = _ref8.date;
126
+ export var formatDate = function formatDate(_ref5) {
127
+ var f = _ref5.f,
128
+ lang = _ref5.lang,
129
+ date = _ref5.date;
151
130
 
152
131
  if (lang === 'en') {
153
132
  return f(date, 'MM/DD/YYYY');
@@ -167,4 +146,8 @@ export var buildEditAttributePath = function buildEditAttributePath(editPathByMo
167
146
 
168
147
  var currentPath = editPathByModelProps[currentModel];
169
148
  return (_currentPath$replace = currentPath === null || currentPath === void 0 ? void 0 : currentPath.replace(/__NAME__/, name)) !== null && _currentPath$replace !== void 0 ? _currentPath$replace : '';
149
+ };
150
+ export var isEditableAttribute = function isEditableAttribute(name, file) {
151
+ var isNotEditableAttributes = ['datetime', 'qualification'];
152
+ return !isNotEditableAttributes.includes(name) && (name === 'issueDate' && !isFromKonnector(file) || name !== 'issueDate');
170
153
  };
@@ -64,13 +64,13 @@ var withFileUrl = function withFileUrl(BaseComponent) {
64
64
  }
65
65
 
66
66
  _createClass(withFileUrlClass, [{
67
- key: "componentWillMount",
68
- value: function componentWillMount() {
67
+ key: "UNSAFE_componentWillMount",
68
+ value: function UNSAFE_componentWillMount() {
69
69
  this.loadDownloadUrl();
70
70
  }
71
71
  }, {
72
- key: "componentWillReceiveProps",
73
- value: function componentWillReceiveProps(nextProps) {
72
+ key: "UNSAFE_componentWillReceiveProps",
73
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
74
74
  if (nextProps.file.id !== this.props.file.id || nextProps.url !== this.props.url) {
75
75
  this.reset();
76
76
  }