@truedat/audit 4.36.7 → 4.36.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/audit",
3
- "version": "4.36.7",
3
+ "version": "4.36.8",
4
4
  "description": "Truedat Web Audit Module",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -47,7 +47,7 @@
47
47
  "jest": "^27.0.6",
48
48
  "react": "^16.14.0",
49
49
  "react-dom": "^16.14.0",
50
- "redux-saga-test-plan": "^4.0.1",
50
+ "redux-saga-test-plan": "^4.0.4",
51
51
  "rimraf": "^3.0.2",
52
52
  "semantic-ui-react": "^2.0.3"
53
53
  },
@@ -84,8 +84,8 @@
84
84
  ]
85
85
  },
86
86
  "dependencies": {
87
- "@truedat/auth": "4.36.7",
88
- "@truedat/core": "4.36.7",
87
+ "@truedat/auth": "4.36.8",
88
+ "@truedat/core": "4.36.8",
89
89
  "axios": "^0.19.2",
90
90
  "path-to-regexp": "^1.7.0",
91
91
  "prop-types": "^15.7.2",
@@ -105,5 +105,5 @@
105
105
  "react-dom": ">= 16.8.6 < 17",
106
106
  "semantic-ui-react": ">= 0.88.2 < 2.1"
107
107
  },
108
- "gitHead": "f5b0b7da7d61e1e8fff39337fe411f4174055b73"
108
+ "gitHead": "b9b8ee80998b230697593b5d207d187971bc0724"
109
109
  }
@@ -1,70 +1,77 @@
1
- import _ from "lodash/fp";
2
1
  import React from "react";
3
2
  import PropTypes from "prop-types";
4
3
  import { Link } from "react-router-dom";
5
- import { useSelector, useDispatch } from "react-redux";
4
+ import { connect } from "react-redux";
6
5
  import { Button } from "semantic-ui-react";
7
- import { FormattedMessage } from "react-intl";
6
+ import { useIntl } from "react-intl";
8
7
  import { ConfirmModal, GroupActions } from "@truedat/core/components";
9
8
  import { SUBSCRIPTIONS, linkTo } from "@truedat/core/routes";
10
9
  import { deleteSubscription } from "@truedat/core/routines";
11
10
 
