@truedat/audit 4.44.2 → 4.44.5
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 +6 -0
- package/package.json +21 -19
- package/src/components/EventsLoader.js +15 -11
- package/src/components/NotificationEvent.js +12 -1
- package/src/components/ShareLinkForm.js +2 -4
- package/src/components/Subscription.js +43 -22
- package/src/components/SubscriptionEdit.js +33 -18
- package/src/components/SubscriptionForm.js +6 -2
- package/src/components/SubscriptionLoader.js +26 -14
- package/src/components/SubscriptionNew.js +20 -8
- package/src/components/Subscriptions.js +22 -7
- package/src/components/SubscriptionsLoader.js +26 -13
- package/src/components/__tests__/NotificationEvent.spec.js +8 -9
- package/src/components/__tests__/ShareLinkForm.spec.js +14 -34
- package/src/components/__tests__/Subscription.spec.js +18 -27
- package/src/components/__tests__/SubscriptionEdit.spec.js +12 -20
- package/src/components/__tests__/SubscriptionForm.spec.js +51 -158
- package/src/components/__tests__/SubscriptionLoader.spec.js +4 -12
- package/src/components/__tests__/SubscriptionNew.spec.js +6 -13
- package/src/components/__tests__/Subscriptions.spec.js +26 -38
- package/src/components/__tests__/SubscriptionsLoader.spec.js +10 -9
- package/src/components/__tests__/__snapshots__/NotificationEvent.spec.js.snap +25 -44
- package/src/components/__tests__/__snapshots__/ShareLinkForm.spec.js.snap +6 -6
- package/src/components/__tests__/__snapshots__/Subscription.spec.js.snap +144 -75
- package/src/components/__tests__/__snapshots__/SubscriptionEdit.spec.js.snap +372 -22
- package/src/components/__tests__/__snapshots__/SubscriptionForm.spec.js.snap +22 -22
- package/src/components/__tests__/__snapshots__/SubscriptionLoader.spec.js.snap +16 -1
- package/src/components/__tests__/__snapshots__/SubscriptionNew.spec.js.snap +373 -16
- package/src/components/__tests__/__snapshots__/Subscriptions.spec.js.snap +339 -407
- package/src/components/__tests__/__snapshots__/SubscriptionsLoader.spec.js.snap +18 -1
- package/src/messages/en.js +0 -2
- package/src/messages/es.js +0 -2
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/audit",
|
|
3
|
-
"version": "4.44.
|
|
3
|
+
"version": "4.44.5",
|
|
4
4
|
"description": "Truedat Web Audit Module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -16,26 +16,26 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"clean": "rimraf yarn-error.log",
|
|
18
18
|
"debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
|
|
19
|
-
"test": "jest --coverage",
|
|
20
|
-
"test:watch": "jest --watch",
|
|
19
|
+
"test": "TZ=UTC jest --coverage",
|
|
20
|
+
"test:watch": "TZ=UTC jest --watch",
|
|
21
21
|
"eslint": "eslint src/**",
|
|
22
22
|
"eslint:fix": "eslint --fix src/**"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/cli": "^7.
|
|
26
|
-
"@babel/core": "^7.
|
|
27
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
28
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
29
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
25
|
+
"@babel/cli": "^7.17.10",
|
|
26
|
+
"@babel/core": "^7.18.0",
|
|
27
|
+
"@babel/plugin-proposal-class-properties": "^7.17.12",
|
|
28
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.18.0",
|
|
29
|
+
"@babel/plugin-proposal-optional-chaining": "^7.17.12",
|
|
30
30
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
31
|
-
"@babel/plugin-transform-modules-commonjs": "^7.
|
|
32
|
-
"@babel/preset-env": "^7.
|
|
33
|
-
"@babel/preset-react": "^7.
|
|
34
|
-
"@testing-library/jest-dom": "^5.
|
|
31
|
+
"@babel/plugin-transform-modules-commonjs": "^7.18.0",
|
|
32
|
+
"@babel/preset-env": "^7.18.0",
|
|
33
|
+
"@babel/preset-react": "^7.17.12",
|
|
34
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
35
35
|
"@testing-library/react": "^12.0.0",
|
|
36
36
|
"@testing-library/user-event": "^13.2.1",
|
|
37
|
-
"@truedat/test": "4.44.
|
|
38
|
-
"babel-jest": "^
|
|
37
|
+
"@truedat/test": "4.44.5",
|
|
38
|
+
"babel-jest": "^28.1.0",
|
|
39
39
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
40
40
|
"babel-plugin-lodash": "^3.3.4",
|
|
41
41
|
"babel-plugin-react-intl": "^5.1.18",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"enzyme-adapter-react-16": "^1.15.6",
|
|
45
45
|
"enzyme-to-json": "^3.6.2",
|
|
46
46
|
"identity-obj-proxy": "^3.0.0",
|
|
47
|
-
"jest": "^
|
|
47
|
+
"jest": "^28.1.0",
|
|
48
|
+
"jest-environment-jsdom": "^28.1.0",
|
|
48
49
|
"react": "^16.14.0",
|
|
49
50
|
"react-dom": "^16.14.0",
|
|
50
51
|
"redux-saga-test-plan": "^4.0.4",
|
|
@@ -84,14 +85,15 @@
|
|
|
84
85
|
]
|
|
85
86
|
},
|
|
86
87
|
"dependencies": {
|
|
87
|
-
"@truedat/auth": "4.44.
|
|
88
|
-
"@truedat/core": "4.44.
|
|
88
|
+
"@truedat/auth": "4.44.5",
|
|
89
|
+
"@truedat/core": "4.44.5",
|
|
89
90
|
"axios": "^0.19.2",
|
|
90
91
|
"path-to-regexp": "^1.7.0",
|
|
91
|
-
"prop-types": "^15.
|
|
92
|
+
"prop-types": "^15.8.1",
|
|
92
93
|
"react-color": "^2.17.3",
|
|
93
94
|
"react-hook-form": "^7.30.0",
|
|
94
95
|
"react-intl": "^5.20.10",
|
|
96
|
+
"react-moment": "^1.1.2",
|
|
95
97
|
"react-redux": "^7.2.4",
|
|
96
98
|
"react-router-dom": "^5.2.0",
|
|
97
99
|
"react-sortable-hoc": "^1.11.0",
|
|
@@ -105,5 +107,5 @@
|
|
|
105
107
|
"react-dom": ">= 16.8.6 < 17",
|
|
106
108
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
107
109
|
},
|
|
108
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "5a339468198c803592b285eddd0dd0c0b0eced93"
|
|
109
111
|
}
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
import { useEffect
|
|
2
|
-
import { useDispatch } from "react-redux";
|
|
1
|
+
import { useEffect } from "react";
|
|
3
2
|
import PropTypes from "prop-types";
|
|
3
|
+
import { connect } from "react-redux";
|
|
4
4
|
import { fetchEvents, clearEvents } from "../routines";
|
|
5
5
|
|
|
6
|
-
export const EventsLoader = ({
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export const EventsLoader = ({
|
|
7
|
+
resource_id,
|
|
8
|
+
resource_type,
|
|
9
|
+
fetchEvents,
|
|
10
|
+
clearEvents,
|
|
11
|
+
}) => {
|
|
9
12
|
useEffect(() => {
|
|
10
|
-
|
|
13
|
+
fetchEvents({ resource_id, resource_type });
|
|
11
14
|
return () => {
|
|
12
|
-
|
|
15
|
+
clearEvents();
|
|
13
16
|
};
|
|
14
|
-
|
|
15
|
-
}, [stableDispatch]);
|
|
17
|
+
}, [fetchEvents, clearEvents, resource_id, resource_type]);
|
|
16
18
|
return null;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
EventsLoader.propTypes = {
|
|
20
22
|
resource_id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
21
|
-
resource_type: PropTypes.string
|
|
23
|
+
resource_type: PropTypes.string,
|
|
24
|
+
fetchEvents: PropTypes.func,
|
|
25
|
+
clearEvents: PropTypes.func,
|
|
22
26
|
};
|
|
23
27
|
|
|
24
|
-
export default EventsLoader;
|
|
28
|
+
export default connect(null, { fetchEvents, clearEvents })(EventsLoader);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
2
3
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
3
4
|
import { Label } from "semantic-ui-react";
|
|
4
5
|
import Moment from "react-moment";
|
|
@@ -62,7 +63,10 @@ export const NotificationEvent = ({
|
|
|
62
63
|
</h4>
|
|
63
64
|
<p>{event.name}</p>
|
|
64
65
|
<Label>
|
|
65
|
-
<FormattedMessage
|
|
66
|
+
<FormattedMessage
|
|
67
|
+
id={`subscriptions.events.${event.event}`}
|
|
68
|
+
defaultMessage={event.event}
|
|
69
|
+
/>
|
|
66
70
|
</Label>
|
|
67
71
|
<Moment locale={locale} fromNow>
|
|
68
72
|
{date}
|
|
@@ -71,4 +75,11 @@ export const NotificationEvent = ({
|
|
|
71
75
|
);
|
|
72
76
|
};
|
|
73
77
|
|
|
78
|
+
NotificationEvent.propTypes = {
|
|
79
|
+
event: PropTypes.object,
|
|
80
|
+
date: PropTypes.instanceOf(Date),
|
|
81
|
+
readMark: PropTypes.bool,
|
|
82
|
+
readNotification: PropTypes.func,
|
|
83
|
+
};
|
|
84
|
+
|
|
74
85
|
export default NotificationEvent;
|
|
@@ -4,7 +4,7 @@ import { Button, Container, Form, Header, Ref } from "semantic-ui-react";
|
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import { useIntl } from "react-intl";
|
|
6
6
|
import { connect } from "react-redux";
|
|
7
|
-
import {
|
|
7
|
+
import { lowerDeburrTrim } from "@truedat/core/services/sort";
|
|
8
8
|
import { createNotification } from "../routines";
|
|
9
9
|
import { getRecipients } from "../selectors";
|
|
10
10
|
|
|
@@ -16,8 +16,6 @@ const GroupsSearchLoader = React.lazy(() =>
|
|
|
16
16
|
import("@truedat/auth/groups/components/GroupsSearchLoader")
|
|
17
17
|
);
|
|
18
18
|
|
|
19
|
-
const lowerDeburrTrim = _.flow(_.trim, lowerDeburr);
|
|
20
|
-
|
|
21
19
|
const MIN_SEARCH_CHARACTERS = 2;
|
|
22
20
|
|
|
23
21
|
export const ShareLinkForm = ({
|
|
@@ -127,7 +125,7 @@ export const ShareLinkForm = ({
|
|
|
127
125
|
disabled={_.isEmpty(selected) || saving}
|
|
128
126
|
loading={saving}
|
|
129
127
|
primary
|
|
130
|
-
content={formatMessage({ id: "
|
|
128
|
+
content={formatMessage({ id: "actions.share" })}
|
|
131
129
|
/>
|
|
132
130
|
</div>
|
|
133
131
|
</Form>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import { useSelector } from "react-redux";
|
|
5
4
|
import {
|
|
6
5
|
Header,
|
|
7
6
|
Grid,
|
|
@@ -49,11 +48,13 @@ SubscriptionHeader.propTypes = {
|
|
|
49
48
|
subheader: PropTypes.string,
|
|
50
49
|
};
|
|
51
50
|
|
|
52
|
-
export const Subscription = ({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
export const Subscription = ({
|
|
52
|
+
subscription,
|
|
53
|
+
subscriptionLoading: loading,
|
|
54
|
+
templates,
|
|
55
|
+
users,
|
|
56
|
+
}) => {
|
|
57
|
+
if (_.isEmpty(subscription) || loading) return null;
|
|
57
58
|
|
|
58
59
|
const { type, identifier } = _.getOr({}, "subscriber")(subscription);
|
|
59
60
|
const subscriber =
|
|
@@ -86,26 +87,32 @@ export const Subscription = ({ templates }) => {
|
|
|
86
87
|
<Segment>
|
|
87
88
|
<SubscriptionHeader header={subscriber} subheader={resourceName} />
|
|
88
89
|
<List size="big" relaxed="very">
|
|
90
|
+
{periodicity ? (
|
|
91
|
+
<List.Item>
|
|
92
|
+
<List.Header>
|
|
93
|
+
<FormattedMessage id="subscriptions.periodicity" />
|
|
94
|
+
</List.Header>
|
|
95
|
+
<List.Description>
|
|
96
|
+
<Label>
|
|
97
|
+
<FormattedMessage
|
|
98
|
+
id={`subscriptions.periodicity.${periodicity}`}
|
|
99
|
+
defaultMessage={periodicity}
|
|
100
|
+
/>
|
|
101
|
+
</Label>
|
|
102
|
+
</List.Description>
|
|
103
|
+
</List.Item>
|
|
104
|
+
) : null}
|
|
89
105
|
<List.Item>
|
|
90
106
|
<List.Header>
|
|
91
|
-
<FormattedMessage id=
|
|
92
|
-
</List.Header>
|
|
93
|
-
<List.Description>
|
|
94
|
-
<Label>
|
|
95
|
-
<FormattedMessage
|
|
96
|
-
id={`subscriptions.periodicity.${periodicity}`}
|
|
97
|
-
/>
|
|
98
|
-
</Label>
|
|
99
|
-
</List.Description>
|
|
100
|
-
</List.Item>
|
|
101
|
-
<List.Item>
|
|
102
|
-
<List.Header>
|
|
103
|
-
<FormattedMessage id={"subscriptions.events"} />
|
|
107
|
+
<FormattedMessage id="subscriptions.events" />
|
|
104
108
|
</List.Header>
|
|
105
109
|
<List.Description>
|
|
106
110
|
{events.map((event, idx) => (
|
|
107
111
|
<Label key={idx}>
|
|
108
|
-
<FormattedMessage
|
|
112
|
+
<FormattedMessage
|
|
113
|
+
id={`subscriptions.events.${event}`}
|
|
114
|
+
defaultMessage={event}
|
|
115
|
+
/>
|
|
109
116
|
</Label>
|
|
110
117
|
))}
|
|
111
118
|
</List.Description>
|
|
@@ -118,7 +125,10 @@ export const Subscription = ({ templates }) => {
|
|
|
118
125
|
<List.Description>
|
|
119
126
|
{status.map((status, idx) => (
|
|
120
127
|
<Label key={idx}>
|
|
121
|
-
<FormattedMessage
|
|
128
|
+
<FormattedMessage
|
|
129
|
+
id={`subscriptions.status.${status}`}
|
|
130
|
+
defaultMessage={status}
|
|
131
|
+
/>
|
|
122
132
|
</Label>
|
|
123
133
|
))}
|
|
124
134
|
</List.Description>
|
|
@@ -176,11 +186,22 @@ export const Subscription = ({ templates }) => {
|
|
|
176
186
|
};
|
|
177
187
|
|
|
178
188
|
Subscription.propTypes = {
|
|
189
|
+
subscription: PropTypes.object,
|
|
190
|
+
subscriptionLoading: PropTypes.bool,
|
|
179
191
|
templates: PropTypes.array,
|
|
192
|
+
users: PropTypes.array,
|
|
180
193
|
};
|
|
181
194
|
|
|
182
|
-
const mapStateToProps = ({
|
|
195
|
+
const mapStateToProps = ({
|
|
196
|
+
subscription,
|
|
197
|
+
subscriptionLoading,
|
|
198
|
+
templates,
|
|
199
|
+
users,
|
|
200
|
+
}) => ({
|
|
201
|
+
subscription,
|
|
202
|
+
subscriptionLoading,
|
|
183
203
|
templates,
|
|
204
|
+
users,
|
|
184
205
|
});
|
|
185
206
|
|
|
186
207
|
export default connect(mapStateToProps)(Subscription);
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
3
4
|
import { useIntl } from "react-intl";
|
|
4
|
-
import {
|
|
5
|
+
import { connect } from "react-redux";
|
|
5
6
|
import { Container, Segment, Header } from "semantic-ui-react";
|
|
6
7
|
import { updateSubscription } from "@truedat/core/routines";
|
|
7
8
|
import SubscriptionCrumbs from "./SubscriptionCrumbs";
|
|
8
9
|
import SubscriptionForm from "./SubscriptionForm";
|
|
9
10
|
|
|
10
|
-
export const SubscriptionEdit = (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
export const SubscriptionEdit = ({
|
|
12
|
+
subscription,
|
|
13
|
+
subscriptionLoading: loading,
|
|
14
|
+
users,
|
|
15
|
+
updateSubscription,
|
|
16
|
+
}) => {
|
|
15
17
|
const { formatMessage } = useIntl();
|
|
16
18
|
|
|
17
|
-
if (_.isEmpty(subscription) ||
|
|
19
|
+
if (_.isEmpty(subscription) || loading) return null;
|
|
18
20
|
|
|
19
|
-
const onSubmit = subscriptionChanges =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
28
|
-
);
|
|
21
|
+
const onSubmit = (subscriptionChanges) =>
|
|
22
|
+
updateSubscription({
|
|
23
|
+
subscription: {
|
|
24
|
+
...subscriptionChanges,
|
|
25
|
+
id: subscription.id,
|
|
26
|
+
},
|
|
27
|
+
redirect: true,
|
|
28
|
+
});
|
|
29
29
|
|
|
30
30
|
const { type, identifier } = _.getOr({}, "subscriber")(subscription);
|
|
31
31
|
const subscriber =
|
|
@@ -52,4 +52,19 @@ export const SubscriptionEdit = () => {
|
|
|
52
52
|
);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
SubscriptionEdit.propTypes = {
|
|
56
|
+
subscription: PropTypes.object,
|
|
57
|
+
subscriptionLoading: PropTypes.bool,
|
|
58
|
+
updateSubscription: PropTypes.func,
|
|
59
|
+
users: PropTypes.array,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const mapStateToProps = ({
|
|
63
|
+
subscription,
|
|
64
|
+
subscriptionLoading,
|
|
65
|
+
users,
|
|
66
|
+
}) => ({ subscription, subscriptionLoading, users });
|
|
67
|
+
|
|
68
|
+
export default connect(mapStateToProps, { updateSubscription })(
|
|
69
|
+
SubscriptionEdit
|
|
70
|
+
);
|
|
@@ -396,6 +396,7 @@ export const SubscriptionForm = ({
|
|
|
396
396
|
value: periodicity,
|
|
397
397
|
text: formatMessage({
|
|
398
398
|
id: `subscriptions.periodicity.${periodicity}`,
|
|
399
|
+
defaultMessage: periodicity,
|
|
399
400
|
}),
|
|
400
401
|
}))}
|
|
401
402
|
/>
|
|
@@ -427,7 +428,10 @@ export const SubscriptionForm = ({
|
|
|
427
428
|
options={eventsForType.map((event, key) => ({
|
|
428
429
|
key,
|
|
429
430
|
value: event,
|
|
430
|
-
text: formatMessage({
|
|
431
|
+
text: formatMessage({
|
|
432
|
+
id: `subscriptions.events.${event}`,
|
|
433
|
+
defaultMessage: event,
|
|
434
|
+
}),
|
|
431
435
|
}))}
|
|
432
436
|
/>
|
|
433
437
|
)}
|
|
@@ -483,7 +487,7 @@ export const SubscriptionForm = ({
|
|
|
483
487
|
type="submit"
|
|
484
488
|
loading={isLoading}
|
|
485
489
|
disabled={disabled}
|
|
486
|
-
content={formatMessage({ id: "actions.
|
|
490
|
+
content={formatMessage({ id: "actions.save" })}
|
|
487
491
|
/>
|
|
488
492
|
</div>
|
|
489
493
|
</Form>
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { connect } from "react-redux";
|
|
4
4
|
import { useParams } from "react-router-dom";
|
|
5
|
-
import { useDispatch } from "react-redux";
|
|
6
5
|
import { Dimmer, Loader } from "semantic-ui-react";
|
|
6
|
+
import { clearSubscription, fetchSubscription } from "../routines";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export const SubscriptionLoader = ({
|
|
9
|
+
clearSubscription,
|
|
10
|
+
fetchSubscription,
|
|
11
|
+
subscriptionLoading: loading,
|
|
12
|
+
}) => {
|
|
12
13
|
const { id } = useParams();
|
|
13
|
-
const dispatch = useDispatch();
|
|
14
|
-
const stableDispatch = useCallback(dispatch, []);
|
|
15
14
|
useEffect(() => {
|
|
16
|
-
|
|
15
|
+
fetchSubscription({ id });
|
|
17
16
|
return () => {
|
|
18
|
-
|
|
17
|
+
clearSubscription();
|
|
19
18
|
};
|
|
20
|
-
}, [id,
|
|
19
|
+
}, [id, clearSubscription, fetchSubscription]);
|
|
21
20
|
return loading ? (
|
|
22
21
|
<Dimmer active inverted>
|
|
23
22
|
<Loader size="massive" inverted />
|
|
@@ -25,4 +24,17 @@ export const SubscriptionLoader = () => {
|
|
|
25
24
|
) : null;
|
|
26
25
|
};
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
SubscriptionLoader.propTypes = {
|
|
28
|
+
clearSubscription: PropTypes.func,
|
|
29
|
+
fetchSubscription: PropTypes.func,
|
|
30
|
+
subscriptionLoading: PropTypes.bool,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const mapStateToProps = ({ subscriptionLoading }) => ({
|
|
34
|
+
subscriptionLoading,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export default connect(mapStateToProps, {
|
|
38
|
+
clearSubscription,
|
|
39
|
+
fetchSubscription,
|
|
40
|
+
})(SubscriptionLoader);
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
1
|
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
3
|
import { useIntl } from "react-intl";
|
|
4
|
-
import {
|
|
4
|
+
import { connect } from "react-redux";
|
|
5
5
|
import { Container, Segment, Header } from "semantic-ui-react";
|
|
6
6
|
import { createSubscription } from "@truedat/core/routines";
|
|
7
7
|
import SubscriptionCrumbs from "./SubscriptionCrumbs";
|
|
8
8
|
import SubscriptionForm from "./SubscriptionForm";
|
|
9
9
|
|
|
10
|
-
export const SubscriptionNew = (
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export const SubscriptionNew = ({
|
|
11
|
+
createSubscription,
|
|
12
|
+
creatingSubscription,
|
|
13
|
+
}) => {
|
|
13
14
|
const { formatMessage } = useIntl();
|
|
14
15
|
|
|
15
|
-
const onSubmit = subscription =>
|
|
16
|
-
|
|
16
|
+
const onSubmit = (subscription) =>
|
|
17
|
+
createSubscription({ subscription, redirect: true });
|
|
17
18
|
|
|
18
19
|
return (
|
|
19
20
|
<>
|
|
@@ -35,4 +36,15 @@ export const SubscriptionNew = () => {
|
|
|
35
36
|
);
|
|
36
37
|
};
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
SubscriptionNew.propTypes = {
|
|
40
|
+
createSubscription: PropTypes.func,
|
|
41
|
+
creatingSubscription: PropTypes.bool,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const mapStateToProps = ({ creatingSubscription }) => ({
|
|
45
|
+
creatingSubscription,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export default connect(mapStateToProps, { createSubscription })(
|
|
49
|
+
SubscriptionNew
|
|
50
|
+
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { connect } from "react-redux";
|
|
4
5
|
import { useForm, Controller } from "react-hook-form";
|
|
5
6
|
import { useHistory, Link } from "react-router-dom";
|
|
6
7
|
import { FormattedMessage } from "react-intl";
|
|
@@ -49,7 +50,11 @@ export const SubscriptionsHeader = () => (
|
|
|
49
50
|
</Header>
|
|
50
51
|
);
|
|
51
52
|
|
|
52
|
-
export const Subscriptions = (
|
|
53
|
+
export const Subscriptions = ({
|
|
54
|
+
subscriptions,
|
|
55
|
+
subscriptionsLoading: loading,
|
|
56
|
+
users,
|
|
57
|
+
}) => {
|
|
53
58
|
const history = useHistory();
|
|
54
59
|
const { control, watch } = useForm({
|
|
55
60
|
mode: "all",
|
|
@@ -59,10 +64,7 @@ export const Subscriptions = () => {
|
|
|
59
64
|
},
|
|
60
65
|
});
|
|
61
66
|
|
|
62
|
-
|
|
63
|
-
_.pick(["subscriptions", "subscriptionsLoading", "users"])
|
|
64
|
-
);
|
|
65
|
-
if (subscriptionsLoading) return null;
|
|
67
|
+
if (loading) return null;
|
|
66
68
|
|
|
67
69
|
const usersById = _.keyBy("id")(users);
|
|
68
70
|
const subscriberIcon = ({ type }) =>
|
|
@@ -201,6 +203,7 @@ export const Subscriptions = () => {
|
|
|
201
203
|
{periodicity && (
|
|
202
204
|
<FormattedMessage
|
|
203
205
|
id={`subscriptions.periodicity.${periodicity}`}
|
|
206
|
+
defaultMessage={periodicity}
|
|
204
207
|
/>
|
|
205
208
|
)}
|
|
206
209
|
</Table.Cell>
|
|
@@ -213,4 +216,16 @@ export const Subscriptions = () => {
|
|
|
213
216
|
);
|
|
214
217
|
};
|
|
215
218
|
|
|
216
|
-
|
|
219
|
+
Subscriptions.propTypes = {
|
|
220
|
+
subscriptions: PropTypes.array,
|
|
221
|
+
subscriptionsLoading: PropTypes.bool,
|
|
222
|
+
users: PropTypes.array,
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export const mapStateToProps = ({
|
|
226
|
+
subscriptions,
|
|
227
|
+
subscriptionsLoading,
|
|
228
|
+
users,
|
|
229
|
+
}) => ({ subscriptions, subscriptionsLoading, users });
|
|
230
|
+
|
|
231
|
+
export default connect(mapStateToProps)(Subscriptions);
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { connect } from "react-redux";
|
|
4
4
|
import { Dimmer, Loader } from "semantic-ui-react";
|
|
5
|
+
import { clearSubscriptions, fetchSubscriptions } from "../routines";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const stableDispatch = useCallback(dispatch, []);
|
|
7
|
+
export const SubscriptionsLoader = ({
|
|
8
|
+
clearSubscriptions,
|
|
9
|
+
fetchSubscriptions,
|
|
10
|
+
loading,
|
|
11
|
+
}) => {
|
|
12
12
|
useEffect(() => {
|
|
13
|
-
|
|
13
|
+
fetchSubscriptions();
|
|
14
14
|
return () => {
|
|
15
|
-
|
|
15
|
+
clearSubscriptions();
|
|
16
16
|
};
|
|
17
|
-
}, [
|
|
17
|
+
}, [clearSubscriptions, fetchSubscriptions]);
|
|
18
18
|
return loading ? (
|
|
19
19
|
<Dimmer active inverted>
|
|
20
20
|
<Loader size="massive" inverted />
|
|
@@ -22,4 +22,17 @@ export const SubscriptionsLoader = () => {
|
|
|
22
22
|
) : null;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
SubscriptionsLoader.propTypes = {
|
|
26
|
+
clearSubscriptions: PropTypes.func,
|
|
27
|
+
fetchSubscriptions: PropTypes.func,
|
|
28
|
+
loading: PropTypes.bool,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const mapStateToProps = ({ subscriptionsLoading }) => ({
|
|
32
|
+
loading: subscriptionsLoading,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export default connect(mapStateToProps, {
|
|
36
|
+
clearSubscriptions,
|
|
37
|
+
fetchSubscriptions,
|
|
38
|
+
})(SubscriptionsLoader);
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { NotificationEvent } from "../NotificationEvent";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import NotificationEvent from "../NotificationEvent";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
// see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
|
|
8
|
-
jest.spyOn(React, "useContext").mockImplementation(() => intl);
|
|
5
|
+
jest.mock("@truedat/core/hooks", () => ({ useOnScreen: jest.fn() }));
|
|
9
6
|
|
|
10
7
|
describe("<NotificationEvent />", () => {
|
|
11
8
|
it("matches the latest snapshot", () => {
|
|
12
9
|
const event = {
|
|
13
10
|
event: "comment_created",
|
|
14
|
-
name: "event name"
|
|
11
|
+
name: "event name",
|
|
15
12
|
};
|
|
16
13
|
const date = new Date("2020-01-01");
|
|
17
14
|
|
|
18
|
-
const
|
|
19
|
-
|
|
15
|
+
const { container } = render(
|
|
16
|
+
<NotificationEvent event={event} date={date} />
|
|
17
|
+
);
|
|
18
|
+
expect(container).toMatchSnapshot();
|
|
20
19
|
});
|
|
21
20
|
});
|