cozy-harvest-lib 12.1.0 → 12.3.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 +35 -0
- package/dist/components/AccountModalWithoutTabs/AccountModalContentWrapper.js +41 -0
- package/dist/components/AccountModalWithoutTabs/AccountModalHeader.js +36 -0
- package/dist/components/AccountModalWithoutTabs/AccountModalWithoutTabs.js +68 -0
- package/dist/components/AccountModalWithoutTabs/Error.js +38 -0
- package/dist/components/AccountModalWithoutTabs/FovV4Router/AccountModalContentWrapper.js +38 -0
- package/dist/components/AccountModalWithoutTabs/FovV4Router/AccountModalWithoutTabs.js +68 -0
- package/dist/components/AccountModalWithoutTabs/OpenOAuthWindowButton.js +74 -0
- package/dist/components/AccountModalWithoutTabs/TriggerError.js +41 -0
- package/dist/components/AccountModalWithoutTabs/TriggerErrorAction.js +33 -0
- package/dist/components/AccountModalWithoutTabs/helpers.js +6 -0
- package/dist/components/KonnectorConfiguration/ConfigurationTab/index.js +1 -1
- package/dist/components/KonnectorConfiguration/DataTab/index.js +6 -1
- package/dist/components/Routes/RoutesV4.js +52 -6
- package/dist/components/Routes/RoutesV6.js +37 -1
- package/dist/components/cards/LaunchTriggerAlert.js +41 -7
- package/dist/components/hoc/withRouter.js +2 -1
- package/dist/components/hoc/withRouter.spec.js +8 -0
- package/dist/connections/accounts.js +19 -0
- package/dist/helpers/accounts.js +71 -0
- package/dist/locales/en.json +2 -0
- package/dist/locales/fr.json +2 -0
- package/package.json +2 -2
- package/src/components/AccountModalWithoutTabs/AccountModalContentWrapper.jsx +37 -0
- package/src/components/AccountModalWithoutTabs/AccountModalHeader.jsx +45 -0
- package/src/components/AccountModalWithoutTabs/AccountModalWithoutTabs.jsx +80 -0
- package/src/components/AccountModalWithoutTabs/Error.jsx +38 -0
- package/src/components/AccountModalWithoutTabs/FovV4Router/AccountModalContentWrapper.jsx +40 -0
- package/src/components/AccountModalWithoutTabs/FovV4Router/AccountModalWithoutTabs.jsx +88 -0
- package/src/components/AccountModalWithoutTabs/OpenOAuthWindowButton.jsx +58 -0
- package/src/components/AccountModalWithoutTabs/TriggerError.jsx +46 -0
- package/src/components/AccountModalWithoutTabs/TriggerErrorAction.jsx +33 -0
- package/src/components/AccountModalWithoutTabs/helpers.js +10 -0
- package/src/components/KonnectorConfiguration/ConfigurationTab/index.jsx +1 -1
- package/src/components/KonnectorConfiguration/DataTab/index.jsx +17 -3
- package/src/components/Routes/RoutesV4.jsx +74 -14
- package/src/components/Routes/RoutesV6.jsx +77 -18
- package/src/components/cards/LaunchTriggerAlert.jsx +50 -8
- package/src/components/hoc/withRouter.jsx +2 -1
- package/src/components/hoc/withRouter.spec.jsx +6 -0
- package/src/connections/accounts.js +18 -0
- package/src/helpers/accounts.js +35 -0
- package/src/locales/en.json +2 -0
- package/src/locales/fr.json +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
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
|
+
# [12.3.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@12.2.0...cozy-harvest-lib@12.3.0) (2023-01-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **harvest:** Add missing props for ConfigurationTab ([b80b961](https://github.com/cozy/cozy-libs/commit/b80b961e4643e4b246686961e7001f61e04f31ac))
|
|
12
|
+
* **harvest:** Add missing translation for launchTrigger lastSync format ([b8fe298](https://github.com/cozy/cozy-libs/commit/b8fe298a514fccefb396ed2211a785d32b4901e1))
|
|
13
|
+
* **harvest:** WithRouter now handles route even without baseRoute ([6486e7f](https://github.com/cozy/cozy-libs/commit/6486e7ffa1ca61551ee8f59aed3e350b559f093e))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **harvest:** Add `/config` route on routerV4 and remove tabs ([79c6947](https://github.com/cozy/cozy-libs/commit/79c694721e23678238b3a06c06601ebf476314f1))
|
|
19
|
+
* **harvest:** Add `configure` option in LaunchTriggerAlert menu ([a3be41c](https://github.com/cozy/cozy-libs/commit/a3be41c0816b10166cfaabdeadfd53df6e72ec92))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [12.2.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@12.1.0...cozy-harvest-lib@12.2.0) (2023-01-11)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* **harvest:** Add AccountModalContentWrapper component ([748939e](https://github.com/cozy/cozy-libs/commit/748939e8cb20ef5b79c6a8e0b68dbd8afacec417))
|
|
31
|
+
* **harvest:** Add AccountModalHeader component ([7d17627](https://github.com/cozy/cozy-libs/commit/7d1762776000f78815ea00ff96b750e52e10649a))
|
|
32
|
+
* **harvest:** Add AccountModalWithoutTabs component ([afcf7f2](https://github.com/cozy/cozy-libs/commit/afcf7f28e94ad0f0685a515ecfdda4724b12bbaa))
|
|
33
|
+
* **harvest:** Add Error component ([4dd2c27](https://github.com/cozy/cozy-libs/commit/4dd2c273884619d158ee2d2d2d1376c073b4a336))
|
|
34
|
+
* **harvest:** Add Routes in RoutesV6 component ([59e37c3](https://github.com/cozy/cozy-libs/commit/59e37c3bc53b3b07e59e2517f0163d40981deca0))
|
|
35
|
+
* **harvest:** Add TriggerError component ([3a3866a](https://github.com/cozy/cozy-libs/commit/3a3866abfd88dcd1424187f408d10c308186100d))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
6
41
|
# [12.1.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@12.0.0...cozy-harvest-lib@12.1.0) (2023-01-11)
|
|
7
42
|
|
|
8
43
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useOutletContext } from 'react-router-dom';
|
|
3
|
+
import DialogContent from '@material-ui/core/DialogContent';
|
|
4
|
+
import useBreakpoints from 'cozy-ui/transpiled/react/hooks/useBreakpoints';
|
|
5
|
+
import FlowProvider from '../FlowProvider';
|
|
6
|
+
import TriggerError from './TriggerError';
|
|
7
|
+
|
|
8
|
+
var AccountModalContentWrapper = function AccountModalContentWrapper(_ref) {
|
|
9
|
+
var children = _ref.children;
|
|
10
|
+
|
|
11
|
+
var _useBreakpoints = useBreakpoints(),
|
|
12
|
+
isMobile = _useBreakpoints.isMobile;
|
|
13
|
+
|
|
14
|
+
var _useOutletContext = useOutletContext(),
|
|
15
|
+
trigger = _useOutletContext.trigger,
|
|
16
|
+
account = _useOutletContext.account,
|
|
17
|
+
konnector = _useOutletContext.konnector;
|
|
18
|
+
|
|
19
|
+
return /*#__PURE__*/React.createElement(DialogContent, {
|
|
20
|
+
className: isMobile ? 'u-p-0' : 'u-pt-0'
|
|
21
|
+
}, /*#__PURE__*/React.createElement(FlowProvider, {
|
|
22
|
+
initialTrigger: trigger,
|
|
23
|
+
konnector: konnector
|
|
24
|
+
}, function (_ref2) {
|
|
25
|
+
var flow = _ref2.flow;
|
|
26
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TriggerError, {
|
|
27
|
+
flow: flow,
|
|
28
|
+
konnector: konnector,
|
|
29
|
+
account: account,
|
|
30
|
+
trigger: trigger
|
|
31
|
+
}), React.Children.map(children, function (child) {
|
|
32
|
+
return /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
|
|
33
|
+
flow: flow,
|
|
34
|
+
trigger: trigger,
|
|
35
|
+
account: account
|
|
36
|
+
}) : null;
|
|
37
|
+
}));
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default AccountModalContentWrapper;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import AccountSelectBox from '../AccountSelectBox/AccountSelectBox';
|
|
4
|
+
import KonnectorModalHeader from '../KonnectorModalHeader';
|
|
5
|
+
import { withMountPointProps } from '../MountPointContext';
|
|
6
|
+
export var AccountModalHeader = function AccountModalHeader(_ref) {
|
|
7
|
+
var konnector = _ref.konnector,
|
|
8
|
+
account = _ref.account,
|
|
9
|
+
accountsAndTriggers = _ref.accountsAndTriggers,
|
|
10
|
+
showAccountSelection = _ref.showAccountSelection,
|
|
11
|
+
pushHistory = _ref.pushHistory;
|
|
12
|
+
return /*#__PURE__*/React.createElement(KonnectorModalHeader, {
|
|
13
|
+
konnector: konnector
|
|
14
|
+
}, showAccountSelection && /*#__PURE__*/React.createElement(AccountSelectBox, {
|
|
15
|
+
loading: !account,
|
|
16
|
+
selectedAccount: account,
|
|
17
|
+
accountsAndTriggers: accountsAndTriggers,
|
|
18
|
+
onChange: function onChange(option) {
|
|
19
|
+
pushHistory("/accounts/".concat(option.account._id));
|
|
20
|
+
},
|
|
21
|
+
onCreate: function onCreate() {
|
|
22
|
+
pushHistory('/new');
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
AccountModalHeader.defaultProps = {
|
|
27
|
+
showAccountSelection: true
|
|
28
|
+
};
|
|
29
|
+
AccountModalHeader.propTypes = {
|
|
30
|
+
konnector: PropTypes.object.isRequired,
|
|
31
|
+
account: PropTypes.object,
|
|
32
|
+
accountsAndTriggers: PropTypes.array.isRequired,
|
|
33
|
+
showAccountSelection: PropTypes.bool,
|
|
34
|
+
pushHistory: PropTypes.func.isRequired
|
|
35
|
+
};
|
|
36
|
+
export default withMountPointProps(AccountModalHeader);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
var _excluded = ["data"];
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { Outlet } from 'react-router-dom';
|
|
6
|
+
import DialogContent from '@material-ui/core/DialogContent';
|
|
7
|
+
import { useQuery, isQueryLoading } from 'cozy-client';
|
|
8
|
+
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
9
|
+
import { buildAccountQueryById } from '../../connections/accounts';
|
|
10
|
+
import { withMountPointProps } from '../MountPointContext';
|
|
11
|
+
import { getMatchingTrigger } from './helpers';
|
|
12
|
+
import AccountModalHeader from './AccountModalHeader';
|
|
13
|
+
import Error from './Error';
|
|
14
|
+
|
|
15
|
+
var AccountModalWithoutTabs = function AccountModalWithoutTabs(_ref) {
|
|
16
|
+
var accountsAndTriggers = _ref.accountsAndTriggers,
|
|
17
|
+
konnector = _ref.konnector,
|
|
18
|
+
accountId = _ref.accountId;
|
|
19
|
+
var matchingTrigger = getMatchingTrigger(accountsAndTriggers, accountId);
|
|
20
|
+
var matchingAccountId = matchingTrigger ? accountId : undefined;
|
|
21
|
+
|
|
22
|
+
var _buildAccountQueryByI = buildAccountQueryById(matchingAccountId),
|
|
23
|
+
definition = _buildAccountQueryByI.definition,
|
|
24
|
+
options = _buildAccountQueryByI.options;
|
|
25
|
+
|
|
26
|
+
var _useQuery = useQuery(definition, options),
|
|
27
|
+
accounts = _useQuery.data,
|
|
28
|
+
accountQueryResult = _objectWithoutProperties(_useQuery, _excluded);
|
|
29
|
+
|
|
30
|
+
var isLoading = isQueryLoading(accountQueryResult) || accountQueryResult.hasMore;
|
|
31
|
+
var isError = !isLoading && (!matchingTrigger || !accounts || (accounts === null || accounts === void 0 ? void 0 : accounts.length) === 0);
|
|
32
|
+
var account = accounts === null || accounts === void 0 ? void 0 : accounts[0];
|
|
33
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AccountModalHeader, {
|
|
34
|
+
konnector: konnector,
|
|
35
|
+
account: account,
|
|
36
|
+
accountsAndTriggers: accountsAndTriggers
|
|
37
|
+
}), (isError || isLoading) && /*#__PURE__*/React.createElement(DialogContent, {
|
|
38
|
+
className: "u-pb-2"
|
|
39
|
+
}, isError && /*#__PURE__*/React.createElement(Error, {
|
|
40
|
+
accountId: accountId,
|
|
41
|
+
accountsAndTriggers: accountsAndTriggers,
|
|
42
|
+
trigger: matchingTrigger,
|
|
43
|
+
lastError: accountQueryResult.lastError
|
|
44
|
+
}), isLoading && /*#__PURE__*/React.createElement(Spinner, {
|
|
45
|
+
className: "u-flex u-flex-justify-center",
|
|
46
|
+
size: "xxlarge"
|
|
47
|
+
})), !isError && !isLoading && /*#__PURE__*/React.createElement(Outlet, {
|
|
48
|
+
context: {
|
|
49
|
+
trigger: matchingTrigger,
|
|
50
|
+
account: account,
|
|
51
|
+
konnector: konnector
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
AccountModalWithoutTabs.propTypes = {
|
|
57
|
+
konnector: PropTypes.object.isRequired,
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @type {{ account: 'io.cozy.accounts', trigger: 'io.cozy.triggers' }[]} - An array of objects containing an account and its associated trigger
|
|
61
|
+
*/
|
|
62
|
+
accountsAndTriggers: PropTypes.arrayOf(PropTypes.shape({
|
|
63
|
+
account: PropTypes.object.isRequired,
|
|
64
|
+
trigger: PropTypes.object.isRequired
|
|
65
|
+
})).isRequired,
|
|
66
|
+
accountId: PropTypes.string.isRequired
|
|
67
|
+
};
|
|
68
|
+
export default withMountPointProps(AccountModalWithoutTabs);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useClient } from 'cozy-client';
|
|
3
|
+
import Infos from 'cozy-ui/transpiled/react/Infos';
|
|
4
|
+
import Button from 'cozy-ui/transpiled/react/Buttons';
|
|
5
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
6
|
+
import { loadSelectedAccountId } from '../../helpers/accounts';
|
|
7
|
+
import withLocales from '../hoc/withLocales';
|
|
8
|
+
|
|
9
|
+
var Error = function Error(_ref) {
|
|
10
|
+
var accountId = _ref.accountId,
|
|
11
|
+
accountsAndTriggers = _ref.accountsAndTriggers,
|
|
12
|
+
trigger = _ref.trigger,
|
|
13
|
+
lastError = _ref.lastError;
|
|
14
|
+
|
|
15
|
+
var _useI18n = useI18n(),
|
|
16
|
+
t = _useI18n.t;
|
|
17
|
+
|
|
18
|
+
var client = useClient();
|
|
19
|
+
var error = !trigger ? new Error('No matching trigger found') : lastError;
|
|
20
|
+
|
|
21
|
+
var handleClick = function handleClick() {
|
|
22
|
+
loadSelectedAccountId(client, accountId, accountsAndTriggers);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return /*#__PURE__*/React.createElement(Infos, {
|
|
26
|
+
actionButton: /*#__PURE__*/React.createElement(Button, {
|
|
27
|
+
label: t('modal.konnector.error.button'),
|
|
28
|
+
color: "error",
|
|
29
|
+
onClick: handleClick
|
|
30
|
+
}),
|
|
31
|
+
title: t('modal.konnector.error.title'),
|
|
32
|
+
text: t('modal.konnector.error.description', error),
|
|
33
|
+
icon: "warning",
|
|
34
|
+
isImportant: true
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default withLocales(Error);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import DialogContent from '@material-ui/core/DialogContent';
|
|
3
|
+
import useBreakpoints from 'cozy-ui/transpiled/react/hooks/useBreakpoints';
|
|
4
|
+
import FlowProvider from '../../FlowProvider';
|
|
5
|
+
import TriggerError from '../TriggerError';
|
|
6
|
+
|
|
7
|
+
var AccountModalContentWrapper = function AccountModalContentWrapper(_ref) {
|
|
8
|
+
var children = _ref.children,
|
|
9
|
+
trigger = _ref.trigger,
|
|
10
|
+
account = _ref.account,
|
|
11
|
+
konnector = _ref.konnector;
|
|
12
|
+
|
|
13
|
+
var _useBreakpoints = useBreakpoints(),
|
|
14
|
+
isMobile = _useBreakpoints.isMobile;
|
|
15
|
+
|
|
16
|
+
return /*#__PURE__*/React.createElement(DialogContent, {
|
|
17
|
+
className: isMobile ? 'u-p-0' : 'u-pt-0'
|
|
18
|
+
}, /*#__PURE__*/React.createElement(FlowProvider, {
|
|
19
|
+
initialTrigger: trigger,
|
|
20
|
+
konnector: konnector
|
|
21
|
+
}, function (_ref2) {
|
|
22
|
+
var flow = _ref2.flow;
|
|
23
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TriggerError, {
|
|
24
|
+
flow: flow,
|
|
25
|
+
konnector: konnector,
|
|
26
|
+
account: account,
|
|
27
|
+
trigger: trigger
|
|
28
|
+
}), React.Children.map(children, function (child) {
|
|
29
|
+
return /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
|
|
30
|
+
flow: flow,
|
|
31
|
+
trigger: trigger,
|
|
32
|
+
account: account
|
|
33
|
+
}) : null;
|
|
34
|
+
}));
|
|
35
|
+
}));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default AccountModalContentWrapper;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
var _excluded = ["data"];
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import DialogContent from '@material-ui/core/DialogContent';
|
|
6
|
+
import { useQuery, isQueryLoading } from 'cozy-client';
|
|
7
|
+
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
8
|
+
import { buildAccountQueryById } from '../../../connections/accounts';
|
|
9
|
+
import { withMountPointProps } from '../../MountPointContext';
|
|
10
|
+
import { getMatchingTrigger } from '../helpers';
|
|
11
|
+
import AccountModalHeader from '../AccountModalHeader';
|
|
12
|
+
import Error from '../Error';
|
|
13
|
+
|
|
14
|
+
var AccountModalWithoutTabs = function AccountModalWithoutTabs(_ref) {
|
|
15
|
+
var accountsAndTriggers = _ref.accountsAndTriggers,
|
|
16
|
+
konnector = _ref.konnector,
|
|
17
|
+
accountId = _ref.accountId,
|
|
18
|
+
children = _ref.children;
|
|
19
|
+
var matchingTrigger = getMatchingTrigger(accountsAndTriggers, accountId);
|
|
20
|
+
var matchingAccountId = matchingTrigger ? accountId : undefined;
|
|
21
|
+
|
|
22
|
+
var _buildAccountQueryByI = buildAccountQueryById(matchingAccountId),
|
|
23
|
+
definition = _buildAccountQueryByI.definition,
|
|
24
|
+
options = _buildAccountQueryByI.options;
|
|
25
|
+
|
|
26
|
+
var _useQuery = useQuery(definition, options),
|
|
27
|
+
accounts = _useQuery.data,
|
|
28
|
+
accountQueryResult = _objectWithoutProperties(_useQuery, _excluded);
|
|
29
|
+
|
|
30
|
+
var isLoading = isQueryLoading(accountQueryResult) || accountQueryResult.hasMore;
|
|
31
|
+
var isError = !isLoading && (!matchingTrigger || !accounts || (accounts === null || accounts === void 0 ? void 0 : accounts.length) === 0);
|
|
32
|
+
var account = accounts === null || accounts === void 0 ? void 0 : accounts[0];
|
|
33
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AccountModalHeader, {
|
|
34
|
+
konnector: konnector,
|
|
35
|
+
account: account,
|
|
36
|
+
accountsAndTriggers: accountsAndTriggers
|
|
37
|
+
}), (isError || isLoading) && /*#__PURE__*/React.createElement(DialogContent, {
|
|
38
|
+
className: "u-pb-2"
|
|
39
|
+
}, isError && /*#__PURE__*/React.createElement(Error, {
|
|
40
|
+
accountId: accountId,
|
|
41
|
+
accountsAndTriggers: accountsAndTriggers,
|
|
42
|
+
trigger: matchingTrigger,
|
|
43
|
+
lastError: accountQueryResult.lastError
|
|
44
|
+
}), isLoading && /*#__PURE__*/React.createElement(Spinner, {
|
|
45
|
+
className: "u-flex u-flex-justify-center",
|
|
46
|
+
size: "xxlarge"
|
|
47
|
+
})), !isError && !isLoading && React.Children.map(children, function (child) {
|
|
48
|
+
return /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
|
|
49
|
+
trigger: matchingTrigger,
|
|
50
|
+
account: account,
|
|
51
|
+
konnector: konnector
|
|
52
|
+
}) : null;
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
AccountModalWithoutTabs.propTypes = {
|
|
57
|
+
konnector: PropTypes.object.isRequired,
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @type {{ account: 'io.cozy.accounts', trigger: 'io.cozy.triggers' }[]} - An array of objects containing an account and its associated trigger
|
|
61
|
+
*/
|
|
62
|
+
accountsAndTriggers: PropTypes.arrayOf(PropTypes.shape({
|
|
63
|
+
account: PropTypes.object.isRequired,
|
|
64
|
+
trigger: PropTypes.object.isRequired
|
|
65
|
+
})).isRequired,
|
|
66
|
+
accountId: PropTypes.string.isRequired
|
|
67
|
+
};
|
|
68
|
+
export default withMountPointProps(AccountModalWithoutTabs);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import React, { useCallback } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import flag from 'cozy-flags';
|
|
6
|
+
import { useClient } from 'cozy-client';
|
|
7
|
+
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
8
|
+
import { Button } from 'cozy-ui/transpiled/react/Button';
|
|
9
|
+
import useOAuthExtraParams from '../hooks/useOAuthExtraParams';
|
|
10
|
+
import { OAUTH_SERVICE_OK, openOAuthWindow } from '../OAuthService';
|
|
11
|
+
|
|
12
|
+
var OpenOAuthWindowButton = function OpenOAuthWindowButton(_ref) {
|
|
13
|
+
var flow = _ref.flow,
|
|
14
|
+
account = _ref.account,
|
|
15
|
+
konnector = _ref.konnector;
|
|
16
|
+
|
|
17
|
+
var _useI18n = useI18n(),
|
|
18
|
+
t = _useI18n.t;
|
|
19
|
+
|
|
20
|
+
var client = useClient();
|
|
21
|
+
|
|
22
|
+
var _useOAuthExtraParams = useOAuthExtraParams({
|
|
23
|
+
account: account,
|
|
24
|
+
client: client,
|
|
25
|
+
konnector: konnector,
|
|
26
|
+
reconnect: true
|
|
27
|
+
}),
|
|
28
|
+
extraParams = _useOAuthExtraParams.extraParams;
|
|
29
|
+
|
|
30
|
+
var handleClick = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
31
|
+
var response;
|
|
32
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
33
|
+
while (1) {
|
|
34
|
+
switch (_context.prev = _context.next) {
|
|
35
|
+
case 0:
|
|
36
|
+
_context.next = 2;
|
|
37
|
+
return openOAuthWindow({
|
|
38
|
+
client: client,
|
|
39
|
+
konnector: konnector,
|
|
40
|
+
account: account,
|
|
41
|
+
extraParams: extraParams,
|
|
42
|
+
reconnect: true
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
case 2:
|
|
46
|
+
response = _context.sent;
|
|
47
|
+
|
|
48
|
+
if (response.result === OAUTH_SERVICE_OK && flag('harvest.bi.fullwebhooks')) {
|
|
49
|
+
flow.expectTriggerLaunch();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
case 4:
|
|
53
|
+
case "end":
|
|
54
|
+
return _context.stop();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}, _callee);
|
|
58
|
+
})), [account, client, extraParams, flow, konnector]);
|
|
59
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
60
|
+
className: "u-ml-0",
|
|
61
|
+
variant: "secondary",
|
|
62
|
+
label: t('error.reconnect-via-form'),
|
|
63
|
+
onClick: handleClick,
|
|
64
|
+
disabled: !extraParams,
|
|
65
|
+
busy: !extraParams
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
OpenOAuthWindowButton.propTypes = {
|
|
70
|
+
flow: PropTypes.object.isRequired,
|
|
71
|
+
account: PropTypes.object.isRequired,
|
|
72
|
+
konnector: PropTypes.object.isRequired
|
|
73
|
+
};
|
|
74
|
+
export default OpenOAuthWindowButton;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useClient } from 'cozy-client';
|
|
4
|
+
import useMaintenanceStatus from '../hooks/useMaintenanceStatus';
|
|
5
|
+
import TriggerErrorInfo from '../infos/TriggerErrorInfo';
|
|
6
|
+
import TriggerErrorAction from './TriggerErrorAction';
|
|
7
|
+
|
|
8
|
+
var TriggerError = function TriggerError(_ref) {
|
|
9
|
+
var flow = _ref.flow,
|
|
10
|
+
konnector = _ref.konnector,
|
|
11
|
+
account = _ref.account,
|
|
12
|
+
trigger = _ref.trigger;
|
|
13
|
+
var client = useClient();
|
|
14
|
+
var flowState = flow.getState();
|
|
15
|
+
var error = flowState.error;
|
|
16
|
+
|
|
17
|
+
var _useMaintenanceStatus = useMaintenanceStatus(client, konnector),
|
|
18
|
+
isInMaintenance = _useMaintenanceStatus.data.isInMaintenance;
|
|
19
|
+
|
|
20
|
+
if (!error || isInMaintenance) return null;
|
|
21
|
+
return /*#__PURE__*/React.createElement(TriggerErrorInfo, {
|
|
22
|
+
error: error,
|
|
23
|
+
konnector: konnector,
|
|
24
|
+
action: /*#__PURE__*/React.createElement(TriggerErrorAction, {
|
|
25
|
+
error: error,
|
|
26
|
+
flow: flow,
|
|
27
|
+
konnector: konnector,
|
|
28
|
+
account: account,
|
|
29
|
+
trigger: trigger
|
|
30
|
+
}),
|
|
31
|
+
className: "u-mt-1"
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default TriggerError;
|
|
36
|
+
TriggerError.propTypes = {
|
|
37
|
+
flow: PropTypes.object.isRequired,
|
|
38
|
+
konnector: PropTypes.object.isRequired,
|
|
39
|
+
account: PropTypes.object,
|
|
40
|
+
trigger: PropTypes.object
|
|
41
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { findKonnectorPolicy } from '../../konnector-policies';
|
|
4
|
+
import RedirectToAccountFormButton from '../RedirectToAccountFormButton';
|
|
5
|
+
import OpenOAuthWindowButton from './OpenOAuthWindowButton';
|
|
6
|
+
|
|
7
|
+
var TriggerErrorAction = function TriggerErrorAction(_ref) {
|
|
8
|
+
var flow = _ref.flow,
|
|
9
|
+
konnector = _ref.konnector,
|
|
10
|
+
account = _ref.account,
|
|
11
|
+
trigger = _ref.trigger,
|
|
12
|
+
error = _ref.error;
|
|
13
|
+
var konnectorPolicy = findKonnectorPolicy(konnector);
|
|
14
|
+
if (!error.isSolvableViaReconnect()) return null;
|
|
15
|
+
if (konnectorPolicy.isBIWebView) return /*#__PURE__*/React.createElement(OpenOAuthWindowButton, {
|
|
16
|
+
flow: flow,
|
|
17
|
+
account: account,
|
|
18
|
+
konnector: konnector
|
|
19
|
+
});
|
|
20
|
+
return /*#__PURE__*/React.createElement(RedirectToAccountFormButton, {
|
|
21
|
+
konnector: konnector,
|
|
22
|
+
trigger: trigger
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
TriggerErrorAction.propTypes = {
|
|
27
|
+
flow: PropTypes.object.isRequired,
|
|
28
|
+
konnector: PropTypes.object.isRequired,
|
|
29
|
+
account: PropTypes.object,
|
|
30
|
+
trigger: PropTypes.object,
|
|
31
|
+
error: PropTypes.object.isRequired
|
|
32
|
+
};
|
|
33
|
+
export default TriggerErrorAction;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
export var getMatchingTrigger = function getMatchingTrigger(accountsAndTriggers, accountId) {
|
|
3
|
+
return get(accountsAndTriggers.find(function (accountAndTrigger) {
|
|
4
|
+
return accountAndTrigger.account._id === accountId;
|
|
5
|
+
}), 'trigger');
|
|
6
|
+
};
|
|
@@ -278,7 +278,7 @@ var ConfigurationTab = function ConfigurationTab(_ref2) {
|
|
|
278
278
|
|
|
279
279
|
ConfigurationTab.propTypes = {
|
|
280
280
|
konnector: PropTypes.object.isRequired,
|
|
281
|
-
account: PropTypes.object
|
|
281
|
+
account: PropTypes.object,
|
|
282
282
|
error: PropTypes.object,
|
|
283
283
|
flow: PropTypes.object,
|
|
284
284
|
addAccount: PropTypes.func.isRequired,
|
|
@@ -27,6 +27,7 @@ var styles = {
|
|
|
27
27
|
};
|
|
28
28
|
export var DataTab = function DataTab(_ref) {
|
|
29
29
|
var konnector = _ref.konnector,
|
|
30
|
+
konnectorRoot = _ref.konnectorRoot,
|
|
30
31
|
trigger = _ref.trigger,
|
|
31
32
|
client = _ref.client,
|
|
32
33
|
flow = _ref.flow,
|
|
@@ -56,6 +57,7 @@ export var DataTab = function DataTab(_ref) {
|
|
|
56
57
|
maintenanceMessages = _useMaintenanceStatus2.messages;
|
|
57
58
|
|
|
58
59
|
return /*#__PURE__*/React.createElement("div", null, flag('harvest.inappconnectors.enabled') && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LaunchTriggerCard, {
|
|
60
|
+
konnectorRoot: konnectorRoot,
|
|
59
61
|
flow: flow,
|
|
60
62
|
disabled: isInMaintenance
|
|
61
63
|
}), isMobile && /*#__PURE__*/React.createElement(Divider, {
|
|
@@ -90,7 +92,10 @@ export var DataTab = function DataTab(_ref) {
|
|
|
90
92
|
};
|
|
91
93
|
DataTab.propTypes = {
|
|
92
94
|
konnector: PropTypes.object.isRequired,
|
|
95
|
+
konnectorRoot: PropTypes.string,
|
|
93
96
|
trigger: PropTypes.object.isRequired,
|
|
94
|
-
client: PropTypes.object.isRequired
|
|
97
|
+
client: PropTypes.object.isRequired,
|
|
98
|
+
flow: PropTypes.object,
|
|
99
|
+
account: PropTypes.object
|
|
95
100
|
};
|
|
96
101
|
export default withClient(DataTab);
|
|
@@ -7,11 +7,17 @@ import NewAccountModal from '../NewAccountModal';
|
|
|
7
7
|
import EditAccountModal from '../EditAccountModal';
|
|
8
8
|
import KonnectorSuccess from '../KonnectorSuccess';
|
|
9
9
|
import HarvestModalRoot from '../HarvestModalRoot';
|
|
10
|
+
import AccountModalWithoutTabs from '../AccountModalWithoutTabs/FovV4Router/AccountModalWithoutTabs';
|
|
11
|
+
import AccountModalContentWrapper from '../AccountModalWithoutTabs/FovV4Router/AccountModalContentWrapper';
|
|
12
|
+
import DataTab from '../KonnectorConfiguration/DataTab';
|
|
13
|
+
import ConfigurationTab from '../KonnectorConfiguration/ConfigurationTab';
|
|
14
|
+
import withAdaptiveRouter from '../hoc/withRouter';
|
|
10
15
|
|
|
11
16
|
var RoutesV4 = function RoutesV4(_ref) {
|
|
12
17
|
var konnectorRoot = _ref.konnectorRoot,
|
|
13
18
|
konnectorWithTriggers = _ref.konnectorWithTriggers,
|
|
14
19
|
accountsAndTriggers = _ref.accountsAndTriggers,
|
|
20
|
+
historyAction = _ref.historyAction,
|
|
15
21
|
onSuccess = _ref.onSuccess,
|
|
16
22
|
onDismiss = _ref.onDismiss;
|
|
17
23
|
return /*#__PURE__*/React.createElement(Switch, null, /*#__PURE__*/React.createElement(Route, {
|
|
@@ -23,11 +29,51 @@ var RoutesV4 = function RoutesV4(_ref) {
|
|
|
23
29
|
konnector: konnectorWithTriggers
|
|
24
30
|
});
|
|
25
31
|
}
|
|
26
|
-
}), /*#__PURE__*/React.createElement(Route, {
|
|
32
|
+
}), flag('harvest.inappconnectors.enabled') ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Route, {
|
|
27
33
|
path: "".concat(konnectorRoot, "/accounts/:accountId"),
|
|
28
34
|
exact: true,
|
|
29
35
|
render: function render(_ref2) {
|
|
30
36
|
var match = _ref2.match;
|
|
37
|
+
return /*#__PURE__*/React.createElement(AccountModalWithoutTabs, {
|
|
38
|
+
konnector: konnectorWithTriggers,
|
|
39
|
+
accountId: match.params.accountId,
|
|
40
|
+
accountsAndTriggers: accountsAndTriggers,
|
|
41
|
+
showNewAccountButton: !konnectorWithTriggers.clientSide,
|
|
42
|
+
showAccountSelection: !konnectorWithTriggers.clientSide,
|
|
43
|
+
onDismiss: onDismiss
|
|
44
|
+
}, /*#__PURE__*/React.createElement(AccountModalContentWrapper, null, /*#__PURE__*/React.createElement(DataTab, {
|
|
45
|
+
konnectorRoot: "".concat(konnectorRoot, "/accounts/").concat(match.params.accountId),
|
|
46
|
+
konnector: konnectorWithTriggers,
|
|
47
|
+
showNewAccountButton: !konnectorWithTriggers.clientSide,
|
|
48
|
+
onDismiss: onDismiss
|
|
49
|
+
})));
|
|
50
|
+
}
|
|
51
|
+
}), /*#__PURE__*/React.createElement(Route, {
|
|
52
|
+
path: "".concat(konnectorRoot, "/accounts/:accountId/config"),
|
|
53
|
+
exact: true,
|
|
54
|
+
render: function render(_ref3) {
|
|
55
|
+
var match = _ref3.match;
|
|
56
|
+
return /*#__PURE__*/React.createElement(AccountModalWithoutTabs, {
|
|
57
|
+
konnector: konnectorWithTriggers,
|
|
58
|
+
accountId: match.params.accountId,
|
|
59
|
+
accountsAndTriggers: accountsAndTriggers,
|
|
60
|
+
showNewAccountButton: !konnectorWithTriggers.clientSide,
|
|
61
|
+
showAccountSelection: !konnectorWithTriggers.clientSide,
|
|
62
|
+
onDismiss: onDismiss
|
|
63
|
+
}, /*#__PURE__*/React.createElement(AccountModalContentWrapper, null, /*#__PURE__*/React.createElement(ConfigurationTab, {
|
|
64
|
+
konnector: konnectorWithTriggers,
|
|
65
|
+
showNewAccountButton: !konnectorWithTriggers.clientSide,
|
|
66
|
+
onAccountDeleted: onDismiss,
|
|
67
|
+
addAccount: function addAccount() {
|
|
68
|
+
return historyAction("".concat(konnectorRoot, "/new"), 'replace');
|
|
69
|
+
}
|
|
70
|
+
})));
|
|
71
|
+
}
|
|
72
|
+
})) : /*#__PURE__*/React.createElement(Route, {
|
|
73
|
+
path: "".concat(konnectorRoot, "/accounts/:accountId"),
|
|
74
|
+
exact: true,
|
|
75
|
+
render: function render(_ref4) {
|
|
76
|
+
var match = _ref4.match;
|
|
31
77
|
return /*#__PURE__*/React.createElement(AccountModal, {
|
|
32
78
|
konnector: konnectorWithTriggers,
|
|
33
79
|
accountId: match.params.accountId,
|
|
@@ -40,8 +86,8 @@ var RoutesV4 = function RoutesV4(_ref) {
|
|
|
40
86
|
}), /*#__PURE__*/React.createElement(Route, {
|
|
41
87
|
path: "".concat(konnectorRoot, "/accounts/:accountId/edit"),
|
|
42
88
|
exact: true,
|
|
43
|
-
render: function render(
|
|
44
|
-
var match =
|
|
89
|
+
render: function render(_ref5) {
|
|
90
|
+
var match = _ref5.match;
|
|
45
91
|
return /*#__PURE__*/React.createElement(EditAccountModal, {
|
|
46
92
|
konnector: konnectorWithTriggers,
|
|
47
93
|
accountId: match.params.accountId,
|
|
@@ -67,8 +113,8 @@ var RoutesV4 = function RoutesV4(_ref) {
|
|
|
67
113
|
}), !flag('harvest.inappconnectors.enabled') && /*#__PURE__*/React.createElement(Route, {
|
|
68
114
|
path: "".concat(konnectorRoot, "/accounts/:accountId/success"),
|
|
69
115
|
exact: true,
|
|
70
|
-
render: function render(
|
|
71
|
-
var match =
|
|
116
|
+
render: function render(_ref6) {
|
|
117
|
+
var match = _ref6.match;
|
|
72
118
|
return /*#__PURE__*/React.createElement(KonnectorSuccess, {
|
|
73
119
|
konnector: konnectorWithTriggers,
|
|
74
120
|
accountId: match.params.accountId,
|
|
@@ -82,4 +128,4 @@ var RoutesV4 = function RoutesV4(_ref) {
|
|
|
82
128
|
}));
|
|
83
129
|
};
|
|
84
130
|
|
|
85
|
-
export default RoutesV4;
|
|
131
|
+
export default withAdaptiveRouter(RoutesV4);
|