@truedat/bg 4.44.0 → 4.44.3

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": "4.44.0",
3
+ "version": "4.44.3",
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.14.1",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "4.44.0",
37
+ "@truedat/test": "4.44.3",
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",
@@ -83,8 +83,8 @@
83
83
  ]
84
84
  },
85
85
  "dependencies": {
86
- "@truedat/core": "4.44.0",
87
- "@truedat/df": "4.44.0",
86
+ "@truedat/core": "4.44.3",
87
+ "@truedat/df": "4.44.3",
88
88
  "file-saver": "^2.0.5",
89
89
  "moment": "^2.24.0",
90
90
  "path-to-regexp": "^1.7.0",
@@ -104,5 +104,5 @@
104
104
  "react-dom": ">= 16.8.6 < 17",
105
105
  "semantic-ui-react": ">= 0.88.2 < 2.1"
106
106
  },
107
- "gitHead": "55fd4a8be70ca0d1bd4f3cb7b5eaf073b0350029"
107
+ "gitHead": "d5e72d523389c6e66d6f7168d7e3546b5d2ffdda"
108
108
  }
@@ -50,12 +50,14 @@ export class ConceptEdit extends React.Component {
50
50
  static propTypes = {
51
51
  action: PropTypes.object,
52
52
  applyTemplate: PropTypes.func,
53
- conceptAction: PropTypes.func.isRequired,
54
53
  concept: PropTypes.object,
54
+ conceptAction: PropTypes.func.isRequired,
55
55
  intl: PropTypes.object,
56
56
  loading: PropTypes.bool,
57
- templateId: PropTypes.number,
57
+ selectDomain: PropTypes.func,
58
+ selectTemplate: PropTypes.func,
58
59
  template: PropTypes.object,
60
+ templateId: PropTypes.number,
59
61
  };
60
62
 
61
63
  state = initialState;
@@ -162,7 +164,7 @@ export class ConceptEdit extends React.Component {
162
164
  onChange={this.handleEditorChange}
163
165
  />
164
166
  </Form.Field>
165
- {!_.isEmpty(template) && !_.isNil(content) && (
167
+ {_.isEmpty(template) || _.isNil(content) ? null : (
166
168
  <DynamicForm
167
169
  onChange={this.handleContentChange}
168
170
  content={content}
@@ -13,8 +13,8 @@ import {
13
13
  import { compose } from "redux";
14
14
  import { connect } from "react-redux";
15
15
  import { injectIntl, FormattedMessage } from "react-intl";
16
- import { HistoryBackButton } from "@truedat/core/components";
17
- import { selectTemplate, selectDomain } from "@truedat/df/routines";
16
+ import { HistoryBackButton, TemplateSelector } from "@truedat/core/components";
17
+ import { selectDomain } from "@truedat/df/routines";
18
18
  import { applyTemplate } from "@truedat/df/utils";
19
19
  import { conceptAction } from "../routines";
20
20
  import DomainDropdownSelector from "../../taxonomy/components/DomainDropdownSelector";
@@ -27,14 +27,6 @@ const RichTextEditor = React.lazy(() =>
27
27
  import("@truedat/core/components/RichTextEditor")
28
28
  );
29
29
 
30
- const TemplateLoader = React.lazy(() =>
31
- import("@truedat/df/templates/components/TemplateLoader")
32
- );
33
-
34
- const TemplateSelector = React.lazy(() =>
35
- import("@truedat/df/templates/components/TemplateSelector")
36
- );
37
-
38
30
  const actionKey = "create";
39
31
 
40
32
  const staticFields = ["name", "description"];
@@ -43,6 +35,8 @@ const initialState = {
43
35
  name: "",
44
36
  description: {},
45
37
  content: {},
38
+ templatesLoading: true,
39
+ template: null,
46
40
  };
47
41
 
48
42
  const isNonEmptyString = _.flow(_.trim, _.negate(_.isEmpty));
@@ -55,38 +49,37 @@ const isValid = _.conforms({
55
49
  export class ConceptForm extends React.Component {
56
50
  static propTypes = {
57
51
  action: PropTypes.object,
58
- applyTemplate: PropTypes.func,
59
52
  conceptAction: PropTypes.func,
60
53
  conceptActionLoading: PropTypes.string,
61
54
  intl: PropTypes.object,
62
55
  selectDomain: PropTypes.func,
63
- selectTemplate: PropTypes.func,
64
- template: PropTypes.object,
65
- templateLoading: PropTypes.bool,
66
- templates: PropTypes.array,
67
56
  };
68
57
 
69
58
  state = initialState;
70
59
 
71
- componentDidMount() {
72
- const { templates } = this.props;
73
- if (_.size(templates) == 1) {
74
- const { selectTemplate } = this.props;
75
- const id = _.flow(_.head, _.prop("id"))(templates);
76
- selectTemplate({ id });
77
- }
78
- }
79
-
80
- componentDidUpdate() {
81
- const { applyTemplate, template } = this.props;
82
- const { type, content, domain_id } = this.state;
60
+ handleTemplatesLoaded = ({ templates = [] } = {}) => {
61
+ const { type: name, content, domain_id } = this.state;
62
+ const template = name
63
+ ? _.find(_.propEq("name", name))(templates)
64
+ : _.size(templates) == 1
65
+ ? templates[0]
66
+ : null;
67
+ this.setState({
68
+ template,
69
+ templatesLoading: false,
70
+ type: template?.name || null,
71
+ content: template ? applyTemplate(template)(content, domain_id) : {},
72
+ });
73
+ };
83
74
 
84
- if (_.has("name")(template) && !_.propEq("name", type)(template))
85
- this.setState({
86
- type: _.prop("name")(template),
87
- content: applyTemplate(content, domain_id),
88
- });
89
- }
75
+ handleTemplateSelected = (e, { template }) => {
76
+ const { content, domain_id } = this.state;
77
+ this.setState({
78
+ template,
79
+ type: template?.name || null,
80
+ content: template ? applyTemplate(template)(content, domain_id) : {},
81
+ });
82
+ };
90
83
 
91
84
  handleDomainSelected = (e, { value }) => {
92
85
  const domain_id = value;
@@ -97,12 +90,6 @@ export class ConceptForm extends React.Component {
97
90
  this.setState({ domain_id });
98
91
  };
99
92
 
100
- handleTemplateSelected = (e, data) => {
101
- const { value } = data;
102
- const { selectTemplate } = this.props;
103
- selectTemplate({ id: value });
104
- };
105
-
106
93
  handleEditorChange = (e, { value }) => {
107
94
  this.handleChange(null, { name: "description", value });
108
95
  };
@@ -123,19 +110,21 @@ export class ConceptForm extends React.Component {
123
110
 
124
111
  handleSubmit = (e) => {
125
112
  e.preventDefault();
126
- const { action, applyTemplate, conceptAction } = this.props;
113
+ const { action, conceptAction } = this.props;
127
114
  const businessConceptVersion = _.pick([
128
115
  "domain_id",
129
116
  "type",
130
117
  ...staticFields,
131
118
  ])(this.state);
132
-
133
- const content = applyTemplate(this.state?.content, this.state?.domain_id);
119
+ const { template, content, domain_id } = this.state;
134
120
 
135
121
  conceptAction({
136
122
  action: actionKey,
137
123
  ...action,
138
- business_concept_version: { ...businessConceptVersion, content },
124
+ business_concept_version: {
125
+ ...businessConceptVersion,
126
+ content: applyTemplate(template)(content, domain_id),
127
+ },
139
128
  });
140
129
  };
141
130
 
@@ -144,124 +133,104 @@ export class ConceptForm extends React.Component {
144
133
  action,
145
134
  conceptActionLoading,
146
135
  intl: { formatMessage },
147
- template,
148
- templateLoading,
149
- templates,
150
136
  } = this.props;
151
137
 
152
- const { name, description, content } = this.state;
138
+ const { name, description, content, template, templatesLoading } =
139
+ this.state;
153
140
 
154
141
  const loading =
155
- templateLoading ||
142
+ templatesLoading ||
156
143
  (action && action.href && conceptActionLoading === action.href);
157
144
 
158
145
  return (
159
- <>
160
- <TemplateLoader />
161
- <Container as={Segment} text>
162
- <Header as="h2">
163
- <Icon name="book" />
164
- <Header.Content>
165
- <FormattedMessage id="concepts.actions.create" />
166
- </Header.Content>
167
- </Header>
168
- <Form loading={loading}>
169
- <Header
170
- as="h3"
171
- content={<FormattedMessage id="concepts.form.required_fields" />}
146
+ <Container as={Segment} text>
147
+ <Header as="h2">
148
+ <Icon name="book" />
149
+ <Header.Content>
150
+ <FormattedMessage id="concepts.actions.create" />
151
+ </Header.Content>
152
+ </Header>
153
+ <Form loading={loading}>
154
+ <Header
155
+ as="h3"
156
+ content={formatMessage({ id: "concepts.form.required_fields" })}
157
+ />
158
+ <DomainDropdownSelector
159
+ name="domain"
160
+ invalid={!_.isFinite(this.state.domain_id)}
161
+ onChange={this.handleDomainSelected}
162
+ />
163
+ <TemplateSelector
164
+ scope="bg"
165
+ selectedValue={template?.id}
166
+ onLoad={this.handleTemplatesLoaded}
167
+ onChange={this.handleTemplateSelected}
168
+ required
169
+ />
170
+ <Form.Field required>
171
+ <label>
172
+ <FormattedMessage id="concepts.props.name" />
173
+ {_.isEmpty(name) ? (
174
+ <Label pointing="left">
175
+ <FormattedMessage id="template.form.validation.empty_required" />
176
+ </Label>
177
+ ) : null}
178
+ </label>
179
+ <Form.Input name="name" value={name} onChange={this.handleChange} />
180
+ </Form.Field>
181
+ <Form.Field required>
182
+ <label>
183
+ <FormattedMessage id="concepts.props.description" />
184
+ {_.isEmpty(description) ? (
185
+ <Label pointing="left">
186
+ <FormattedMessage id="template.form.validation.empty_required" />
187
+ </Label>
188
+ ) : null}
189
+ </label>
190
+ <RichTextEditor
191
+ name="description"
192
+ value={description}
193
+ onChange={this.handleEditorChange}
172
194
  />
173
- <DomainDropdownSelector
174
- name="domain"
175
- invalid={!_.isFinite(this.state.domain_id)}
176
- onChange={this.handleDomainSelected}
177
- />
178
- {_.size(templates) > 1 && (
179
- <TemplateSelector
180
- name="template"
181
- selectedValue={_.prop("id")(template)}
182
- onChange={this.handleTemplateSelected}
195
+ </Form.Field>
196
+ {template?.id ? (
197
+ <>
198
+ <Header
199
+ as="h3"
200
+ content={formatMessage({
201
+ id: "concepts.form.aditional_fields",
202
+ })}
183
203
  />
184
- )}
185
-
186
- <Form.Field required>
187
- <label>
188
- {formatMessage({ id: "concepts.props.name" })}
189
- {_.isEmpty(name) ? (
190
- <Label pointing="left">
191
- <FormattedMessage id="template.form.validation.empty_required" />
192
- </Label>
193
- ) : null}
194
- </label>
195
- <Form.Input
196
- name="name"
197
- value={name}
198
- onChange={this.handleChange}
204
+ <DynamicForm
205
+ onChange={this.handleContentChange}
206
+ content={content}
207
+ template={template}
199
208
  />
200
- </Form.Field>
201
-
202
- <Form.Field required>
203
- <label>
204
- {formatMessage({ id: "concepts.props.description" })}
205
- {_.isEmpty(description) ? (
206
- <Label pointing="left">
207
- <FormattedMessage id="template.form.validation.empty_required" />
208
- </Label>
209
- ) : null}
210
- </label>
211
- <RichTextEditor
212
- name="description"
213
- value={description}
214
- onChange={this.handleEditorChange}
215
- />
216
- </Form.Field>
217
- {template && template.id && (
218
- <>
219
- <Header
220
- as="h3"
221
- content={
222
- <FormattedMessage id="concepts.form.aditional_fields" />
223
- }
224
- />
225
- <DynamicForm
226
- onChange={this.handleContentChange}
227
- content={content}
228
- />
229
- </>
230
- )}
231
- <div className="actions">
232
- <HistoryBackButton
233
- content={formatMessage({ id: "actions.cancel" })}
234
- />
235
- <Button
236
- primary
237
- disabled={this.isInvalid()}
238
- onClick={this.handleSubmit}
239
- content={<FormattedMessage id="actions.create" />}
240
- />
241
- </div>
242
- </Form>
243
- </Container>
244
- </>
209
+ </>
210
+ ) : null}
211
+ <div className="actions">
212
+ <HistoryBackButton
213
+ content={formatMessage({ id: "actions.cancel" })}
214
+ />
215
+ <Button
216
+ primary
217
+ disabled={this.isInvalid()}
218
+ onClick={this.handleSubmit}
219
+ content={formatMessage({ id: "actions.create" })}
220
+ />
221
+ </div>
222
+ </Form>
223
+ </Container>
245
224
  );
246
225
  }
247
226
  }
248
227
 
249
- const mapStateToProps = ({
250
- conceptActionLoading,
251
- conceptsActions,
252
- template,
253
- templateLoading,
254
- templates,
255
- }) => ({
228
+ const mapStateToProps = ({ conceptActionLoading, conceptsActions }) => ({
256
229
  action: _.prop(actionKey)(conceptsActions),
257
- applyTemplate: applyTemplate(template),
258
230
  conceptActionLoading,
259
- template,
260
- templateLoading,
261
- templates,
262
231
  });
263
232
 
264
233
  export default compose(
265
234
  injectIntl,
266
- connect(mapStateToProps, { conceptAction, selectDomain, selectTemplate })
235
+ connect(mapStateToProps, { conceptAction, selectDomain })
267
236
  )(ConceptForm);
@@ -12,7 +12,7 @@ import {
12
12
  CONCEPTS_NEW,
13
13
  CONCEPTS_PENDING,
14
14
  CONCEPT_EDIT,
15
- CONCEPT_VERSION
15
+ CONCEPT_VERSION,
16
16
  } from "@truedat/core/routes";
17
17
  import DomainsLoader from "../../taxonomy/components/DomainsLoader";
18
18
  import Concept from "./Concept";
@@ -43,7 +43,7 @@ const RelationsGraphLoader = React.lazy(() =>
43
43
  export const ConceptRoutes = ({ concept, conceptLoaded, templatesLoaded }) => {
44
44
  const authorized = useAuthorized([
45
45
  "business_glossary_view",
46
- "business_glossary_management"
46
+ "business_glossary_management",
47
47
  ]);
48
48
  const conceptsActive = useActiveRoutes([CONCEPTS, CONCEPTS_PENDING]);
49
49
  return (
@@ -58,12 +58,17 @@ export const ConceptRoutes = ({ concept, conceptLoaded, templatesLoaded }) => {
58
58
  <ConceptUserFiltersLoader />
59
59
  <ConceptsDefaultFiltersLoader
60
60
  defaultFilters={{
61
- status: ["pending_approval", "draft", "rejected"]
61
+ status: ["pending_approval", "draft", "rejected"],
62
62
  }}
63
63
  />
64
64
  <ConceptFiltersLoader
65
65
  defaultFilters={{
66
- status: ["pending_approval", "draft", "rejected", "published"]
66
+ status: [
67
+ "pending_approval",
68
+ "draft",
69
+ "rejected",
70
+ "published",
71
+ ],
67
72
  }}
68
73
  />
69
74
  <Concepts
@@ -93,12 +98,12 @@ export const ConceptRoutes = ({ concept, conceptLoaded, templatesLoaded }) => {
93
98
  <ConceptUserFiltersLoader />
94
99
  <ConceptsDefaultFiltersLoader
95
100
  defaultFilters={{
96
- status: ["published"]
101
+ status: ["published"],
97
102
  }}
98
103
  />
99
104
  <ConceptFiltersLoader
100
105
  defaultFilters={{
101
- status: ["published"]
106
+ status: ["published"],
102
107
  }}
103
108
  />
104
109
  <Concepts
@@ -128,8 +133,7 @@ export const ConceptRoutes = ({ concept, conceptLoaded, templatesLoaded }) => {
128
133
  <>
129
134
  <DomainsLoader actions="create_business_concept" />
130
135
  <ConceptCrumbs conceptAction="concepts.actions.create" />
131
- <TemplatesLoader scope="bg" />
132
- {templatesLoaded && <ConceptForm />}
136
+ <ConceptForm />
133
137
  </>
134
138
  )}
135
139
  />
@@ -176,13 +180,13 @@ export const ConceptRoutes = ({ concept, conceptLoaded, templatesLoaded }) => {
176
180
  ConceptRoutes.propTypes = {
177
181
  concept: PropTypes.object,
178
182
  conceptLoaded: PropTypes.bool,
179
- templatesLoaded: PropTypes.bool
183
+ templatesLoaded: PropTypes.bool,
180
184
  };
181
185
 
182
186
  const mapStateToProps = ({ concept, templatesLoading, templates }) => ({
183
187
  conceptLoaded: !_.isEmpty(concept),
184
188
  templatesLoaded: !templatesLoading && !_.isEmpty(templates),
185
- concept
189
+ concept,
186
190
  });
187
191
 
188
192
  export default connect(mapStateToProps)(ConceptRoutes);
@@ -211,7 +211,7 @@ const mapStateToProps = ({
211
211
  }) => {
212
212
  const concept = _.head(concepts);
213
213
  const templateId =
214
- templates && concept && concept.type
214
+ templates && concept?.type
215
215
  ? _.flow(_.find(_.propEq("name", concept.type)), _.prop("id"))(templates)
216
216
  : null;
217
217
  return {
@@ -61,7 +61,7 @@ export const SharedToForm = ({
61
61
  disabled={!isDirty || !isValid}
62
62
  loading={saving}
63
63
  primary
64
- content={formatMessage({ id: "share.actions.submit" })}
64
+ content={formatMessage({ id: "actions.share" })}
65
65
  />
66
66
  </div>
67
67
  </Form>