12
- export const ModalDelete = ({ dispatch, id }) => (
13
- <ConfirmModal
14
- icon="trash"
15
- trigger={
16
- <Button
17
- icon="trash"
18
- content={<FormattedMessage id="subscription.actions.remove" />}
19
- />
20
- }
21
- header={
22
- <FormattedMessage id="subscription.actions.delete.confirmation.header" />
23
- }
24
- size="small"
25
- content={
26
- <FormattedMessage id="subscription.actions.delete.confirmation.content" />
27
- }
28
- handleSubmit={() =>
29
- dispatch(
11
+ export const ModalDelete = ({ deleteSubscription, id }) => {
12
+ const { formatMessage } = useIntl();
13
+ return (
14
+ <ConfirmModal
15
+ icon="trash"
16
+ trigger={
17
+ <Button
18
+ icon="trash"
19
+ content={formatMessage({ id: "subscription.actions.remove" })}
20
+ />
21
+ }
22
+ header={formatMessage({
23
+ id: "subscription.actions.delete.confirmation.header",
24
+ })}
25
+ size="small"
26
+ content={formatMessage({
27
+ id: "subscription.actions.delete.confirmation.content",
28
+ })}
29
+ onConfirm={() =>
30
30
  deleteSubscription({ subscription: { id }, redirect: SUBSCRIPTIONS })
31
- )
32
- }
33
- />
34
- );
35
- ModalDelete.propTypes = {
36
- dispatch: PropTypes.func,
37
- id: PropTypes.number
31
+ }
32
+ />
33
+ );
38
34
  };
39
35
 
40
- export const SubscriptionActions = () => {
41
- const dispatch = useDispatch();
42
- const { id } = useSelector(_.get("subscription"));
36
+ ModalDelete.propTypes = {
37
+ deleteSubscription: PropTypes.func,
38
+ id: PropTypes.number,
39
+ };
43
40
 
44
- const actions = [
45
- {
46
- key: "edit",
47
- icon: "edit",
48
- text: <FormattedMessage id="subscription.actions.edit" />,
49
- value: "edit",
50
- as: Link,
51
- to: linkTo.SUBSCRIPTION_EDIT({ id }),
52
- selected: false,
53
- active: false
54
- },
55
- {
56
- key: "delete",
57
- icon: "trash",
58
- value: "delete",
59
- as: ModalDelete,
60
- dispatch,
61
- id,
62
- selected: false,
63
- active: false
64
- }
65
- ];
41
+ export const SubscriptionActions = ({ deleteSubscription, subscription }) => {
42
+ const { formatMessage } = useIntl();
43
+ const id = subscription?.id;
44
+ const actions = id
45
+ ? [
46
+ {
47
+ key: "edit",
48
+ icon: "edit",
49
+ text: formatMessage({ id: "subscription.actions.edit" }),
50
+ value: "edit",
51
+ as: Link,
52
+ to: linkTo.SUBSCRIPTION_EDIT({ id }),
53
+ },
54
+ {
55
+ key: "delete",
56
+ icon: "trash",
57
+ value: "delete",
58
+ as: ModalDelete,
59
+ deleteSubscription,
60
+ id,
61
+ },
62
+ ]
63
+ : [];
66
64
 
67
65
  return <GroupActions availableActions={actions} />;
68
66
  };
69
67
 
70
- export default SubscriptionActions;
68
+ SubscriptionActions.propTypes = {
69
+ subscription: PropTypes.object,
70
+ deleteSubscription: PropTypes.func,
71
+ };
72
+
73
+ export const mapStateToProps = ({ subscription }) => ({ subscription });
74
+
75
+ export default connect(mapStateToProps, { deleteSubscription })(
76
+ SubscriptionActions
77
+ );
@@ -29,7 +29,7 @@ const StructureSelector = React.lazy(() =>
29
29
  );
30
30
 
31
31
  const SourceSelector = React.lazy(() =>
32
- import("@truedat/cx/sources/components/SourcesSelector")
32
+ import("@truedat/cx/sources/components/SourceSelector")
33
33
  );
34
34
 
35
35
  const SUBSCRIBER_TYPES = ["role", "taxonomy_role", "email", "user"];
@@ -1,39 +1,40 @@
1
1
  import React from "react";
2
- import { intl } from "@truedat/test/intl-stub";
3
- import { shallow } from "enzyme";
2
+ import { render } from "@truedat/test/render";
4
3
  import { SubscriptionActions, ModalDelete } from "../SubscriptionActions";
5
4
 
6
- jest.mock("react-redux", () => ({
7
- ...jest.requireActual("react-redux"),
8
- useDispatch: jest.fn(),
9
- useSelector: jest.fn(selector =>
10
- selector({
11
- subscription: {
12
- id: 2,
13
- subscriber: { type: "user" },
14
- scope: {
15
- events: ["event1"],
16
- status: ["status1"]
17
- }
18
- }
19
- })
20
- )
21
- }));
5
+ const messages = {
6
+ en: {
7
+ "subscription.actions.delete.confirmation.content": "content",
8
+ "subscription.actions.delete.confirmation.header": "header",
9
+ "subscription.actions.remove": "remove",
10
+ },
11
+ };
22
12
 
23
- // workaround for enzyme issue with React.useContext
24
- // see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
25
- jest.spyOn(React, "useContext").mockImplementation(() => intl);
13
+ const subscription = {
14
+ id: 2,
15
+ subscriber: { type: "user" },
16
+ scope: {
17
+ events: ["event1"],
18
+ status: ["status1"],
19
+ },
20
+ };
26
21
 
27
22
  describe("<SubscriptionActions />", () => {
23
+ const state = { subscription };
24
+ const renderOpts = { state, messages };
25
+
28
26
  it("matches the latest snapshot", () => {
29
- const wrapper = shallow(<SubscriptionActions />);
30
- expect(wrapper).toMatchSnapshot();
27
+ const { container } = render(<SubscriptionActions />, renderOpts);
28
+ expect(container).toMatchSnapshot();
31
29
  });
32
30
  });
33
31
 
34
32
  describe("<ModalDelete />", () => {
33
+ const state = {};
34
+ const renderOpts = { state, messages };
35
+
35
36
  it("matches the latest snapshot", () => {
36
- const wrapper = shallow(<ModalDelete />);
37
- expect(wrapper).toMatchSnapshot();
37
+ const { container } = render(<ModalDelete />, renderOpts);
38
+ expect(container).toMatchSnapshot();
38
39
  });
39
40
  });
@@ -84,7 +84,7 @@ exports[`<SubscriptionHeader /> matches the latest snapshot 1`] = `
84
84
  textAlign="right"
85
85
  width={4}
86
86
  >
87
- <SubscriptionActions />
87
+ <Connect(SubscriptionActions) />
88
88
  </GridColumn>
89
89
  </Grid>
90
90
  `;
@@ -1,73 +1,34 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`<ModalDelete /> matches the latest snapshot 1`] = `
4
- <ConfirmModal
5
- content={
6
- <Memo(MemoizedFormattedMessage)
7
- id="subscription.actions.delete.confirmation.content"
4
+ <div>
5
+ <button
6
+ class="ui button"
7
+ >
8
+ <i
9
+ aria-hidden="true"
10
+ class="trash icon"
8
11
  />
9
- }
10
- handleSubmit={[Function]}
11
- header={
12
- <Memo(MemoizedFormattedMessage)
13
- id="subscription.actions.delete.confirmation.header"
14
- />
15
- }
16
- icon="trash"
17
- size="small"
18
- trigger={
19
- <Button
20
- as="button"
21
- content={
22
- <Memo(MemoizedFormattedMessage)
23
- id="subscription.actions.remove"
24
- />
25
- }
26
- icon="trash"
27
- />
28
- }
29
- />
12
+ remove
13
+ </button>
14
+ </div>
30
15
  `;
31
16
 
32
17
  exports[`<SubscriptionActions /> matches the latest snapshot 1`] = `
33
- <GroupActions
34
- availableActions={
35
- Array [
36
- Object {
37
- "active": false,
38
- "as": Object {
39
- "$$typeof": Symbol(react.forward_ref),
40
- "displayName": "Link",
41
- "propTypes": Object {
42
- "innerRef": [Function],
43
- "onClick": [Function],
44
- "replace": [Function],
45
- "target": [Function],
46
- "to": [Function],
47
- },
48
- "render": [Function],
49
- },
50
- "icon": "edit",
51
- "key": "edit",
52
- "selected": false,
53
- "text": <Memo(MemoizedFormattedMessage)
54
- id="subscription.actions.edit"
55
- />,
56
- "to": "/subscriptions/2/edit",
57
- "value": "edit",
58
- },
59
- Object {
60
- "active": false,
61
- "as": [Function],
62
- "dispatch": undefined,
63
- "icon": "trash",
64
- "id": 2,
65
- "key": "delete",
66
- "selected": false,
67
- "value": "delete",
68
- },
69
- ]
70
- }
71
- direction="left"
72
- />
18
+ <div>
19
+ <div
20
+ aria-expanded="false"
21
+ class="ui floating dropdown button icon group-actions"
22
+ role="listbox"
23
+ tabindex="0"
24
+ >
25
+ <i
26
+ aria-hidden="true"
27
+ class="ellipsis vertical icon"
28
+ />
29
+ <div
30
+ class="left menu transition"
31
+ />
32
+ </div>
33
+ </div>
73
34
  `;