cozy-ui 74.3.0 → 74.4.2

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,30 @@
1
+ ## [74.4.2](https://github.com/cozy/cozy-ui/compare/v74.4.1...v74.4.2) (2022-09-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * isLoadingContacts on useReferencedContactName hook ([dab3e09](https://github.com/cozy/cozy-ui/commit/dab3e09))
7
+
8
+ ## [74.4.1](https://github.com/cozy/cozy-ui/compare/v74.4.0...v74.4.1) (2022-09-08)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Restore BottomSheet items' gap in `FooterContent` container ([7ba1caf](https://github.com/cozy/cozy-ui/commit/7ba1caf))
14
+
15
+ # [74.4.0](https://github.com/cozy/cozy-ui/compare/v74.3.0...v74.4.0) (2022-09-06)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * Add a mid ellipsis to the filename in the qualification list ([4f30229](https://github.com/cozy/cozy-ui/commit/4f30229))
21
+ * Add a missing `overflow: hidden;` property to the viewer filename ([6d9b5c2](https://github.com/cozy/cozy-ui/commit/6d9b5c2))
22
+
23
+
24
+ ### Features
25
+
26
+ * Display Viewer's Download button on iOS Flagship app ([b21726c](https://github.com/cozy/cozy-ui/commit/b21726c)), closes [cozy/cozy-ui#2215](https://github.com/cozy/cozy-ui/issues/2215)
27
+
1
28
  # [74.3.0](https://github.com/cozy/cozy-ui/compare/v74.2.0...v74.3.0) (2022-09-02)
2
29
 
3
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "74.3.0",
3
+ "version": "74.4.2",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -65,6 +65,7 @@
65
65
  "intersection-observer"
66
66
  ],
67
67
  "devDependencies": {
68
+ "@argos-ci/cli": "^0.2.1",
68
69
  "@babel/cli": "7.17.6",
69
70
  "@babel/core": "7.17.8",
70
71
  "@babel/helper-builder-react-jsx": "7.16.7",
@@ -80,7 +81,6 @@
80
81
  "@testing-library/react": "11.2.7",
81
82
  "@testing-library/react-hooks": "^3.2.1",
82
83
  "@testing-library/user-event": "^14.4.2",
83
- "argos-cli": "^0.3.3",
84
84
  "autoprefixer-stylus": "1.0.0",
85
85
  "babel-loader": "8.2.4",
86
86
  "babel-plugin-css-modules-transform": "1.6.2",
@@ -1,6 +1,7 @@
1
1
  import React, { useMemo, Children, cloneElement, isValidElement } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import { makeStyles } from '@material-ui/core/styles'
4
+ import cx from 'classnames'
4
5
 
5
6
  import BottomSheet, { BottomSheetHeader } from '../../BottomSheet'
6
7
 
@@ -18,6 +19,9 @@ const useStyles = makeStyles(theme => ({
18
19
  paddingRight: '1rem',
19
20
  borderTop: `1px solid ${theme.palette.divider}`,
20
21
  columnGap: '0.5rem'
22
+ },
23
+ bottomSheetHeader: {
24
+ columnGap: '0.5rem'
21
25
  }
22
26
  }))
23
27
 
@@ -46,7 +50,9 @@ const FooterContent = ({ file, toolbarRef, children }) => {
46
50
  if (isValidForPanel({ file }) && !isLoadingContacts) {
47
51
  return (
48
52
  <BottomSheet toolbarProps={toolbarProps}>
49
- <BottomSheetHeader className="u-ph-1 u-pb-1">
53
+ <BottomSheetHeader
54
+ className={cx('u-ph-1 u-pb-1', styles.bottomSheetHeader)}
55
+ >
50
56
  {FooterActionButtonsWithFile}
51
57
  </BottomSheetHeader>
52
58
  <BottomSheetContent file={file} contactsFullname={contactName} />
@@ -2,7 +2,6 @@ import React from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
 
4
4
  import { useClient } from 'cozy-client'
5
- import { isFlagshipApp, isIOS } from 'cozy-device-helper'
6
5
 
7
6
  import ForwardButton from './ForwardButton'
8
7
  import DownloadButton from './DownloadButton'
@@ -15,10 +14,7 @@ const ForwardOrDownloadButton = ({ file }) => {
15
14
  ? ForwardButton
16
15
  : DownloadButton
17
16
 
18
- // Temporarily disable Download button on iOS Flagship app until
19
- // the download feature is fixed on this platform
20
- // When fixed on this platform, revert this commit from PR #2215
21
- return isFlagshipApp() && isIOS() ? null : <FileActionButton file={file} />
17
+ return <FileActionButton file={file} />
22
18
  }
23
19
 
24
20
  ForwardOrDownloadButton.propTypes = {
@@ -10,17 +10,20 @@ const useReferencedContactName = file => {
10
10
  const contactIds = getReferencedBy(file, 'io.cozy.contacts').map(
11
11
  ref => ref.id
12
12
  )
13
+ const isContactByIdsQueryEnabled = contactIds.length > 0
14
+
13
15
  const contactByIdsQuery = buildContactByIdsQuery(contactIds)
14
16
  const { data: contacts, ...contactsQueryResult } = useQuery(
15
17
  contactByIdsQuery.definition,
16
18
  {
17
19
  ...contactByIdsQuery.options,
18
- enabled: contactIds.length > 0
20
+ enabled: isContactByIdsQueryEnabled
19
21
  }
20
22
  )
21
23
 
22
24
  const isLoadingContacts =
23
- isQueryLoading(contactsQueryResult) || contactsQueryResult.hasMore
25
+ isContactByIdsQueryEnabled &&
26
+ (isQueryLoading(contactsQueryResult) || contactsQueryResult.hasMore)
24
27
 
25
28
  const contactName =
26
29
  contacts && contacts.length > 0
@@ -7,6 +7,7 @@ import List from '../../MuiCozyTheme/List'
7
7
  import ListItem from '../../MuiCozyTheme/ListItem'
8
8
  import QualificationListItemText from './QualificationListItemText'
9
9
  import { withViewerLocales } from '../withViewerLocales'
10
+ import MidEllipsis from '../../MidEllipsis'
10
11
 
11
12
  const {
12
13
  document: {
@@ -53,9 +54,13 @@ const Qualification = ({ file = {}, contactsFullname, t, f, lang }) => {
53
54
  <QualificationListItemText
54
55
  primary={t('Viewer.panel.qualification.label.title')}
55
56
  secondary={
56
- pageLabel
57
- ? t(`Viewer.panel.qualification.label.${pageLabel}`)
58
- : filename
57
+ <MidEllipsis
58
+ text={
59
+ pageLabel
60
+ ? t(`Viewer.panel.qualification.label.${pageLabel}`)
61
+ : filename
62
+ }
63
+ />
59
64
  }
60
65
  />
61
66
  </ListItem>
@@ -73,8 +73,15 @@ const files = [
73
73
  {
74
74
  _id: 'text',
75
75
  class: 'text',
76
- name: 'Demo.txt',
77
- mime: 'text/plain'
76
+ name: 'LoremipsumdolorsitametconsecteturadipiscingelitSednonrisusSuspendisselectustortordignissimsitametadipiscingnecultriciesseddolorCraselementumultricesdiamMaecenasligulamassavariusasempercongueeuismodnonmiProinporttitororcinecnonummymolestieenimesteleifendminonfermentumdiamnislsitameteratDuissemperDuisarcumassascelerisquevitaeconsequatinpretiumaenimPellentesquecongueUtinrisusvolutpatliberopharetratemporCrasvestibulumbibendumauguePraesentegestasleoinpedePraesentblanditodioeuenimPellentesquesedduiutaugueblanditsodalesVestibulumanteipsumprimisinfaucibusorciluctusetultricesposuerecubiliaCuraeAliquamnibhMaurisacmaurissedpedepellentesquefermentumMaecenasadipiscingantenondiamsodaleshendrerit.txt',
77
+ mime: 'text/plain',
78
+ metadata: {
79
+ datetime: "2022-01-01T12:00:00.000Z",
80
+ datetimeLabel: "datetime",
81
+ qualification: {
82
+ label: 'tax_notice'
83
+ }
84
+ }
78
85
  },
79
86
  {
80
87
  _id: 'text',
@@ -75,6 +75,7 @@ $viewerMarginTopMedium = $toolbarHeightMedium - $footerHeight
75
75
  .viewer-filename
76
76
  max-width 90%
77
77
  text-overflow ellipsis
78
+ overflow hidden
78
79
 
79
80
  .viewer-pdfviewer-pdf
80
81
  overflow auto
@@ -1,6 +1,7 @@
1
1
  import React, { useMemo, Children, cloneElement, isValidElement } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { makeStyles } from '@material-ui/core/styles';
4
+ import cx from 'classnames';
4
5
  import BottomSheet, { BottomSheetHeader } from "cozy-ui/transpiled/react/BottomSheet";
5
6
  import { isValidForPanel } from "cozy-ui/transpiled/react/Viewer/helpers";
6
7
  import BottomSheetContent from "cozy-ui/transpiled/react/Viewer/Footer/BottomSheetContent";
@@ -16,6 +17,9 @@ var useStyles = makeStyles(function (theme) {
16
17
  paddingRight: '1rem',
17
18
  borderTop: "1px solid ".concat(theme.palette.divider),
18
19
  columnGap: '0.5rem'
20
+ },
21
+ bottomSheetHeader: {
22
+ columnGap: '0.5rem'
19
23
  }
20
24
  };
21
25
  });
@@ -48,7 +52,7 @@ var FooterContent = function FooterContent(_ref) {
48
52
  return /*#__PURE__*/React.createElement(BottomSheet, {
49
53
  toolbarProps: toolbarProps
50
54
  }, /*#__PURE__*/React.createElement(BottomSheetHeader, {
51
- className: "u-ph-1 u-pb-1"
55
+ className: cx('u-ph-1 u-pb-1', styles.bottomSheetHeader)
52
56
  }, FooterActionButtonsWithFile), /*#__PURE__*/React.createElement(BottomSheetContent, {
53
57
  file: file,
54
58
  contactsFullname: contactName
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { useClient } from 'cozy-client';
4
- import { isFlagshipApp, isIOS } from 'cozy-device-helper';
5
4
  import ForwardButton from "cozy-ui/transpiled/react/Viewer/Footer/ForwardButton";
6
5
  import DownloadButton from "cozy-ui/transpiled/react/Viewer/Footer/DownloadButton";
7
6
  import { shouldBeForwardButton } from "cozy-ui/transpiled/react/Viewer/Footer/helpers";
@@ -9,11 +8,8 @@ import { shouldBeForwardButton } from "cozy-ui/transpiled/react/Viewer/Footer/he
9
8
  var ForwardOrDownloadButton = function ForwardOrDownloadButton(_ref) {
10
9
  var file = _ref.file;
11
10
  var client = useClient();
12
- var FileActionButton = shouldBeForwardButton(client) ? ForwardButton : DownloadButton; // Temporarily disable Download button on iOS Flagship app until
13
- // the download feature is fixed on this platform
14
- // When fixed on this platform, revert this commit from PR #2215
15
-
16
- return isFlagshipApp() && isIOS() ? null : /*#__PURE__*/React.createElement(FileActionButton, {
11
+ var FileActionButton = shouldBeForwardButton(client) ? ForwardButton : DownloadButton;
12
+ return /*#__PURE__*/React.createElement(FileActionButton, {
17
13
  file: file
18
14
  });
19
15
  };
@@ -14,15 +14,16 @@ var useReferencedContactName = function useReferencedContactName(file) {
14
14
  var contactIds = getReferencedBy(file, 'io.cozy.contacts').map(function (ref) {
15
15
  return ref.id;
16
16
  });
17
+ var isContactByIdsQueryEnabled = contactIds.length > 0;
17
18
  var contactByIdsQuery = buildContactByIdsQuery(contactIds);
18
19
 
19
20
  var _useQuery = useQuery(contactByIdsQuery.definition, _objectSpread(_objectSpread({}, contactByIdsQuery.options), {}, {
20
- enabled: contactIds.length > 0
21
+ enabled: isContactByIdsQueryEnabled
21
22
  })),
22
23
  contacts = _useQuery.data,
23
24
  contactsQueryResult = _objectWithoutProperties(_useQuery, _excluded);
24
25
 
25
- var isLoadingContacts = isQueryLoading(contactsQueryResult) || contactsQueryResult.hasMore;
26
+ var isLoadingContacts = isContactByIdsQueryEnabled && (isQueryLoading(contactsQueryResult) || contactsQueryResult.hasMore);
26
27
  var contactName = contacts && contacts.length > 0 ? contacts.map(function (contact) {
27
28
  return "".concat(getDisplayName(contact));
28
29
  }).join(', ') : '';
@@ -5,6 +5,7 @@ import List from "cozy-ui/transpiled/react/MuiCozyTheme/List";
5
5
  import ListItem from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem";
6
6
  import QualificationListItemText from "cozy-ui/transpiled/react/Viewer/Panel/QualificationListItemText";
7
7
  import { withViewerLocales } from "cozy-ui/transpiled/react/Viewer/withViewerLocales";
8
+ import MidEllipsis from "cozy-ui/transpiled/react/MidEllipsis";
8
9
  var getBoundT = models.document.locales.getBoundT;
9
10
 
10
11
  var Qualification = function Qualification(_ref) {
@@ -39,7 +40,9 @@ var Qualification = function Qualification(_ref) {
39
40
  className: 'u-ph-2'
40
41
  }, /*#__PURE__*/React.createElement(QualificationListItemText, {
41
42
  primary: t('Viewer.panel.qualification.label.title'),
42
- secondary: pageLabel ? t("Viewer.panel.qualification.label.".concat(pageLabel)) : filename
43
+ secondary: /*#__PURE__*/React.createElement(MidEllipsis, {
44
+ text: pageLabel ? t("Viewer.panel.qualification.label.".concat(pageLabel)) : filename
45
+ })
43
46
  })), /*#__PURE__*/React.createElement(ListItem, {
44
47
  className: 'u-ph-2'
45
48
  }, /*#__PURE__*/React.createElement(QualificationListItemText, {