@truedat/audit 4.28.5 → 4.29.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
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.28.7] 2021-09-20
4
+
5
+ ### Added
6
+
7
+ - [TD-3780] Support for `taxonomy_role` subscriptor type
8
+
3
9
  ## [4.27.7] 2021-09-06
4
10
 
5
11
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/audit",
3
- "version": "4.28.5",
3
+ "version": "4.29.0",
4
4
  "description": "Truedat Web Audit Module",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/jest-dom": "^5.14.1",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "4.28.5",
37
+ "@truedat/test": "4.29.0",
38
38
  "babel-jest": "^27.0.6",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -84,8 +84,8 @@
84
84
  ]
85
85
  },
86
86
  "dependencies": {
87
- "@truedat/auth": "4.28.5",
88
- "@truedat/core": "4.28.5",
87
+ "@truedat/auth": "4.29.0",
88
+ "@truedat/core": "4.29.0",
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": "e004c6a673d6824a4807e4378b6e5c83e947c992"
108
+ "gitHead": "42028609748cd7f1686ea783264a9cdfa7b0ca8f"
109
109
  }
@@ -28,7 +28,7 @@ const StructureSelector = React.lazy(() =>
28
28
  import("@truedat/dd/components/StructureSelector")
29
29
  );
30
30
 
31
- const SUBSCRIBER_TYPES = ["role", "email", "user"];
31
+ const SUBSCRIBER_TYPES = ["role", "taxonomy_role", "email", "user"];
32
32
  const PERIODICITIES = ["daily", "minutely", "hourly"];
