@truedat/bg 6.6.2 → 6.6.4
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/bg",
|
|
3
|
-
"version": "6.6.
|
|
3
|
+
"version": "6.6.4",
|
|
4
4
|
"description": "Truedat Web Business Glossary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@testing-library/jest-dom": "^5.16.5",
|
|
35
35
|
"@testing-library/react": "^12.0.0",
|
|
36
36
|
"@testing-library/user-event": "^13.2.1",
|
|
37
|
-
"@truedat/test": "6.6.
|
|
37
|
+
"@truedat/test": "6.6.4",
|
|
38
38
|
"babel-jest": "^28.1.0",
|
|
39
39
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
40
40
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
]
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@truedat/core": "6.6.
|
|
90
|
-
"@truedat/df": "6.6.
|
|
91
|
-
"@truedat/lm": "6.6.
|
|
89
|
+
"@truedat/core": "6.6.4",
|
|
90
|
+
"@truedat/df": "6.6.4",
|
|
91
|
+
"@truedat/lm": "6.6.4",
|
|
92
92
|
"decode-uri-component": "^0.2.2",
|
|
93
93
|
"file-saver": "^2.0.5",
|
|
94
94
|
"moment": "^2.29.4",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"react-dom": ">= 16.8.6 < 17",
|
|
112
112
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
113
113
|
},
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "27d89e54bdeca18ed5d4cff590058bda5ebec629"
|
|
115
115
|
}
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
splitTranslatableFields,
|
|
10
10
|
formatLocales,
|
|
11
11
|
} from "@truedat/core/services/i18nContent";
|
|
12
|
+
import { useTemplate } from "@truedat/core/hooks";
|
|
13
|
+
|
|
12
14
|
import { conceptAction } from "../routines";
|
|
13
15
|
|
|
14
16
|
import ConceptForms from "./ConceptForms";
|
|
@@ -20,7 +22,7 @@ export const ConceptEdit = ({
|
|
|
20
22
|
template,
|
|
21
23
|
action,
|
|
22
24
|
conceptAction,
|
|
23
|
-
|
|
25
|
+
processedContent,
|
|
24
26
|
}) => {
|
|
25
27
|
const { content: propContent, name: propName, domain } = concept;
|
|
26
28
|
const { locales, loading: localesLoading } = useLocales(false);
|
|
@@ -81,7 +83,7 @@ export const ConceptEdit = ({
|
|
|
81
83
|
)
|
|
82
84
|
)(i18nConcept);
|
|
83
85
|
|
|
84
|
-
const newContent =
|
|
86
|
+
const newContent = processedContent(defaultContent.content, domain?.id);
|
|
85
87
|
|
|
86
88
|
const business_concept_version = {
|
|
87
89
|
name: defaultContent.name,
|
|
@@ -118,42 +120,47 @@ export const ConceptEdit = ({
|
|
|
118
120
|
|
|
119
121
|
ConceptEdit.propTypes = {
|
|
120
122
|
action: PropTypes.object,
|
|
121
|
-
applyTemplate: PropTypes.func,
|
|
122
123
|
concept: PropTypes.object,
|
|
123
124
|
conceptAction: PropTypes.func.isRequired,
|
|
124
|
-
|
|
125
|
+
templateName: PropTypes.string,
|
|
125
126
|
loading: PropTypes.bool,
|
|
126
|
-
selectDomain: PropTypes.func,
|
|
127
|
-
selectTemplate: PropTypes.func,
|
|
128
|
-
template: PropTypes.object,
|
|
129
127
|
};
|
|
130
128
|
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
export const ConceptEditLoader = (props) => {
|
|
130
|
+
const templateName = _.prop("templateName")(props);
|
|
131
|
+
const concept = _.prop("concept")(props);
|
|
132
|
+
const { domain } = concept;
|
|
133
|
+
|
|
134
|
+
const { data, loading: templateLoading } = useTemplate({
|
|
135
|
+
name: templateName,
|
|
136
|
+
domainIds: [domain.id],
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const template = _.prop("template")(data);
|
|
140
|
+
const processedContent = applyTemplate(template);
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<ConceptEdit
|
|
144
|
+
templateLoading={templateLoading}
|
|
145
|
+
processedContent={processedContent}
|
|
146
|
+
template={template}
|
|
147
|
+
{...props}
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const mapStateToProps = ({ concept, conceptActionLoading, conceptActions }) => {
|
|
138
153
|
const action = _.prop(actionKey)(conceptActions);
|
|
139
|
-
const loading =
|
|
140
|
-
|
|
141
|
-
(action && action.href && conceptActionLoading === action.href);
|
|
142
|
-
|
|
143
|
-
const template =
|
|
144
|
-
templates && concept && concept.type
|
|
145
|
-
? _.flow(_.find(_.propEq("name", concept.type)))(templates)
|
|
146
|
-
: null;
|
|
154
|
+
const loading = action && action.href && conceptActionLoading === action.href;
|
|
155
|
+
|
|
147
156
|
return {
|
|
148
157
|
action,
|
|
149
158
|
concept,
|
|
150
159
|
loading,
|
|
151
|
-
|
|
152
|
-
loading,
|
|
153
|
-
applyTemplate: applyTemplate(template),
|
|
160
|
+
templateName: concept.type,
|
|
154
161
|
};
|
|
155
162
|
};
|
|
156
163
|
|
|
157
164
|
export default compose(connect(mapStateToProps, { conceptAction }))(
|
|
158
|
-
|
|
165
|
+
ConceptEditLoader
|
|
159
166
|
);
|
|
@@ -95,7 +95,7 @@ const ConceptForms = ({
|
|
|
95
95
|
domainId={domainId}
|
|
96
96
|
template={template}
|
|
97
97
|
concept={i18nConcept[singleLang]}
|
|
98
|
-
defaultContent={i18nConcept[singleLang]}
|
|
98
|
+
defaultContent={i18nConcept[singleLang].content}
|
|
99
99
|
noTranslatableFields={[]}
|
|
100
100
|
onChangeDomainId={handleDomainChange}
|
|
101
101
|
onChangeName={handleI18nNameChange}
|
|
@@ -188,7 +188,7 @@ ConceptForms.propTypes = {
|
|
|
188
188
|
template: PropTypes.object,
|
|
189
189
|
i18nConcept: PropTypes.object,
|
|
190
190
|
loading: PropTypes.bool,
|
|
191
|
-
langs: PropTypes.
|
|
191
|
+
langs: PropTypes.object,
|
|
192
192
|
noTranslatableFields: PropTypes.array,
|
|
193
193
|
translatableFields: PropTypes.array,
|
|
194
194
|
setI18nConcept: PropTypes.func,
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import React, { Suspense } from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { waitFor } from "@testing-library/react";
|
|
4
|
+
import ConceptEdit from "../ConceptEdit";
|
|
5
|
+
|
|
6
|
+
const template1 = {
|
|
7
|
+
id: 1,
|
|
8
|
+
name: "template1",
|
|
9
|
+
label: "template1",
|
|
10
|
+
scope: "foo",
|
|
11
|
+
content: [
|
|
12
|
+
{
|
|
13
|
+
fields: [
|
|
14
|
+
{
|
|
15
|
+
name: "user",
|
|
16
|
+
type: "user",
|
|
17
|
+
label: "user",
|
|
18
|
+
widget: "dropdown",
|
|
19
|
+
values: {
|
|
20
|
+
processed_users: ["xyz_user", "foo_user"],
|
|
21
|
+
role_users: "role_users",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
jest.mock("@truedat/core/hooks", () => ({
|
|
30
|
+
useLocales: jest.fn(() => ({
|
|
31
|
+
loading: false,
|
|
32
|
+
locales: [
|
|
33
|
+
{
|
|
34
|
+
local_name: "es",
|
|
35
|
+
name: "es",
|
|
36
|
+
lang: "es",
|
|
37
|
+
id: 1,
|
|
38
|
+
is_default: true,
|
|
39
|
+
is_enabled: true,
|
|
40
|
+
is_required: true,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
})),
|
|
44
|
+
useTemplate: jest.fn(() => ({
|
|
45
|
+
loading: false,
|
|
46
|
+
data: { template: template1 },
|
|
47
|
+
})),
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
jest.mock("@truedat/bg/concepts/hooks/useConcepts", () => {
|
|
51
|
+
const originalModule = jest.requireActual(
|
|
52
|
+
"@truedat/bg/concepts/hooks/useConcepts"
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
__esModule: true,
|
|
57
|
+
...originalModule,
|
|
58
|
+
useConceptFilters: () => ({
|
|
59
|
+
trigger: () => ({
|
|
60
|
+
then: (callback) =>
|
|
61
|
+
callback({
|
|
62
|
+
data: { data: {} },
|
|
63
|
+
}),
|
|
64
|
+
}),
|
|
65
|
+
}),
|
|
66
|
+
useConceptVersionsSearch: () => ({
|
|
67
|
+
trigger: () => ({
|
|
68
|
+
then: (callback) =>
|
|
69
|
+
callback({
|
|
70
|
+
data: { data: [] },
|
|
71
|
+
headers: {},
|
|
72
|
+
}),
|
|
73
|
+
}),
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const concept = {
|
|
79
|
+
_actions: { can_create_structure_link: true },
|
|
80
|
+
id: 1,
|
|
81
|
+
business_concept_id: 1111,
|
|
82
|
+
name: "concept_name",
|
|
83
|
+
domain: { id: 1, name: "bar" },
|
|
84
|
+
status: "draft",
|
|
85
|
+
content: { user: "xyz_user" },
|
|
86
|
+
links: [
|
|
87
|
+
{
|
|
88
|
+
id: 745,
|
|
89
|
+
resource_id: 4569480,
|
|
90
|
+
resource_type: "data_structure",
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const renderOpts = {
|
|
96
|
+
state: { concept },
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
describe("<ConceptEdit />", () => {
|
|
100
|
+
const props = {
|
|
101
|
+
applyTemplate: jest.fn(),
|
|
102
|
+
};
|
|
103
|
+
it("matches the latest snapshot", async () => {
|
|
104
|
+
const { container, queryByText, debug } = render(
|
|
105
|
+
<Suspense fallback={null}>
|
|
106
|
+
<ConceptEdit {...props} />
|
|
107
|
+
</Suspense>,
|
|
108
|
+
renderOpts
|
|
109
|
+
);
|
|
110
|
+
await waitFor(() => expect(queryByText(/foo_user/i)).toBeInTheDocument());
|
|
111
|
+
expect(container).toMatchSnapshot();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<ConceptEdit /> matches the latest snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="ui segment ui text container"
|
|
7
|
+
style=""
|
|
8
|
+
>
|
|
9
|
+
<h2
|
|
10
|
+
class="ui header"
|
|
11
|
+
>
|
|
12
|
+
<i
|
|
13
|
+
aria-hidden="true"
|
|
14
|
+
class="book icon"
|
|
15
|
+
/>
|
|
16
|
+
<div
|
|
17
|
+
class="content"
|
|
18
|
+
>
|
|
19
|
+
Edit Business Concept
|
|
20
|
+
</div>
|
|
21
|
+
</h2>
|
|
22
|
+
<form
|
|
23
|
+
class="ui form"
|
|
24
|
+
>
|
|
25
|
+
<div
|
|
26
|
+
class="required field"
|
|
27
|
+
>
|
|
28
|
+
<label>
|
|
29
|
+
Term
|
|
30
|
+
</label>
|
|
31
|
+
<div
|
|
32
|
+
class="field"
|
|
33
|
+
>
|
|
34
|
+
<div
|
|
35
|
+
class="ui input"
|
|
36
|
+
>
|
|
37
|
+
<input
|
|
38
|
+
name="name"
|
|
39
|
+
type="text"
|
|
40
|
+
value="concept_name"
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<h3
|
|
46
|
+
class="ui header"
|
|
47
|
+
>
|
|
48
|
+
Template fields (only required for publishing)
|
|
49
|
+
</h3>
|
|
50
|
+
<div
|
|
51
|
+
class="ui segment"
|
|
52
|
+
>
|
|
53
|
+
<div
|
|
54
|
+
class="field"
|
|
55
|
+
data-testid="form-field"
|
|
56
|
+
>
|
|
57
|
+
<label>
|
|
58
|
+
user
|
|
59
|
+
</label>
|
|
60
|
+
<div
|
|
61
|
+
class="dimmable"
|
|
62
|
+
>
|
|
63
|
+
<div
|
|
64
|
+
class="field"
|
|
65
|
+
>
|
|
66
|
+
<div
|
|
67
|
+
aria-expanded="false"
|
|
68
|
+
class="ui fluid search selection dropdown"
|
|
69
|
+
name="user"
|
|
70
|
+
role="combobox"
|
|
71
|
+
>
|
|
72
|
+
<input
|
|
73
|
+
aria-autocomplete="list"
|
|
74
|
+
autocomplete="off"
|
|
75
|
+
class="search"
|
|
76
|
+
tabindex="0"
|
|
77
|
+
type="text"
|
|
78
|
+
value=""
|
|
79
|
+
/>
|
|
80
|
+
<div
|
|
81
|
+
aria-atomic="true"
|
|
82
|
+
aria-live="polite"
|
|
83
|
+
class="divider text"
|
|
84
|
+
role="alert"
|
|
85
|
+
>
|
|
86
|
+
xyz_user
|
|
87
|
+
</div>
|
|
88
|
+
<i
|
|
89
|
+
aria-hidden="true"
|
|
90
|
+
class="dropdown icon"
|
|
91
|
+
/>
|
|
92
|
+
<div
|
|
93
|
+
aria-multiselectable="false"
|
|
94
|
+
class="menu transition"
|
|
95
|
+
role="listbox"
|
|
96
|
+
>
|
|
97
|
+
<div
|
|
98
|
+
aria-checked="false"
|
|
99
|
+
aria-selected="false"
|
|
100
|
+
class="item"
|
|
101
|
+
role="option"
|
|
102
|
+
style="pointer-events: all;"
|
|
103
|
+
>
|
|
104
|
+
<span
|
|
105
|
+
class="text"
|
|
106
|
+
>
|
|
107
|
+
No selection
|
|
108
|
+
</span>
|
|
109
|
+
</div>
|
|
110
|
+
<div
|
|
111
|
+
aria-checked="false"
|
|
112
|
+
aria-selected="false"
|
|
113
|
+
class="item"
|
|
114
|
+
role="option"
|
|
115
|
+
style="pointer-events: all;"
|
|
116
|
+
>
|
|
117
|
+
<span
|
|
118
|
+
class="text"
|
|
119
|
+
>
|
|
120
|
+
foo_user
|
|
121
|
+
</span>
|
|
122
|
+
</div>
|
|
123
|
+
<div
|
|
124
|
+
aria-checked="true"
|
|
125
|
+
aria-selected="true"
|
|
126
|
+
class="active selected item"
|
|
127
|
+
role="option"
|
|
128
|
+
style="pointer-events: all;"
|
|
129
|
+
>
|
|
130
|
+
<span
|
|
131
|
+
class="text"
|
|
132
|
+
>
|
|
133
|
+
xyz_user
|
|
134
|
+
</span>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
<div
|
|
140
|
+
class="ui inverted dimmer"
|
|
141
|
+
>
|
|
142
|
+
<div
|
|
143
|
+
class="content"
|
|
144
|
+
>
|
|
145
|
+
<div
|
|
146
|
+
class="ui loader"
|
|
147
|
+
/>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
</form>
|
|
154
|
+
<div
|
|
155
|
+
class="concept-forms-actions actions"
|
|
156
|
+
>
|
|
157
|
+
<a
|
|
158
|
+
class="ui secondary button"
|
|
159
|
+
href="/"
|
|
160
|
+
role="button"
|
|
161
|
+
>
|
|
162
|
+
Cancel
|
|
163
|
+
</a>
|
|
164
|
+
<button
|
|
165
|
+
class="ui primary button"
|
|
166
|
+
>
|
|
167
|
+
Update
|
|
168
|
+
</button>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
`;
|