cozy-harvest-lib 6.13.0 → 6.14.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
@@ -3,6 +3,53 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [6.14.2](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@6.14.1...cozy-harvest-lib@6.14.2) (2021-11-22)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Handle undefined this.konnector for OAuth connectors ([9bea259](https://github.com/cozy/cozy-libs/commit/9bea259))
12
+
13
+
14
+
15
+
16
+
17
+ ## [6.14.1](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@6.14.0...cozy-harvest-lib@6.14.1) (2021-11-18)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * Harvest Konnector translation ([d7c13ca](https://github.com/cozy/cozy-libs/commit/d7c13ca))
23
+
24
+
25
+
26
+
27
+
28
+ # [6.14.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@6.13.1...cozy-harvest-lib@6.14.0) (2021-11-10)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * Change UI for geocard ([6408ecb](https://github.com/cozy/cozy-libs/commit/6408ecb))
34
+ * Harmonize title variant ([a4b7941](https://github.com/cozy/cozy-libs/commit/a4b7941))
35
+
36
+
37
+ ### Features
38
+
39
+ * Do not display AppLinkCard icon for GeoCard ([d9aadbd](https://github.com/cozy/cozy-libs/commit/d9aadbd))
40
+
41
+
42
+
43
+
44
+
45
+ ## [6.13.1](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@6.13.0...cozy-harvest-lib@6.13.1) (2021-11-09)
46
+
47
+ **Note:** Version bump only for package cozy-harvest-lib
48
+
49
+
50
+
51
+
52
+
6
53
  # [6.13.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@6.12.0...cozy-harvest-lib@6.13.0) (2021-11-08)
7
54
 
8
55
 
@@ -26,7 +26,6 @@ var appLinksProps = {
26
26
  coachco2: function coachco2() {
27
27
  return {
28
28
  slug: 'coachco2',
29
- icon: 'location',
30
29
  iconColor: 'brightSun'
31
30
  };
32
31
  }
@@ -66,14 +66,14 @@ var AppLinkCard = function AppLinkCard(_ref3) {
66
66
  return /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement(Stack, null, /*#__PURE__*/React.createElement(Typography, {
67
67
  variant: "h6",
68
68
  gutterBottom: true
69
- }, /*#__PURE__*/React.createElement(Circle, {
69
+ }, icon ? /*#__PURE__*/React.createElement(Circle, {
70
70
  size: "small",
71
71
  backgroundColor: palette[iconColor],
72
72
  className: "u-mr-half"
73
73
  }, /*#__PURE__*/React.createElement(Icon, {
74
74
  icon: icon,
75
75
  color: palette['white']
76
- })), t("card.appLink.".concat(slug, ".title"))), /*#__PURE__*/React.createElement(Typography, {
76
+ })) : null, t("card.appLink.".concat(slug, ".title"))), /*#__PURE__*/React.createElement(Typography, {
77
77
  variant: "body1"
78
78
  }, t("card.appLink.".concat(slug, ".description"))), /*#__PURE__*/React.createElement(AppLinkButton, {
79
79
  path: path,
@@ -17,13 +17,6 @@ import React from 'react';
17
17
  import PropTypes from 'prop-types';
18
18
  import { extend } from 'cozy-ui/transpiled/react/I18n';
19
19
  import { getDisplayName } from './utils';
20
- /**
21
- * Index of konnectors which locales have already extended the I18n.
22
- * For now we are not supposed to update konnector locales at runtime and we
23
- * should just load them once for all.
24
- */
25
-
26
- var loadedKonnectors = [];
27
20
  /**
28
21
  * HOC which ensures that a component get extended I18n with locales data from
29
22
  * konnector manifest.
@@ -44,12 +37,10 @@ export var withKonnectorLocales = function withKonnectorLocales(Component) {
44
37
  var _this$props = _this.props,
45
38
  konnector = _this$props.konnector,
46
39
  lang = _this$props.lang;
47
- if (loadedKonnectors.includes(konnector.slug)) return _possibleConstructorReturn(_this);
48
40
  var locales = konnector.locales;
49
41
 
50
42
  if (locales && lang) {
51
43
  extend(locales[lang]);
52
- loadedKonnectors.push(konnector.slug);
53
44
  }
54
45
 
55
46
  return _this;
@@ -35,7 +35,7 @@ import RightIcon from 'cozy-ui/transpiled/react/Icons/Right';
35
35
  import FlagIcon from 'cozy-ui/transpiled/react/Icons/Flag';
36
36
  import { useI18n } from 'cozy-ui/transpiled/react/I18n';
37
37
  import Stack from 'cozy-ui/transpiled/react/Stack';
38
- import AppLinkCard, { AppLinkButton } from '../components/cards/AppLinkCard';
38
+ import AppLinkCard from '../components/cards/AppLinkCard';
39
39
  import appLinksProps from '../components/KonnectorConfiguration/DataTab/appLinksProps';
40
40
  import useCycle from './useCycle';
41
41
  import { transformTimeSeriesToTrips, getStartPlaceDisplayName, getEndPlaceDisplayName, getFormattedDuration, getModes } from './trips';
@@ -242,7 +242,7 @@ var GeoDataCard = function GeoDataCard(_ref4) {
242
242
  }, /*#__PURE__*/React.createElement("div", {
243
243
  className: "u-ph-1 u-mb-half"
244
244
  }, /*#__PURE__*/React.createElement(Typography, {
245
- variant: "h5"
245
+ variant: "h6"
246
246
  }, t('datacards.trips.title')), /*#__PURE__*/React.createElement(Typography, {
247
247
  variant: "caption"
248
248
  }, t('datacards.trips.caption', {
@@ -291,11 +291,7 @@ var GeoDataCard = function GeoDataCard(_ref4) {
291
291
  }) : /*#__PURE__*/React.createElement(TripsMap, {
292
292
  trips: trips,
293
293
  index: index
294
- }), flag('harvest.datacard.coachCO2') ? /*#__PURE__*/React.createElement("div", {
295
- className: "u-ta-right u-mv-half u-mh-1"
296
- }, /*#__PURE__*/React.createElement(AppLinkButton, {
297
- slug: "coachco2"
298
- })) : null);
294
+ }));
299
295
  };
300
296
 
301
297
  var makeQueryFromProps = function makeQueryFromProps(_ref5) {
@@ -341,11 +337,11 @@ var DataGeoDataCard = function DataGeoDataCard(_ref6) {
341
337
  return null;
342
338
  }
343
339
 
344
- return /*#__PURE__*/React.createElement(GeoDataCard, {
340
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GeoDataCard, {
345
341
  trips: ascendingTrips,
346
342
  loading: isLoading,
347
343
  konnector: konnector
348
- });
344
+ }), flag('harvest.datacard.coachCO2') ? /*#__PURE__*/React.createElement(AppLinkCard, appLinksProps.coachco2()) : null);
349
345
  };
350
346
 
351
347
  DataGeoDataCard.propTypes = {
@@ -17,6 +17,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
17
17
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
18
18
 
19
19
  import MicroEE from 'microee';
20
+ import get from 'lodash/get';
20
21
  import Realtime from 'cozy-realtime';
21
22
  import flag from 'cozy-flags';
22
23
  import { fetchReusableAccount, saveAccount as _saveAccount, ACCOUNTS_DOCTYPE } from '../connections/accounts';
@@ -773,7 +774,7 @@ export var ConnectionFlow = /*#__PURE__*/function () {
773
774
  switch (_context10.prev = _context10.next) {
774
775
  case 0:
775
776
  _ref4 = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {}, _ref4$autoSuccessTime = _ref4.autoSuccessTimer, autoSuccessTimer = _ref4$autoSuccessTime === void 0 ? true : _ref4$autoSuccessTime;
776
- computedAutoSuccessTimer = autoSuccessTimer && !this.konnector.clientSide;
777
+ computedAutoSuccessTimer = autoSuccessTimer && !get(this, 'konnector.clientSide');
777
778
  logger.info('ConnectionFlow: Launching job...');
778
779
  this.setState({
779
780
  status: PENDING
@@ -791,7 +792,7 @@ export var ConnectionFlow = /*#__PURE__*/function () {
791
792
  case 11:
792
793
  this.job = _context10.sent;
793
794
 
794
- if (this.konnector.clientSide) {
795
+ if (get(this, 'konnector.clientSide')) {
795
796
  logger.info('This connector can be run by the launcher', this.konnector.slug);
796
797
  launcher = getLauncher({
797
798
  win: window
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-harvest-lib",
3
- "version": "6.13.0",
3
+ "version": "6.14.2",
4
4
  "description": "Provides logic, modules and components for Cozy's harvest applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -29,7 +29,7 @@
29
29
  "@cozy/minilog": "^1.0.0",
30
30
  "@sentry/browser": "^6.0.1",
31
31
  "cozy-bi-auth": "0.0.24",
32
- "cozy-doctypes": "^1.83.0",
32
+ "cozy-doctypes": "^1.83.1",
33
33
  "cozy-logger": "^1.7.0",
34
34
  "date-fns": "^1.30.1",
35
35
  "final-form": "^4.18.5",
@@ -85,5 +85,5 @@
85
85
  "react-router-dom": "^5.0.1"
86
86
  },
87
87
  "sideEffects": false,
88
- "gitHead": "a3ffe5f098d8adbe8e8ce93f97e1989f518c40bb"
88
+ "gitHead": "4accdb64b9d8d6798e31c4545c3bcf9a28c4cc17"
89
89
  }
@@ -19,7 +19,6 @@ const appLinksProps = {
19
19
  }),
20
20
  coachco2: () => ({
21
21
  slug: 'coachco2',
22
- icon: 'location',
23
22
  iconColor: 'brightSun'
24
23
  })
25
24
  }
@@ -60,13 +60,15 @@ const AppLinkCard = ({ slug, path, icon, iconColor }) => {
60
60
  <Card>
61
61
  <Stack>
62
62
  <Typography variant="h6" gutterBottom>
63
- <Circle
64
- size="small"
65
- backgroundColor={palette[iconColor]}
66
- className="u-mr-half"
67
- >
68
- <Icon icon={icon} color={palette['white']} />
69
- </Circle>
63
+ {icon ? (
64
+ <Circle
65
+ size="small"
66
+ backgroundColor={palette[iconColor]}
67
+ className="u-mr-half"
68
+ >
69
+ <Icon icon={icon} color={palette['white']} />
70
+ </Circle>
71
+ ) : null}
70
72
  {t(`card.appLink.${slug}.title`)}
71
73
  </Typography>
72
74
  <Typography variant="body1">
@@ -5,13 +5,6 @@ import { extend } from 'cozy-ui/transpiled/react/I18n'
5
5
 
6
6
  import { getDisplayName } from './utils'
7
7
 
8
- /**
9
- * Index of konnectors which locales have already extended the I18n.
10
- * For now we are not supposed to update konnector locales at runtime and we
11
- * should just load them once for all.
12
- */
13
- const loadedKonnectors = []
14
-
15
8
  /**
16
9
  * HOC which ensures that a component get extended I18n with locales data from
17
10
  * konnector manifest.
@@ -21,15 +14,11 @@ export const withKonnectorLocales = Component => {
21
14
  constructor(props, context) {
22
15
  super(props, context)
23
16
  const { konnector, lang } = this.props
24
- if (loadedKonnectors.includes(konnector.slug)) return
25
-
26
17
  const { locales } = konnector
27
18
  if (locales && lang) {
28
19
  extend(locales[lang])
29
- loadedKonnectors.push(konnector.slug)
30
20
  }
31
21
  }
32
-
33
22
  render() {
34
23
  return <Component {...this.props} />
35
24
  }
@@ -33,7 +33,7 @@ import FlagIcon from 'cozy-ui/transpiled/react/Icons/Flag'
33
33
  import { useI18n } from 'cozy-ui/transpiled/react/I18n'
34
34
  import Stack from 'cozy-ui/transpiled/react/Stack'
35
35
 
36
- import AppLinkCard, { AppLinkButton } from '../components/cards/AppLinkCard'
36
+ import AppLinkCard from '../components/cards/AppLinkCard'
37
37
  import appLinksProps from '../components/KonnectorConfiguration/DataTab/appLinksProps'
38
38
 
39
39
  import useCycle from './useCycle'
@@ -214,7 +214,7 @@ const GeoDataCard = ({ trips, loading, konnector }) => {
214
214
  return (
215
215
  <Card className="u-ph-0 u-pb-0 u-ov-hidden">
216
216
  <div className="u-ph-1 u-mb-half">
217
- <Typography variant="h5">{t('datacards.trips.title')}</Typography>
217
+ <Typography variant="h6">{t('datacards.trips.title')}</Typography>
218
218
  <Typography variant="caption">
219
219
  {t('datacards.trips.caption', { konnectorName: konnector.name })}
220
220
  </Typography>
@@ -261,11 +261,6 @@ const GeoDataCard = ({ trips, loading, konnector }) => {
261
261
  ) : (
262
262
  <TripsMap trips={trips} index={index} />
263
263
  )}
264
- {flag('harvest.datacard.coachCO2') ? (
265
- <div className="u-ta-right u-mv-half u-mh-1">
266
- <AppLinkButton slug="coachco2" />
267
- </div>
268
- ) : null}
269
264
  </Card>
270
265
  )
271
266
  }
@@ -306,11 +301,16 @@ const DataGeoDataCard = ({ timeseriesCol, konnector }) => {
306
301
  return null
307
302
  }
308
303
  return (
309
- <GeoDataCard
310
- trips={ascendingTrips}
311
- loading={isLoading}
312
- konnector={konnector}
313
- />
304
+ <>
305
+ <GeoDataCard
306
+ trips={ascendingTrips}
307
+ loading={isLoading}
308
+ konnector={konnector}
309
+ />
310
+ {flag('harvest.datacard.coachCO2') ? (
311
+ <AppLinkCard {...appLinksProps.coachco2()} />
312
+ ) : null}
313
+ </>
314
314
  )
315
315
  }
316
316
 
@@ -1,4 +1,5 @@
1
1
  import MicroEE from 'microee'
2
+ import get from 'lodash/get'
2
3
 
3
4
  import Realtime from 'cozy-realtime'
4
5
  import flag from 'cozy-flags'
@@ -483,7 +484,7 @@ export class ConnectionFlow {
483
484
  */
484
485
  async launch({ autoSuccessTimer = true } = {}) {
485
486
  const computedAutoSuccessTimer =
486
- autoSuccessTimer && !this.konnector.clientSide
487
+ autoSuccessTimer && !get(this, 'konnector.clientSide')
487
488
 
488
489
  logger.info('ConnectionFlow: Launching job...')
489
490
  this.setState({ status: PENDING })
@@ -501,7 +502,7 @@ export class ConnectionFlow {
501
502
 
502
503
  this.job = await launchTrigger(this.client, this.trigger)
503
504
 
504
- if (this.konnector.clientSide) {
505
+ if (get(this, 'konnector.clientSide')) {
505
506
  logger.info(
506
507
  'This connector can be run by the launcher',
507
508
  this.konnector.slug