@truedat/dd 4.39.0 → 4.39.1

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.39.1] 2022-03-04
4
+
5
+ ### Added
6
+
7
+ - [TD-4534] With inheritance option on structrue domain update
8
+
3
9
  ## [4.38.6] 2022-02-21
4
10
 
5
11
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/dd",
3
- "version": "4.39.0",
3
+ "version": "4.39.1",
4
4
  "description": "Truedat Web Data Dictionary",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -107,5 +107,5 @@
107
107
  "react-dom": ">= 16.8.6 < 17",
108
108
  "semantic-ui-react": ">= 0.88.2 < 2.1"
109
109
  },
110
- "gitHead": "f3d2fe3fcdec546afc22d0a79c4f4f3dfb91ea48"
110
+ "gitHead": "834628cb0737cb7c874fce2bce891d23fe80e1d7"
111
111
  }
@@ -1,6 +1,6 @@
1
1
  import _ from "lodash/fp";
2
2
  import React, { useState } from "react";
3
- import { Button, Container, Form, Header } from "semantic-ui-react";
3
+ import { Button, Checkbox, Container, Form, Header } from "semantic-ui-react";
4
4
  import { DomainDropdownSelector } from "@truedat/bg/components";
5
5
  import { linkTo } from "@truedat/core/routes";
6
6
  import PropTypes from "prop-types";
@@ -11,9 +11,14 @@ import { updateStructure } from "../routines";
11
11
  export const EditDomainForm = ({ title, updateStructure, structure }) => {
12
12
  const { formatMessage } = useIntl();
13
13
  const [domainId, setDomainId] = useState(null);
14
+ const [with_inheritance, set_with_inheritance] = useState(true);
14
15
 
15
16
  const onSubmit = () => {
16
- const data_structure = { id: structure.id, domain_id: domainId };
17
+ const data_structure = {
18
+ id: structure.id,
19
+ domain_id: domainId,
20
+ with_inheritance,
21
+ };
17
22
  const redirect = linkTo.STRUCTURE_NOTES(data_structure);
18
23
 
19
24
  updateStructure({ data_structure, redirect });
@@ -33,11 +38,22 @@ export const EditDomainForm = ({ title, updateStructure, structure }) => {
33
38
  value={domainId || structure?.domain_id}
34
39
  />
35
40
 
41
+ <Checkbox
42
+ label={formatMessage({
43
+ id: "structureDomain.actions.update.with_inheritance",
44
+ })}
45
+ checked={with_inheritance}
46
+ onChange={(e) => {
47
+ set_with_inheritance(!with_inheritance);
48
+ e.preventDefault();
49
+ }}
50
+ />
51
+
36
52
  <Form onSubmit={onSubmit}>
37
53
  <div className="actions">
38
54
  <Button
39
55
  type="submit"
40
- disabled={!Boolean(domainId)}
56
+ disabled={!Boolean(domainId) || domainId == structure?.domain_id}
41
57
  primary
42
58
  content={formatMessage({ id: "structureDomain.actions.update" })}
43
59
  />
@@ -26,11 +26,16 @@ describe("<EditDomainForm />", () => {
26
26
  en: {
27
27
  "structure.edit_domain.title": "Edit domain",
28
28
  "structureDomain.actions.update": "Update",
29
+ "structureDomain.actions.update.with_inheritance": "Apply on children",
29
30
  "domain.selector.label": "Domain",
30
31
  "domain.selector.placeholder": "Select a domain...",
31
32
  },
32
33
  };
33
34
 
35
+ beforeEach(() => {
36
+ jest.clearAllMocks();
37
+ });
38
+
34
39
  it("matches the latest snapshot", () => {
35
40
  const { container } = render(<EditDomainForm {...props} />, {
36
41
  state: { domains },
@@ -62,10 +67,41 @@ describe("<EditDomainForm />", () => {
62
67
  });
63
68
 
64
69
  const button = getByRole("button", { name: /update/i });
70
+ const checkbox = getByRole("checkbox");
71
+ const option = getByRole("option", { name: /Domain 1/i });
72
+
73
+ expect(button).toBeDisabled();
74
+ expect(checkbox).toBeChecked();
75
+ userEvent.click(option);
76
+ await waitFor(() => {
77
+ expect(button).not.toBeDisabled();
78
+ });
79
+ userEvent.click(button);
80
+ await waitFor(() => {
81
+ expect(updateStructure.mock.calls.length).toBe(1);
82
+ });
83
+ expect(updateStructure).toHaveBeenCalledWith(
84
+ expect.objectContaining({
85
+ data_structure: { domain_id: 1, id: 42, with_inheritance: true },
86
+ redirect: "/structures/42/notes",
87
+ })
88
+ );
89
+ });
90
+
91
+ it("invokes function when send button clicked with modified inheritance", async () => {
92
+ const { getByRole } = render(<EditDomainForm {...props} />, {
93
+ state: { domains },
94
+ messages,
95
+ });
96
+
97
+ const button = getByRole("button", { name: /update/i });
98
+ const checkbox = getByRole("checkbox");
65
99
  const option = getByRole("option", { name: /Domain 1/i });
66
100
 
67
101
  expect(button).toBeDisabled();
102
+ expect(checkbox).toBeChecked();
68
103
  userEvent.click(option);
104
+ userEvent.click(checkbox);
69
105
  await waitFor(() => {
70
106
  expect(button).not.toBeDisabled();
71
107
  });
@@ -75,7 +111,7 @@ describe("<EditDomainForm />", () => {
75
111
  });
76
112
  expect(updateStructure).toHaveBeenCalledWith(
77
113
  expect.objectContaining({
78
- data_structure: { domain_id: 1, id: 42 },
114
+ data_structure: { domain_id: 1, id: 42, with_inheritance: false },
79
115
  redirect: "/structures/42/notes",
80
116
  })
81
117
  );
@@ -90,6 +90,21 @@ exports[`<EditDomainForm /> matches the latest snapshot 1`] = `
90
90
  </div>
91
91
  </div>
92
92
  </div>
93
+ <div
94
+ class="ui checked checkbox"
95
+ >
96
+ <input
97
+ checked=""
98
+ class="hidden"
99
+ readonly=""
100
+ tabindex="0"
101
+ type="checkbox"
102
+ value=""
103
+ />
104
+ <label>
105
+ Apply on children
106
+ </label>
107
+ </div>
93
108
  <form
94
109
  class="ui form"
95
110
  >
@@ -314,6 +314,7 @@ export default {
314
314
  "structure.version.inserted_at": "Imported {when}",
315
315
  "structure.version.version": "Version {version}",
316
316
  "structureDomain.actions.update": "Update",
317
+ "structureDomain.actions.update.with_inheritance": "Apply on children",
317
318
  "structureSelector.union.criteria": "Union criteria",
318
319
  "structureTagForm.props.name": "Name",
319
320
  "structureTags.actions.create": "Create Structure Tag",
@@ -318,6 +318,7 @@ export default {
318
318
  "structure.version.inserted_at": "Importada {when}",
319
319
  "structure.version.version": "Versión {version}",
320
320
  "structureDomain.actions.update": "Actualizar",
321
+ "structureDomain.actions.update.with_inheritance": "Aplicar en hijos",
321
322
  "structureSelector.union.criteria": "Criterio de unión",
322
323
  "structureTagForm.props.name": "Nombre",
323
324
  "structureTags.actions.create": "Crear Etiqueta de Estructura",