cozy-harvest-lib 30.7.0 → 30.8.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
@@ -3,6 +3,28 @@
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
+ # [30.8.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@30.7.1...cozy-harvest-lib@30.8.0) (2024-11-27)
7
+
8
+
9
+ ### Features
10
+
11
+ * **Harvest:** Add last sync time in KonnectorBlock ([2642af1](https://github.com/cozy/cozy-libs/commit/2642af127192d187b40c0c7b2c424a6abf8fc0fa))
12
+ * **Harvest:** Add link to store in KonnectorBlock ([ceb4608](https://github.com/cozy/cozy-libs/commit/ceb4608bd2c9a7aa2c34c41e58993ea799dc9a60))
13
+ * **Harvest:** Adjust KonnectorBlock style ([94e413b](https://github.com/cozy/cozy-libs/commit/94e413bae050d4ebad71de4fd1728fe9f12e2112))
14
+ * **Harvest:** Change wording in KonnectorBlock ([3b9cdfb](https://github.com/cozy/cozy-libs/commit/3b9cdfbba91ebe0c89071f75c12992ccd7c44ab8))
15
+
16
+
17
+
18
+
19
+
20
+ ## [30.7.1](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@30.7.0...cozy-harvest-lib@30.7.1) (2024-11-26)
21
+
22
+ **Note:** Version bump only for package cozy-harvest-lib
23
+
24
+
25
+
26
+
27
+
6
28
  # [30.7.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@30.6.5...cozy-harvest-lib@30.7.0) (2024-11-22)
7
29
 
8
30
 
@@ -5,8 +5,8 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  import cx from 'classnames';
6
6
  import get from 'lodash/get';
7
7
  import PropTypes from 'prop-types';
8
- import React, { useEffect, useState, useCallback } from 'react';
9
- import { useClient } from 'cozy-client';
8
+ import React, { useEffect, useState } from 'react';
9
+ import { useClient, generateWebLink } from 'cozy-client';
10
10
  import AppIcon from 'cozy-ui/transpiled/react/AppIcon';
11
11
  import Divider from 'cozy-ui/transpiled/react/Divider';
12
12
  import Icon from 'cozy-ui/transpiled/react/Icon';
@@ -15,12 +15,12 @@ import RightIcon from 'cozy-ui/transpiled/react/Icons/Right';
15
15
  import List from 'cozy-ui/transpiled/react/List';
16
16
  import ListItem from 'cozy-ui/transpiled/react/ListItem';
17
17
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
18
- import ListItemSecondaryAction from 'cozy-ui/transpiled/react/ListItemSecondaryAction';
19
18
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
20
19
  import Spinner from 'cozy-ui/transpiled/react/Spinner';
21
20
  import Typography from 'cozy-ui/transpiled/react/Typography';
22
21
  import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
23
22
  import Markdown from './Markdown';
23
+ import { makeLabel } from './cards/helpers';
24
24
  import withLocales from './hoc/withLocales';
25
25
  import { fetchKonnectorData } from '../helpers/konnectorBlock';
26
26
  /**
@@ -43,16 +43,14 @@ var KonnectorBlock = function KonnectorBlock(_ref) {
43
43
  t = _useI18n.t;
44
44
 
45
45
  var slug = get(file, 'cozyMetadata.uploadedBy.slug');
46
- var sourceAccountIdentifier = get(file, 'cozyMetadata.sourceAccountIdentifier'); // TODO To be removed when UI's AppIcon use getIconURL from Cozy-Client
47
- // instead of its own see https://github.com/cozy/cozy-ui/issues/1723
48
-
49
- var fetchIcon = useCallback(function () {
50
- return client.getStackClient().getIconURL({
51
- type: 'konnector',
52
- slug: slug,
53
- priority: 'registry'
54
- });
55
- }, [client, slug]);
46
+ var sourceAccountIdentifier = get(file, 'cozyMetadata.sourceAccountIdentifier');
47
+ var storeLink = generateWebLink({
48
+ slug: 'store',
49
+ cozyUrl: client.getStackClient().uri,
50
+ subDomainType: client.getInstanceOptions().subdomain,
51
+ pathname: '/',
52
+ hash: "/discover/".concat(slug)
53
+ });
56
54
  useEffect(function () {
57
55
  var fetchKonnector = /*#__PURE__*/function () {
58
56
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
@@ -109,6 +107,7 @@ var KonnectorBlock = function KonnectorBlock(_ref) {
109
107
  vendorLink = konnector.vendorLink,
110
108
  iconStatus = konnector.iconStatus,
111
109
  message = konnector.message,
110
+ trigger = konnector.trigger,
112
111
  fatalError = konnector.fatalError;
113
112
 
114
113
  if (fatalError) {
@@ -120,41 +119,57 @@ var KonnectorBlock = function KonnectorBlock(_ref) {
120
119
  }));
121
120
  }
122
121
 
122
+ var label = makeLabel({
123
+ t: t,
124
+ konnector: konnector,
125
+ trigger: trigger,
126
+ isRunning: trigger.current_state.status === 'running'
127
+ });
123
128
  return /*#__PURE__*/React.createElement(List, null, /*#__PURE__*/React.createElement(ListItem, {
124
- className: "u-ph-2 u-h-3",
125
129
  button: true,
126
130
  component: "a",
127
131
  href: link,
128
132
  target: "_blank"
129
133
  }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(AppIcon, {
130
134
  app: slug,
135
+ type: "konnector",
136
+ priority: "registry",
131
137
  className: cx({
132
138
  'u-filter-gray-100 u-o-50': iconStatus === 'disabled'
133
- }),
134
- fetchIcon: fetchIcon
139
+ })
135
140
  })), /*#__PURE__*/React.createElement(ListItemText, {
136
141
  primary: name,
137
142
  primaryTypographyProps: {
138
143
  variant: 'h6'
139
144
  },
140
- secondary: get(message, 'text'),
145
+ secondary: get(message, 'text', label),
141
146
  secondaryTypographyProps: get(message, 'color') && {
142
147
  color: message.color
143
148
  }
144
- }), /*#__PURE__*/React.createElement(ListItemSecondaryAction, null, /*#__PURE__*/React.createElement(Icon, {
145
- icon: RightIcon,
146
- className: "u-mr-1",
147
- color: "var(--secondaryTextColor)"
149
+ }), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
150
+ icon: RightIcon
148
151
  }))), /*#__PURE__*/React.createElement(Divider, {
149
152
  component: "li"
153
+ }), /*#__PURE__*/React.createElement(ListItem, {
154
+ button: true,
155
+ component: "a",
156
+ href: storeLink,
157
+ target: "_blank"
158
+ }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(AppIcon, {
159
+ app: "store",
160
+ className: "u-w-1 u-h-1"
161
+ })), /*#__PURE__*/React.createElement(ListItemText, {
162
+ primary: t('konnectorBlock.store.primary'),
163
+ secondary: t('konnectorBlock.store.secondary')
164
+ })), /*#__PURE__*/React.createElement(Divider, {
165
+ component: "li",
166
+ variant: "inset"
150
167
  }), /*#__PURE__*/React.createElement(ListItem, _extends({
151
- className: "u-ph-2",
152
168
  button: true
153
169
  }, vendorLink), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
154
- icon: GlobeIcon,
155
- color: "var(--primaryTextColor)"
170
+ icon: GlobeIcon
156
171
  })), /*#__PURE__*/React.createElement(ListItemText, {
157
- primary: t('konnectorBlock.account'),
172
+ primary: t('konnectorBlock.open'),
158
173
  secondary: get(vendorLink, 'href')
159
174
  })));
