cozy-harvest-lib 11.3.0 → 11.4.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,17 @@
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
+ # [11.4.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@11.3.0...cozy-harvest-lib@11.4.0) (2023-01-10)
7
+
8
+
9
+ ### Features
10
+
11
+ * **harvest:** Add success snackbar after successful synchronization ([242544e](https://github.com/cozy/cozy-libs/commit/242544ef5717062c76ae2a23b8326739bce57369))
12
+
13
+
14
+
15
+
16
+
6
17
  # [11.3.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@11.2.0...cozy-harvest-lib@11.3.0) (2023-01-04)
7
18
 
8
19
 
@@ -1,12 +1,15 @@
1
- import React from 'react';
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useState, useEffect } from 'react';
2
3
  import Alert from 'cozy-ui/transpiled/react/Alert';
3
4
  import Button from 'cozy-ui/transpiled/react/Buttons';
4
5
  import Typography from 'cozy-ui/transpiled/react/Typography';
5
6
  import Spinner from 'cozy-ui/transpiled/react/Spinner';
6
- import KonnectorIcon from '../KonnectorIcon';
7
+ import Snackbar from 'cozy-ui/transpiled/react/Snackbar';
7
8
  import { getLastSuccessDate, getKonnectorSlug } from '../../helpers/triggers';
8
9
  import { isRunnable } from '../../helpers/konnectors';
9
10
  import { useFlowState } from '../../models/withConnectionFlow';
11
+ import { SUCCESS } from '../../models/flowEvents';
12
+ import KonnectorIcon from '../KonnectorIcon';
10
13
  import { makeLabel } from './helpers';
11
14
  export var LaunchTriggerAlert = function LaunchTriggerAlert(_ref) {
12
15
  var flow = _ref.flow,
@@ -14,10 +17,16 @@ export var LaunchTriggerAlert = function LaunchTriggerAlert(_ref) {
14
17
  t = _ref.t,
15
18
  disabled = _ref.disabled;
16
19
 
20
+ var _useState = useState(false),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ showSuccessSnackbar = _useState2[0],
23
+ setShowSuccessSnackbar = _useState2[1];
24
+
17
25
  var _useFlowState = useFlowState(flow),
18
26
  trigger = _useFlowState.trigger,
19
27
  running = _useFlowState.running,
20
- expectingTriggerLaunch = _useFlowState.expectingTriggerLaunch;
28
+ expectingTriggerLaunch = _useFlowState.expectingTriggerLaunch,
29
+ status = _useFlowState.status;
21
30
 
22
31
  var launch = flow.launch,
23
32
  konnector = flow.konnector;
@@ -26,7 +35,12 @@ export var LaunchTriggerAlert = function LaunchTriggerAlert(_ref) {
26
35
  win: window,
27
36
  konnector: konnector
28
37
  });
29
- return /*#__PURE__*/React.createElement(Alert, {
38
+ useEffect(function () {
39
+ if (status === SUCCESS) {
40
+ setShowSuccessSnackbar(true);
41
+ }
42
+ }, [status]);
43
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Alert, {
30
44
  color: "var(--paperBackground)",
31
45
  icon: running ? /*#__PURE__*/React.createElement(Spinner, {
32
46
  className: "u-flex",
@@ -54,6 +68,18 @@ export var LaunchTriggerAlert = function LaunchTriggerAlert(_ref) {
54
68
  running: running,
55
69
  expectingTriggerLaunch: expectingTriggerLaunch,
56
70
  lastSuccessDate: lastSuccessDate
57
- })));
71
+ }))), /*#__PURE__*/React.createElement(Snackbar, {
72
+ open: showSuccessSnackbar,
73
+ onClose: function onClose() {
74
+ return setShowSuccessSnackbar(false);
75
+ }
76
+ }, /*#__PURE__*/React.createElement(Alert, {
77
+ variant: "filled",
78
+ elevation: 6,
79
+ severity: "success",
80
+ onClose: function onClose() {
81
+ return setShowSuccessSnackbar(false);
82
+ }
83
+ }, t('card.launchTrigger.success'))));
58
84
  };
59
85
  export default LaunchTriggerAlert;
@@ -77,6 +77,7 @@
77
77
  "button": {
78
78
  "label": "Run again now"
79
79
  },
80
+ "success": "Successful synchronization",
80
81
  "error": "An error occured.",
81
82
  "frequency": {
82
83
  "label": "Frequency:",
@@ -77,6 +77,7 @@
77
77
  "button": {
78
78
  "label": "Mettre à jour"
79
79
  },
80
+ "success": "Synchronisation réussie",
80
81
  "error": "Une erreur est survenue.",
81
82
  "frequency": {
82
83
  "label": "Fréquence :",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-harvest-lib",
3
- "version": "11.3.0",
3
+ "version": "11.4.0",
4
4
  "description": "Provides logic, modules and components for Cozy's harvest applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -90,5 +90,5 @@
90
90
  "react-router-dom": ">=4.3.1"
91
91
  },
92
92
  "sideEffects": false,
93
- "gitHead": "b79c5ad02f0c8a765122146353959fb32f2f3b3e"
93
+ "gitHead": "c2606cb995dfb001340033281f78008aa47cd55f"
94
94
  }
