cozy-ui 102.1.1 → 102.2.1

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
+ ## [102.2.1](https://github.com/cozy/cozy-ui/compare/v102.2.0...v102.2.1) (2024-01-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Use navigator.clipboard instead of copy-text-to-clipboard ([ae42cb9](https://github.com/cozy/cozy-ui/commit/ae42cb9))
7
+
8
+ # [102.2.0](https://github.com/cozy/cozy-ui/compare/v102.1.1...v102.2.0) (2024-01-29)
9
+
10
+
11
+ ### Features
12
+
13
+ * **Viewer:** Add isPublic prop for manage panel blocks displayed ([7f8668a](https://github.com/cozy/cozy-ui/commit/7f8668a))
14
+
1
15
  ## [102.1.1](https://github.com/cozy/cozy-ui/compare/v102.1.0...v102.1.1) (2024-01-29)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "102.1.1",
3
+ "version": "102.2.1",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -161,7 +161,6 @@
161
161
  "bundlemon": "^1.3.2",
162
162
  "chart.js": "3.7.1",
163
163
  "classnames": "^2.2.5",
164
- "copy-text-to-clipboard": "3.2.0",
165
164
  "cozy-interapp": "^0.5.4",
166
165
  "date-fns": "^1.28.5",
167
166
  "filesize": "8.0.7",
@@ -1,5 +1,4 @@
1
1
  import get from 'lodash/get'
2
- import copy from 'copy-text-to-clipboard'
3
2
 
4
3
  import { formatDate } from '../../Viewer/helpers'
5
4
 
@@ -68,15 +67,15 @@ export const makeDefaultExpandedAttributes = (doc, expandedAttributes) => {
68
67
  .filter(x => x)
69
68
  }
70
69
 
71
- export const copyToClipboard = ({ value, setAlertProps, t }) => () => {
72
- const hasCopied = copy(value)
73
- if (hasCopied) {
70
+ export const copyToClipboard = ({ value, setAlertProps, t }) => async () => {
71
+ try {
72
+ await navigator.clipboard.writeText(value)
74
73
  setAlertProps({
75
74
  open: true,
76
75
  severity: 'success',
77
76
  message: t(`ListItem.snackbar.copyToClipboard.success`)
78
77
  })
79
- } else {
78
+ } catch (error) {
80
79
  setAlertProps({
81
80
  open: true,
82
81
  severity: 'error',
@@ -7,8 +7,6 @@ import {
7
7
  import { I18nContext } from '../../jestLib/I18n'
8
8
  import en from '../locales/en'
9
9
 
10
- jest.mock('copy-text-to-clipboard', () => ({ copy: jest.fn() }))
11
-
12
10
  const i18nContext = I18nContext({
13
11
  locale: en
14
12
  })
@@ -3,10 +3,13 @@ import PropTypes from 'prop-types'
3
3
 
4
4
  import { BottomSheetItem } from '../../BottomSheet'
5
5
 
6
- import getPanelBlocks, { panelBlocksSpecs } from '../Panel/getPanelBlocks'
6
+ import getPanelBlocks, { getPanelBlocksSpecs } from '../Panel/getPanelBlocks'
7
7
 
8
- const BottomSheetContent = ({ file }) => {
9
- const panelBlocks = getPanelBlocks({ panelBlocksSpecs, file })
8
+ const BottomSheetContent = ({ file, isPublic }) => {
9
+ const panelBlocks = getPanelBlocks({
10
+ panelBlocksSpecs: getPanelBlocksSpecs(isPublic),
11
+ file
12
+ })
10
13
 
11
14
  return panelBlocks.map((PanelBlock, index) => (
12
15
  <BottomSheetItem
@@ -21,7 +24,7 @@ const BottomSheetContent = ({ file }) => {
21
24
 
22
25
  BottomSheetContent.propTypes = {
23
26
  file: PropTypes.object.isRequired,
24
- contactsFullname: PropTypes.string
27
+ isPublic: PropTypes.bool
25
28
  }
26
29
 
27
30
  export default BottomSheetContent
@@ -23,7 +23,7 @@ const useStyles = makeStyles(theme => ({
23
23
  }
24
24
  }))
25
25
 
26
- const FooterContent = ({ file, toolbarRef, children }) => {
26
+ const FooterContent = ({ file, toolbarRef, children, isPublic }) => {
27
27
  const styles = useStyles()
28
28
 
29
29
  const toolbarProps = useMemo(() => ({ ref: toolbarRef }), [toolbarRef])
@@ -54,7 +54,7 @@ const FooterContent = ({ file, toolbarRef, children }) => {
54
54
  >
55
55
  {FooterActionButtonsWithFile}
56
56
  </BottomSheetHeader>
57
- <BottomSheetContent file={file} />
57
+ <BottomSheetContent file={file} isPublic={isPublic} />
58
58
  </BottomSheet>
59
59
  )
60
60
  }
@@ -68,6 +68,7 @@ const FooterContent = ({ file, toolbarRef, children }) => {
68
68
  FooterContent.propTypes = {
69
69
  file: PropTypes.object.isRequired,
70
70
  toolbarRef: PropTypes.object,
71
+ isPublic: PropTypes.bool,
71
72
  children: PropTypes.oneOfType([
72
73
  PropTypes.node,
73
74
  PropTypes.arrayOf(PropTypes.node)
@@ -1,6 +1,5 @@
1
1
  import React, { forwardRef } from 'react'
2
2
  import PropTypes from 'prop-types'
3
- import copy from 'copy-text-to-clipboard'
4
3
 
5
4
  import { useAppLinkWithStoreFallback, useClient } from 'cozy-client'
6
5
 
@@ -40,14 +39,14 @@ const ActionMenuWrapper = forwardRef(({ onClose, file, optionFile }, ref) => {
40
39
  )
41
40
  const isAppLinkLoaded = fetchStatus === 'loaded'
42
41
 
43
- const handleCopy = () => {
44
- const hasCopied = copy(value)
45
- if (hasCopied) {
42
+ const handleCopy = async () => {
43
+ try {
44
+ await navigator.clipboard.writeText(value)
46
45
  showViewerSnackbar(
47
46
  'success',
48
47
  t(`Viewer.snackbar.copiedToClipboard.success`)
49
48
  )
50
- } else {
49
+ } catch (error) {
51
50
  showViewerSnackbar('error', t(`Viewer.snackbar.copiedToClipboard.error`))
52
51
  }
53
52
  onClose()
@@ -7,10 +7,13 @@ import Paper from '../../Paper'
7
7
  import Typography from '../../Typography'
8
8
  import { withViewerLocales } from '../hoc/withViewerLocales'
9
9
 
10
- import getPanelBlocks, { panelBlocksSpecs } from './getPanelBlocks'
10
+ import getPanelBlocks, { getPanelBlocksSpecs } from './getPanelBlocks'
11
11
 
12
- const PanelContent = ({ file, t }) => {
13
- const panelBlocks = getPanelBlocks({ panelBlocksSpecs, file })
12
+ const PanelContent = ({ file, isPublic, t }) => {
13
+ const panelBlocks = getPanelBlocks({
14
+ panelBlocksSpecs: getPanelBlocksSpecs(isPublic),
15
+ file
16
+ })
14
17
 
15
18
  return (
16
19
  <Stack spacing="s" className={cx('u-flex u-flex-column u-h-100')}>
@@ -40,7 +43,8 @@ const PanelContent = ({ file, t }) => {
40
43
  }
41
44
 
42
45
  PanelContent.propTypes = {
43
- file: PropTypes.object.isRequired
46
+ file: PropTypes.object.isRequired,
47
+ isPublic: PropTypes.bool
44
48
  }
45
49
 
46
50
  export default withViewerLocales(PanelContent)
@@ -6,21 +6,43 @@ import Qualification from './Qualification'
6
6
 
7
7
  const { isFromKonnector, hasQualifications, hasCertifications } = models.file
8
8
 
9
- export const panelBlocksSpecs = {
9
+ /**
10
+ * @typedef {Object} PanelBlockSpec
11
+ * @property {Function} condition - Function that returns true if the block should be displayed
12
+ * @property {React.Component} component - Component to display
13
+ */
14
+
15
+ /**
16
+ * @typedef {Object.<string, PanelBlockSpec>} PanelBlocksSpecs
17
+ */
18
+
19
+ /**
20
+ * Returns the specs of the blocks to display in the panel
21
+ * @param {boolean} isPublic - Whether the panel is displayed in public view
22
+ * @returns {PanelBlocksSpecs}
23
+ */
24
+ export const getPanelBlocksSpecs = (isPublic = false) => ({
10
25
  qualifications: {
11
26
  condition: hasQualifications,
12
27
  component: Qualification
13
28
  },
14
29
  konnector: {
15
- condition: isFromKonnector,
30
+ condition: () => isFromKonnector && !isPublic,
16
31
  component: KonnectorBlock
17
32
  },
18
33
  certifications: {
19
34
  condition: hasCertifications,
20
35
  component: Certifications
21
36
  }
22
- }
37
+ })
23
38
 
39
+ /**
40
+ * Returns the blocks to display in the panel
41
+ * @param {Object} options
42
+ * @param {PanelBlocksSpecs} options.panelBlocksSpecs - Specs of the blocks to display in the panel
43
+ * @param {import('cozy-client/types/types').FileDocument} options.file - File object
44
+ * @returns {Array.<React.Component>}
45
+ */
24
46
  const getPanelBlocks = ({ panelBlocksSpecs, file }) => {
25
47
  const panelBlocks = []
26
48
 
@@ -1,11 +1,9 @@
1
- import getPanelBlocks from './getPanelBlocks'
1
+ import getPanelBlocks, { getPanelBlocksSpecs } from './getPanelBlocks'
2
2
 
3
3
  jest.mock('cozy-harvest-lib/dist/components/KonnectorBlock', () => jest.fn())
4
4
  const block1Component = jest.fn()
5
5
  const block2Component = jest.fn()
6
6
 
7
- jest.mock('copy-text-to-clipboard', () => ({ copy: jest.fn() }))
8
-
9
7
  describe('getPanelBlocks', () => {
10
8
  it('should return only blocks with truthy condition', () => {
11
9
  // with two truthy component
@@ -60,3 +58,22 @@ describe('getPanelBlocks', () => {
60
58
  expect(getPanelBlocks({ panelBlocksSpecs: {} })).toMatchObject([])
61
59
  })
62
60
  })
61
+
62
+ describe('getPanelBlocksSpecs', () => {
63
+ it('should return the specs of the blocks to display in the panel', () => {
64
+ expect(getPanelBlocksSpecs()).toEqual({
65
+ qualifications: {
66
+ condition: expect.any(Function),
67
+ component: expect.anything()
68
+ },
69
+ konnector: {
70
+ condition: expect.any(Function),
71
+ component: expect.anything()
72
+ },
73
+ certifications: {
74
+ condition: expect.any(Function),
75
+ component: expect.anything()
76
+ }
77
+ })
78
+ })
79
+ })
@@ -26,6 +26,7 @@ const ViewerContainer = props => {
26
26
  editPathByModelProps,
27
27
  children,
28
28
  componentsProps,
29
+ isPublic,
29
30
  ...rest
30
31
  } = props
31
32
  const { currentIndex, files, currentURL } = props
@@ -66,6 +67,7 @@ const ViewerContainer = props => {
66
67
  />
67
68
  </EncryptedProvider>
68
69
  <ViewerInformationsWrapper
70
+ isPublic={isPublic}
69
71
  disableFooter={disableFooter}
70
72
  validForPanel={validForPanel}
71
73
  currentFile={currentFile}
@@ -107,6 +109,8 @@ ViewerContainer.propTypes = {
107
109
  disablePanel: PropTypes.bool,
108
110
  /** Show/Hide the panel containing more information about the file only on Phone & Tablet devices */
109
111
  disableFooter: PropTypes.bool,
112
+ /** If the Viewer is in public view */
113
+ isPublic: PropTypes.bool,
110
114
  /* Props passed to components with the same name */
111
115
  componentsProps: PropTypes.shape({
112
116
  /** Used to open an Only Office file */
@@ -15,6 +15,7 @@ const ViewerInformationsWrapper = ({
15
15
  disableFooter,
16
16
  validForPanel,
17
17
  toolbarRef,
18
+ isPublic,
18
19
  children
19
20
  }) => {
20
21
  const theme = useTheme()
@@ -34,14 +35,18 @@ const ViewerInformationsWrapper = ({
34
35
  <>
35
36
  {!disableFooter && (
36
37
  <Footer>
37
- <FooterContent file={currentFile} toolbarRef={toolbarRef}>
38
+ <FooterContent
39
+ file={currentFile}
40
+ toolbarRef={toolbarRef}
41
+ isPublic={isPublic}
42
+ >
38
43
  {children}
39
44
  </FooterContent>
40
45
  </Footer>
41
46
  )}
42
47
  {validForPanel && (
43
48
  <InformationPanel>
44
- <PanelContent file={currentFile} />
49
+ <PanelContent file={currentFile} isPublic={isPublic} />
45
50
  </InformationPanel>
46
51
  )}
47
52
  </>
@@ -53,6 +58,7 @@ ViewerInformationsWrapper.propTypes = {
53
58
  disableFooter: PropTypes.bool,
54
59
  validForPanel: PropTypes.bool,
55
60
  toolbarRef: PropTypes.object,
61
+ isPublic: PropTypes.bool,
56
62
  children: PropTypes.oneOfType([
57
63
  PropTypes.node,
58
64
  PropTypes.arrayOf(PropTypes.node)
@@ -1,5 +1,6 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
1
3
  import get from 'lodash/get';
2
- import copy from 'copy-text-to-clipboard';
3
4
  import { formatDate } from "cozy-ui/transpiled/react/Viewer/helpers";
4
5
  export var normalizeExpandedAttribute = function normalizeExpandedAttribute(attr) {
5
6
  return attr.replaceAll(':', '.').replace('flexsearchProps.', '').replace('translated.', '');
@@ -38,23 +39,40 @@ export var copyToClipboard = function copyToClipboard(_ref) {
38
39
  var value = _ref.value,
39
40
  setAlertProps = _ref.setAlertProps,
40
41
  t = _ref.t;
41
- return function () {
42
- var hasCopied = copy(value);
43
-
44
- if (hasCopied) {
45
- setAlertProps({
46
- open: true,
47
- severity: 'success',
48
- message: t("ListItem.snackbar.copyToClipboard.success")
49
- });
50
- } else {
51
- setAlertProps({
52
- open: true,
53
- severity: 'error',
54
- message: t("ListItem.snackbar.copyToClipboard.error")
55
- });
56
- }
57
- };
42
+ return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
43
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
44
+ while (1) {
45
+ switch (_context.prev = _context.next) {
46
+ case 0:
47
+ _context.prev = 0;
48
+ _context.next = 3;
49
+ return navigator.clipboard.writeText(value);
50
+
51
+ case 3:
52
+ setAlertProps({
53
+ open: true,
54
+ severity: 'success',
55
+ message: t("ListItem.snackbar.copyToClipboard.success")
56
+ });
57
+ _context.next = 9;
58
+ break;
59
+
60
+ case 6:
61
+ _context.prev = 6;
62
+ _context.t0 = _context["catch"](0);
63
+ setAlertProps({
64
+ open: true,
65
+ severity: 'error',
66
+ message: t("ListItem.snackbar.copyToClipboard.error")
67
+ });
68
+
69
+ case 9:
70
+ case "end":
71
+ return _context.stop();
72
+ }
73
+ }
74
+ }, _callee, null, [[0, 6]]);
75
+ }));
58
76
  };
59
77
  export var isDate = function isDate(value) {
60
78
  if (!isNaN(value)) return false;
@@ -62,13 +80,13 @@ export var isDate = function isDate(value) {
62
80
  var dateParsedValue = Date.parse(value);
63
81
  return dateTime === dateParsedValue;
64
82
  };
65
- export var formatAttrValue = function formatAttrValue(_ref2) {
83
+ export var formatAttrValue = function formatAttrValue(_ref3) {
66
84
  var _attrValue$find, _attrValue$find2, _attrValue$find3;
67
85
 
68
- var attribute = _ref2.attribute,
69
- attrValue = _ref2.attrValue,
70
- f = _ref2.f,
71
- lang = _ref2.lang;
86
+ var attribute = _ref3.attribute,
87
+ attrValue = _ref3.attrValue,
88
+ f = _ref3.f,
89
+ lang = _ref3.lang;
72
90
  if (!attrValue || attrValue.length === 0) return undefined;
73
91
 
74
92
  switch (true) {
@@ -110,11 +128,11 @@ export var makeAttrKey = function makeAttrKey(doc, expandedAttribute) {
110
128
  return expandedAttribute;
111
129
  }
112
130
  };
113
- export var makeAttrsKeyAndFormatedValue = function makeAttrsKeyAndFormatedValue(_ref3) {
114
- var doc = _ref3.doc,
115
- expandedAttributes = _ref3.expandedAttributes,
116
- f = _ref3.f,
117
- lang = _ref3.lang;
131
+ export var makeAttrsKeyAndFormatedValue = function makeAttrsKeyAndFormatedValue(_ref4) {
132
+ var doc = _ref4.doc,
133
+ expandedAttributes = _ref4.expandedAttributes,
134
+ f = _ref4.f,
135
+ lang = _ref4.lang;
118
136
  var attrsKeyAndFormatedValue = expandedAttributes.map(function (expandedAttribute) {
119
137
  var attrValue = get(doc, expandedAttribute);
120
138
  var attrFormatedValue = formatAttrValue({
@@ -134,11 +152,11 @@ export var makeAttrsKeyAndFormatedValue = function makeAttrsKeyAndFormatedValue(
134
152
  }).slice(0, 3);
135
153
  return attrsKeyAndFormatedValue;
136
154
  };
137
- export var hasExpandedAttributesDisplayed = function hasExpandedAttributesDisplayed(_ref4) {
138
- var doc = _ref4.doc,
139
- expandedAttributes = _ref4.expandedAttributes,
140
- f = _ref4.f,
141
- lang = _ref4.lang;
155
+ export var hasExpandedAttributesDisplayed = function hasExpandedAttributesDisplayed(_ref5) {
156
+ var doc = _ref5.doc,
157
+ expandedAttributes = _ref5.expandedAttributes,
158
+ f = _ref5.f,
159
+ lang = _ref5.lang;
142
160
  var defaultExpandedAttributes = makeDefaultExpandedAttributes(doc, expandedAttributes);
143
161
  var attrsKeyAndFormatedValue = makeAttrsKeyAndFormatedValue({
144
162
  doc: doc,
@@ -148,10 +166,10 @@ export var hasExpandedAttributesDisplayed = function hasExpandedAttributesDispla
148
166
  });
149
167
  return (attrsKeyAndFormatedValue === null || attrsKeyAndFormatedValue === void 0 ? void 0 : attrsKeyAndFormatedValue.length) > 0 || false;
150
168
  };
151
- export var getValueExtended = function getValueExtended(_ref5) {
152
- var attrKey = _ref5.attrKey,
153
- value = _ref5.value,
154
- t = _ref5.t;
169
+ export var getValueExtended = function getValueExtended(_ref6) {
170
+ var attrKey = _ref6.attrKey,
171
+ value = _ref6.value,
172
+ t = _ref6.t;
155
173
 
156
174
  if (attrKey === 'metadata.noticePeriod') {
157
175
  if (!isNaN(parseInt(value))) {
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { BottomSheetItem } from "cozy-ui/transpiled/react/BottomSheet";
4
- import getPanelBlocks, { panelBlocksSpecs } from "cozy-ui/transpiled/react/Viewer/Panel/getPanelBlocks";
4
+ import getPanelBlocks, { getPanelBlocksSpecs } from "cozy-ui/transpiled/react/Viewer/Panel/getPanelBlocks";
5
5
 
6
6
  var BottomSheetContent = function BottomSheetContent(_ref) {
7
- var file = _ref.file;
7
+ var file = _ref.file,
8
+ isPublic = _ref.isPublic;
8
9
  var panelBlocks = getPanelBlocks({
9
- panelBlocksSpecs: panelBlocksSpecs,
10
+ panelBlocksSpecs: getPanelBlocksSpecs(isPublic),
10
11
  file: file
11
12
  });
12
13
  return panelBlocks.map(function (PanelBlock, index) {
@@ -22,6 +23,6 @@ var BottomSheetContent = function BottomSheetContent(_ref) {
22
23
 
23
24
  BottomSheetContent.propTypes = {
24
25
  file: PropTypes.object.isRequired,
25
- contactsFullname: PropTypes.string
26
+ isPublic: PropTypes.bool
26
27
  };
27
28
  export default BottomSheetContent;
@@ -26,7 +26,8 @@ var useStyles = makeStyles(function (theme) {
26
26
  var FooterContent = function FooterContent(_ref) {
27
27
  var file = _ref.file,
28
28
  toolbarRef = _ref.toolbarRef,
29
- children = _ref.children;
29
+ children = _ref.children,
30
+ isPublic = _ref.isPublic;
30
31
  var styles = useStyles();
31
32
  var toolbarProps = useMemo(function () {
32
33
  return {
@@ -54,7 +55,8 @@ var FooterContent = function FooterContent(_ref) {
54
55
  }, /*#__PURE__*/React.createElement(BottomSheetHeader, {
55
56
  className: cx('u-ph-1 u-pb-1', styles.bottomSheetHeader)
56
57
  }, FooterActionButtonsWithFile), /*#__PURE__*/React.createElement(BottomSheetContent, {
57
- file: file
58
+ file: file,
59
+ isPublic: isPublic
58
60
  }));
59
61
  } // If `FooterActionButtons` hasn't children
60
62
 
@@ -68,6 +70,7 @@ var FooterContent = function FooterContent(_ref) {
68
70
  FooterContent.propTypes = {
69
71
  file: PropTypes.object.isRequired,
70
72
  toolbarRef: PropTypes.object,
73
+ isPublic: PropTypes.bool,
71
74
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)])
72
75
  };
73
76
  export default FooterContent;
@@ -1,6 +1,7 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
1
3
  import React, { forwardRef } from 'react';
2
4
  import PropTypes from 'prop-types';
3
- import copy from 'copy-text-to-clipboard';
4
5
  import { useAppLinkWithStoreFallback, useClient } from 'cozy-client';
5
6
  import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
6
7
  import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
@@ -37,17 +38,41 @@ var ActionMenuWrapper = /*#__PURE__*/forwardRef(function (_ref, ref) {
37
38
 
38
39
  var isAppLinkLoaded = fetchStatus === 'loaded';
39
40
 
40
- var handleCopy = function handleCopy() {
41
- var hasCopied = copy(value);
41
+ var handleCopy = /*#__PURE__*/function () {
42
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
43
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
44
+ while (1) {
45
+ switch (_context.prev = _context.next) {
46
+ case 0:
47
+ _context.prev = 0;
48
+ _context.next = 3;
49
+ return navigator.clipboard.writeText(value);
42
50
 
43
- if (hasCopied) {
44
- showViewerSnackbar('success', t("Viewer.snackbar.copiedToClipboard.success"));
45
- } else {
46
- showViewerSnackbar('error', t("Viewer.snackbar.copiedToClipboard.error"));
47
- }
51
+ case 3:
52
+ showViewerSnackbar('success', t("Viewer.snackbar.copiedToClipboard.success"));
53
+ _context.next = 9;
54
+ break;
48
55
 
49
- onClose();
50
- };
56
+ case 6:
57
+ _context.prev = 6;
58
+ _context.t0 = _context["catch"](0);
59
+ showViewerSnackbar('error', t("Viewer.snackbar.copiedToClipboard.error"));
60
+
61
+ case 9:
62
+ onClose();
63
+
64
+ case 10:
65
+ case "end":
66
+ return _context.stop();
67
+ }
68
+ }
69
+ }, _callee, null, [[0, 6]]);
70
+ }));
71
+
72
+ return function handleCopy() {
73
+ return _ref2.apply(this, arguments);
74
+ };
75
+ }();
51
76
 
52
77
  var handleEdit = function handleEdit(cb) {
53
78
  if (isAppLinkLoaded) {
@@ -5,13 +5,14 @@ import Stack from "cozy-ui/transpiled/react/Stack";
5
5
  import Paper from "cozy-ui/transpiled/react/Paper";
6
6
  import Typography from "cozy-ui/transpiled/react/Typography";
7
7
  import { withViewerLocales } from "cozy-ui/transpiled/react/Viewer/hoc/withViewerLocales";
8
- import getPanelBlocks, { panelBlocksSpecs } from "cozy-ui/transpiled/react/Viewer/Panel/getPanelBlocks";
8
+ import getPanelBlocks, { getPanelBlocksSpecs } from "cozy-ui/transpiled/react/Viewer/Panel/getPanelBlocks";
9
9
 
10
10
  var PanelContent = function PanelContent(_ref) {
11
11
  var file = _ref.file,
12
+ isPublic = _ref.isPublic,
12
13
  t = _ref.t;
13
14
  var panelBlocks = getPanelBlocks({
14
- panelBlocksSpecs: panelBlocksSpecs,
15
+ panelBlocksSpecs: getPanelBlocksSpecs(isPublic),
15
16
  file: file
16
17
  });
17
18
  return /*#__PURE__*/React.createElement(Stack, {
@@ -41,6 +42,7 @@ var PanelContent = function PanelContent(_ref) {
41
42
  };
42
43
 
43
44
  PanelContent.propTypes = {
44
- file: PropTypes.object.isRequired
45
+ file: PropTypes.object.isRequired,
46
+ isPublic: PropTypes.bool
45
47
  };
46
48
  export default withViewerLocales(PanelContent);
@@ -6,20 +6,48 @@ var _models$file = models.file,
6
6
  isFromKonnector = _models$file.isFromKonnector,
7
7
  hasQualifications = _models$file.hasQualifications,
8
8
  hasCertifications = _models$file.hasCertifications;
9
- export var panelBlocksSpecs = {
10
- qualifications: {
11
- condition: hasQualifications,
12
- component: Qualification
13
- },
14
- konnector: {
15
- condition: isFromKonnector,
16
- component: KonnectorBlock
17
- },
18
- certifications: {
19
- condition: hasCertifications,
20
- component: Certifications
21
- }
9
+ /**
10
+ * @typedef {Object} PanelBlockSpec
11
+ * @property {Function} condition - Function that returns true if the block should be displayed
12
+ * @property {React.Component} component - Component to display
13
+ */
14
+
15
+ /**
16
+ * @typedef {Object.<string, PanelBlockSpec>} PanelBlocksSpecs
17
+ */
18
+
19
+ /**
20
+ * Returns the specs of the blocks to display in the panel
21
+ * @param {boolean} isPublic - Whether the panel is displayed in public view
22
+ * @returns {PanelBlocksSpecs}
23
+ */
24
+
25
+ export var getPanelBlocksSpecs = function getPanelBlocksSpecs() {
26
+ var isPublic = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
27
+ return {
28
+ qualifications: {
29
+ condition: hasQualifications,
30
+ component: Qualification
31
+ },
32
+ konnector: {
33
+ condition: function condition() {
34
+ return isFromKonnector && !isPublic;
35
+ },
36
+ component: KonnectorBlock
37
+ },
38
+ certifications: {
39
+ condition: hasCertifications,
40
+ component: Certifications
41
+ }
42
+ };
22
43
  };
44
+ /**
45
+ * Returns the blocks to display in the panel
46
+ * @param {Object} options
47
+ * @param {PanelBlocksSpecs} options.panelBlocksSpecs - Specs of the blocks to display in the panel
48
+ * @param {import('cozy-client/types/types').FileDocument} options.file - File object
49
+ * @returns {Array.<React.Component>}
50
+ */
23
51
 
24
52
  var getPanelBlocks = function getPanelBlocks(_ref) {
25
53
  var panelBlocksSpecs = _ref.panelBlocksSpecs,
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["className", "disableFooter", "disablePanel", "editPathByModelProps", "children", "componentsProps"],
4
+ var _excluded = ["className", "disableFooter", "disablePanel", "editPathByModelProps", "children", "componentsProps", "isPublic"],
5
5
  _excluded2 = ["disableModal"];
6
6
 
7
7
  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; }
@@ -35,6 +35,7 @@ var ViewerContainer = function ViewerContainer(props) {
35
35
  editPathByModelProps = props.editPathByModelProps,
36
36
  children = props.children,
37
37
  componentsProps = props.componentsProps,
38
+ isPublic = props.isPublic,
38
39
  rest = _objectWithoutProperties(props, _excluded);
39
40
 
40
41
  var currentIndex = props.currentIndex,
@@ -75,6 +76,7 @@ var ViewerContainer = function ViewerContainer(props) {
75
76
  validForPanel: validForPanel,
76
77
  toolbarRef: toolbarRef
77
78
  }))), /*#__PURE__*/React.createElement(ViewerInformationsWrapper, {
79
+ isPublic: isPublic,
78
80
  disableFooter: disableFooter,
79
81
  validForPanel: validForPanel,
80
82
  currentFile: currentFile,
@@ -120,6 +122,9 @@ ViewerContainer.propTypes = {
120
122
  /** Show/Hide the panel containing more information about the file only on Phone & Tablet devices */
121
123
  disableFooter: PropTypes.bool,
122
124
 
125
+ /** If the Viewer is in public view */
126
+ isPublic: PropTypes.bool,
127
+
123
128
  /* Props passed to components with the same name */
124
129
  componentsProps: PropTypes.shape({
125
130
  /** Used to open an Only Office file */
@@ -13,6 +13,7 @@ var ViewerInformationsWrapper = function ViewerInformationsWrapper(_ref) {
13
13
  disableFooter = _ref.disableFooter,
14
14
  validForPanel = _ref.validForPanel,
15
15
  toolbarRef = _ref.toolbarRef,
16
+ isPublic = _ref.isPublic,
16
17
  children = _ref.children;
17
18
  var theme = useTheme();
18
19
  var sidebar = document.querySelector('[class*="sidebar"]');
@@ -24,9 +25,11 @@ var ViewerInformationsWrapper = function ViewerInformationsWrapper(_ref) {
24
25
  });
25
26
  return /*#__PURE__*/React.createElement(React.Fragment, null, !disableFooter && /*#__PURE__*/React.createElement(Footer, null, /*#__PURE__*/React.createElement(FooterContent, {
26
27
  file: currentFile,
27
- toolbarRef: toolbarRef
28
+ toolbarRef: toolbarRef,
29
+ isPublic: isPublic
28
30
  }, children)), validForPanel && /*#__PURE__*/React.createElement(InformationPanel, null, /*#__PURE__*/React.createElement(PanelContent, {
29
- file: currentFile
31
+ file: currentFile,
32
+ isPublic: isPublic
30
33
  })));
31
34
  };
32
35
 
@@ -35,6 +38,7 @@ ViewerInformationsWrapper.propTypes = {
35
38
  disableFooter: PropTypes.bool,
36
39
  validForPanel: PropTypes.bool,
37
40
  toolbarRef: PropTypes.object,
41
+ isPublic: PropTypes.bool,
38
42
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)])
39
43
  };
40
44
  export default ViewerInformationsWrapper;