33
33
  const RESOURCE_TYPES = [
34
34
  "domain",
@@ -66,7 +66,9 @@ export const SubscriptionForm = ({
66
66
  const { formatMessage } = useIntl();
67
67
  const [selectedConceptType, setSelectedConceptType] = useState();
68
68
  const [resource, setResource] = useState();
69
+
69
70
  const { SUBSCRIBER_TYPE_ICONS, DEFAULT_ICON, RESOURCE_TYPE_ICONS } = icons;
71
+
70
72
  const { handleSubmit, control, formState, setValue, watch } = useForm({
71
73
  mode: "all",
72
74
  defaultValues: {
@@ -169,13 +171,21 @@ export const SubscriptionForm = ({
169
171
  name={type}
170
172
  value={type}
171
173
  checked={value == type}
172
- onChange={(_e, { value }) => onChange(value)}
174
+ onChange={(_e, { value }) => {
175
+ if (value === "taxonomy_role" && resourceType !== "domains")
176
+ setValue("scope.resource_type", "domains", {
177
+ shouldValidate: true,
178
+ shouldDirty: true,
179
+ });
180
+
181
+ onChange(value);
182
+ }}
173
183
  />
174
184
  ))}
175
185
  </Form.Field>
176
186
  )}
177
187
  />
178
- {subscriberType === "role" && (
188
+ {_.includes(subscriberType)(["role", "taxonomy_role"]) && (
179
189
  <Controller
180
190
  control={control}
181
191
  name="subscriber.identifier"
@@ -237,7 +247,11 @@ export const SubscriptionForm = ({
237
247
  {RESOURCE_TYPES.map((type, idx) => (
238
248
  <Radio
239
249
  role="radio"
240
- disabled={isEditForm || type == "rule"}
250
+ disabled={
251
+ isEditForm ||
252
+ type == "rule" ||
253
+ (subscriberType === "taxonomy_role" && type !== "domains")
254
+ }
241
255
  onBlur={onBlur}
242
256
  key={idx}
243
257
  label={
@@ -13,17 +13,17 @@ import {
13
13
  Segment,
14
14
  Button,
15
15
  Label,
16
- Checkbox
16
+ Checkbox,
17
17
  } from "semantic-ui-react";
18
18
  import { icons } from "../subscriptionConstants";
19
19
 
20
- const SUBSCRIBER_TYPES = ["role", "email", "user"];
20
+ const SUBSCRIBER_TYPES = ["role", "email", "user", "taxonomy_role"];
21
21
  const RESOURCE_TYPES = [
22
22
  "data_structure",
23
23
  "domain",
24
24
  "domains",
25
25
  "concept",
26
- "rule"
26
+ "rule",
27
27
  ];
28
28
 
29
29
  export const SubscriptionsHeader = () => (
@@ -50,8 +50,8 @@ export const Subscriptions = () => {
50
50
  mode: "all",
51
51
  defaultValues: {
52
52
  resourceTypes: RESOURCE_TYPES,
53
- subscriberTypes: SUBSCRIBER_TYPES
54
- }
53
+ subscriberTypes: SUBSCRIBER_TYPES,
54
+ },
55
55
  });
56
56
 
57
57
  const { subscriptions, subscriptionsLoading, users } = useSelector(
@@ -66,7 +66,8 @@ export const Subscriptions = () => {
66
66
  const subscriberIdentifier = ({ type, identifier }) =>
67
67
  type === "user" ? _.get(`${identifier}.full_name`)(usersById) : identifier;
68
68
 
69
- const resourceIcon = type => _.getOr(DEFAULT_ICON, type)(RESOURCE_TYPE_ICONS);
69
+ const resourceIcon = (type) =>
70
+ _.getOr(DEFAULT_ICON, type)(RESOURCE_TYPE_ICONS);
70
71
 
71
72
  const subscriberTypes = watch("subscriberTypes");
72
73
  const resourceTypes = watch("resourceTypes");
@@ -111,7 +112,7 @@ export const Subscriptions = () => {
111
112
  onChange={() => {
112
113
  onChange(
113
114
  _.includes(type)(value)
114
- ? _.filter(t => t !== type)(value)
115
+ ? _.filter((t) => t !== type)(value)
115
116
  : [...value, type]
116
117
  );
117
118
  }}
@@ -144,7 +145,7 @@ export const Subscriptions = () => {
144
145
  onChange={() => {
145
146
  onChange(
146
147
  _.includes(type)(value)
147
- ? _.filter(t => t !== type)(value)
148
+ ? _.filter((t) => t !== type)(value)
148
149
  : [...value, type]
149
150
  );
150
151
  }}
@@ -22,6 +22,8 @@ const renderOpts = {
22
22
  "subscription.subscriber_type.email",
23
23
  "subscription.subscriber_type.role": "subscription.subscriber_type.role",
24
24
  "subscription.subscriber_type.user": "subscription.subscriber_type.user",
25
+ "subscription.subscriber_type.taxonomy_role":
26
+ "subscription.subscriber_type.taxonomy_role",
25
27
  "subscriptions.events": "subscriptions.events",
26
28
  "subscriptions.events.comment_created":
27
29
  "subscriptions.events.comment_created",
@@ -182,6 +184,21 @@ describe("<SubscriptionForm />", () => {
182
184
  });
183
185
  userEvent.type(queryByTestId("email-input"), "foo");
184
186
 
187
+ // Select concept and taxonomy_role
188
+ userEvent.click(await findByText(/resource\.type\.concept/));
189
+ await waitFor(() => {
190
+ expect(queryByText("concepts.search.results.empty")).toBeTruthy();
191
+ });
192
+
193
+ userEvent.click(await findByText(/subscriber_type\.taxonomy_role/));
194
+ await waitFor(() => {
195
+ expect(queryByText("role.search.placeholder")).toBeTruthy();
196
+ });
197
+ await waitFor(() => {
198
+ expect(queryByText("concepts.search.results.empty")).toBeFalsy();
199
+ });
200
+ userEvent.click(await findByText(/role2/));
201
+
185
202
  // Select user
186
203
  userEvent.click(await findByText(/subscriber_type\.user/));
187
204
  await waitFor(() => {
@@ -4,7 +4,7 @@ import { Subscriptions, SubscriptionsHeader } from "../Subscriptions";
4
4
 
5
5
  jest.mock("react-redux", () => ({
6
6
  ...jest.requireActual("react-redux"),
7
- useSelector: jest.fn(selector =>
7
+ useSelector: jest.fn((selector) =>
8
8
  selector({
9
9
  users: [{ full_name: "test1", id: 1 }],
10
10
  subscriptions: [
@@ -13,27 +13,27 @@ jest.mock("react-redux", () => ({
13
13
  scope: { resource_type: "domain" },
14
14
  periodicity: "hourly",
15
15
  subscriber: { id: 3, type: "user" },
16
- resource: { id: 2, name: "resource" }
16
+ resource: { id: 2, name: "resource" },
17
17
  },
18
18
  {
19
19
  id: 2,
20
20
  scope: { resource_type: "data_structure" },
21
21
  periodicity: "minutely",
22
22
  subscriber: { id: 4, type: "user" },
23
- resource: { id: 3, name: "bar" }
24
- }
25
- ]
23
+ resource: { id: 3, name: "bar" },
24
+ },
25
+ ],
26
26
  })
27
- )
27
+ ),
28
28
  }));
29
29
 
30
30
  const mockHistory = {
31
- goBack: jest.fn()
31
+ goBack: jest.fn(),
32
32
  };
33
33
 
34
34
  jest.mock("react-router-dom", () => ({
35
35
  ...jest.requireActual("react-router-dom"),
36
- useHistory: () => mockHistory
36
+ useHistory: () => mockHistory,
37
37
  }));
38
38
 
39
39
  describe("<Subscriptions />", () => {
@@ -33,6 +33,26 @@ exports[`<SubscriptionForm /> matches the latest snapshot 1`] = `
33
33
  subscription.subscriber_type.role
34
34
  </label>
35
35
  </div>
36
+ <div
37
+ class="ui radio checkbox"
38
+ >
39
+ <input
40
+ class="hidden"
41
+ name="taxonomy_role"
42
+ readonly=""
43
+ role="radio"
44
+ tabindex="0"
45
+ type="radio"
46
+ value="taxonomy_role"
47
+ />
48
+ <label>
49
+ <i
50
+ aria-hidden="true"
51
+ class="student icon"
52
+ />
53
+ subscription.subscriber_type.taxonomy_role
54
+ </label>
55
+ </div>
36
56
  <div
37
57
  class="ui radio checkbox"
38
58
  >
@@ -31,6 +31,7 @@ exports[`<Subscriptions /> matches the latest snapshot 1`] = `
31
31
  "role",
32
32
  "email",
33
33
  "user",
34
+ "taxonomy_role",
34
35
  ],
35
36
  },
36
37
  },
@@ -149,6 +150,7 @@ exports[`<Subscriptions /> matches the latest snapshot 1`] = `
149
150
  "role",
150
151
  "email",
151
152
  "user",
153
+ "taxonomy_role",
152
154
  ],
153
155
  },
154
156
  },
@@ -104,6 +104,7 @@ export default {
104
104
 
105
105
  "subscription.subscriber_type.user": "User",
106
106
  "subscription.subscriber_type.role": "Role",
107
+ "subscription.subscriber_type.taxonomy_role": "Role in taxonomy",
107
108
  "subscription.subscriber_type.email": "Email",
108
109
 
109
110
  "alert.createSubscription.failed.header": "Error saving subscription",
@@ -117,6 +117,7 @@ export default {
117
117
 
118
118
  "subscription.subscriber_type.user": "Usuario",
119
119
  "subscription.subscriber_type.role": "Rol",
120
+ "subscription.subscriber_type.taxonomy_role": "Rol en taxonomía",
120
121
  "subscription.subscriber_type.email": "Correo Electrónico",
121
122
 
122
123
  "alert.createSubscription.failed.header": "Error guardando suscripción",
@@ -112,6 +112,7 @@ export const icons = {
112
112
  user: "user",
113
113
  email: "envelope",
114
114
  role: "student",
115
+ taxonomy_role: "student",
115
116
  },
116
117
  DEFAULT_ICON: "question",
117
118
  RESOURCE_TYPE_ICONS: {