@@ -1,57 +1,83 @@
1
- import React from 'react'
1
+ import React, { useState, useEffect } from 'react'
2
2
 
3
3
  import Alert from 'cozy-ui/transpiled/react/Alert'
4
4
  import Button from 'cozy-ui/transpiled/react/Buttons'
5
5
  import Typography from 'cozy-ui/transpiled/react/Typography'
6
6
  import Spinner from 'cozy-ui/transpiled/react/Spinner'
7
+ import Snackbar from 'cozy-ui/transpiled/react/Snackbar'
7
8
 
8
- import KonnectorIcon from '../KonnectorIcon'
9
9
  import { getLastSuccessDate, getKonnectorSlug } from '../../helpers/triggers'
10
10
  import { isRunnable } from '../../helpers/konnectors'
11
11
  import { useFlowState } from '../../models/withConnectionFlow'
12
+ import { SUCCESS } from '../../models/flowEvents'
13
+ import KonnectorIcon from '../KonnectorIcon'
12
14
  import { makeLabel } from './helpers'
13
15
 
14
16
  export const LaunchTriggerAlert = ({ flow, f, t, disabled }) => {
15
- const { trigger, running, expectingTriggerLaunch } = useFlowState(flow)
17
+ const [showSuccessSnackbar, setShowSuccessSnackbar] = useState(false)
18
+ const { trigger, running, expectingTriggerLaunch, status } =
19
+ useFlowState(flow)
16
20
  const { launch, konnector } = flow
21
+
17
22
  const lastSuccessDate = getLastSuccessDate(trigger)
18
23
  const isKonnectorRunnable = isRunnable({ win: window, konnector })
19
24
 
25
+ useEffect(() => {
26
+ if (status === SUCCESS) {
27
+ setShowSuccessSnackbar(true)
28
+ }
29
+ }, [status])
30
+
20
31
  return (
21
- <Alert
22
- color="var(--paperBackground)"
23
- icon={
24
- running ? (
25
- <Spinner className="u-flex" noMargin />
26
- ) : (
27
- <KonnectorIcon
28
- className="u-w-1 u-h-1"
29
- konnectorSlug={getKonnectorSlug(trigger)}
30
- />
31
- )
32
- }
33
- action={
34
- isKonnectorRunnable && (
35
- <Button
36
- variant="text"
37
- size="small"
38
- disabled={running || disabled}
39
- label={t('card.launchTrigger.button.label')}
40
- onClick={() => launch({ autoSuccessTimer: false })}
41
- />
42
- )
43
- }
44
- >
45
- <Typography variant="caption">
46
- {makeLabel({
47
- t,
48
- f,
49
- running,
50
- expectingTriggerLaunch,
51
- lastSuccessDate
52
- })}
53
- </Typography>
54
- </Alert>
32
+ <>
33
+ <Alert
34
+ color="var(--paperBackground)"
35
+ icon={
36
+ running ? (
37
+ <Spinner className="u-flex" noMargin />
38
+ ) : (
39
+ <KonnectorIcon
40
+ className="u-w-1 u-h-1"
41
+ konnectorSlug={getKonnectorSlug(trigger)}
42
+ />
43
+ )
44
+ }
45
+ action={
46
+ isKonnectorRunnable && (
47
+ <Button
48
+ variant="text"
49
+ size="small"
50
+ disabled={running || disabled}
51
+ label={t('card.launchTrigger.button.label')}
52
+ onClick={() => launch({ autoSuccessTimer: false })}
53
+ />
54
+ )
55
+ }
56
+ >
57
+ <Typography variant="caption">
58
+ {makeLabel({
59
+ t,
60
+ f,
61
+ running,
62
+ expectingTriggerLaunch,
63
+ lastSuccessDate
64
+ })}
65
+ </Typography>
66
+ </Alert>
67
+ <Snackbar
68
+ open={showSuccessSnackbar}
69
+ onClose={() => setShowSuccessSnackbar(false)}
70
+ >
71
+ <Alert
72
+ variant="filled"
73
+ elevation={6}
74
+ severity="success"
75
+ onClose={() => setShowSuccessSnackbar(false)}
76
+ >
77
+ {t('card.launchTrigger.success')}
78
+ </Alert>
79
+ </Snackbar>
80
+ </>
55
81
  )
56
82
  }
57
83
 
@@ -77,6 +77,7 @@
77
77
  "button": {
78
78
  "label": "Run again now"
79
79
  },
80
+ "success": "Successful synchronization",
80
81
  "error": "An error occured.",
81
82
  "frequency": {
82
83
  "label": "Frequency:",
@@ -77,6 +77,7 @@
77
77
  "button": {
78
78
  "label": "Mettre à jour"
79
79
  },
80
+ "success": "Synchronisation réussie",
80
81
  "error": "Une erreur est survenue.",
81
82
  "frequency": {
82
83
  "label": "Fréquence :",