160
175
  };
@@ -52,6 +52,9 @@ describe('KonnectorBlock', function () {
52
52
  fetchKonnectorData.mockResolvedValue({
53
53
  name: 'Pajemploi',
54
54
  link: 'https://links.mycozy.cloud/home/connected/pajemploi/accounts/012345?fallback=http%3A%2F%2Fcozy-home.tools%3A8080%2F%23%2Fconnected%2Fpajemploi%2Faccounts%2F012345',
55
+ trigger: {
56
+ current_state: {}
57
+ },
55
58
  vendorLink: {
56
59
  component: 'a',
57
60
  href: 'https://www.pajemploi.urssaf.fr/',
@@ -74,7 +77,8 @@ describe('KonnectorBlock', function () {
74
77
  expect(getByText('Pajemploi').closest('a')).toHaveAttribute('href', "https://links.mycozy.cloud/home/connected/pajemploi/accounts/012345?fallback=".concat(encodeURIComponent('http://cozy-home.tools:8080/#/connected/pajemploi/accounts/012345')));
75
78
  expect(getByText('https://www.pajemploi.urssaf.fr/'));
76
79
  expect(getByText('https://www.pajemploi.urssaf.fr/').closest('a')).toHaveAttribute('href', 'https://www.pajemploi.urssaf.fr/');
77
- expect(getByText(en.konnectorBlock.account));
80
+ expect(getByText(en.konnectorBlock.store.primary));
81
+ expect(getByText(en.konnectorBlock.store.secondary));
78
82
  });
79
83
 
80
84
  case 5: