@truedat/df 4.56.8 → 4.58.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.58.0] 2022-11-15
4
+
5
+ ### Added
6
+
7
+ - [TD-3919] Add template subscope input
8
+
3
9
  ## [4.54.10] 2022-11-10
4
10
 
5
11
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/df",
3
- "version": "4.56.8",
3
+ "version": "4.58.0",
4
4
  "description": "Truedat Web Data Quality Module",
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": "4.56.8",
37
+ "@truedat/test": "4.58.0",
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",
@@ -87,8 +87,8 @@
87
87
  },
88
88
  "dependencies": {
89
89
  "@apollo/client": "^3.7.1",
90
- "@truedat/auth": "4.56.8",
91
- "@truedat/core": "4.56.8",
90
+ "@truedat/auth": "4.58.0",
91
+ "@truedat/core": "4.58.0",
92
92
  "path-to-regexp": "^1.7.0",
93
93
  "prop-types": "^15.8.1",
94
94
  "react-color": "^2.17.3",
@@ -107,5 +107,5 @@
107
107
  "react-dom": ">= 16.8.6 < 17",
108
108
  "semantic-ui-react": ">= 2.0.3 < 2.2"
109
109
  },
110
- "gitHead": "9bf266eb26e4af0b774560d5a88b0f22325495e0"
110
+ "gitHead": "3987557a127b4e999021e0d7179ad7a6375bfe01"
111
111
  }
@@ -82,6 +82,8 @@ export default {
82
82
  "template.form.newGroup": "Add Group",
83
83
  "template.form.scope": "Scope",
84
84
  "template.form.scope.placeholder": "Select scope...",
85
+ "template.form.subscope": "Subcope",
86
+ "template.form.subscope.placeholder": "Type a subscope...",
85
87
  "template.form.validation.empty_required": "Empty required field",
86
88
  "template.form.validation.name_duplicated": "Name duplicated",
87
89
  "template.form.delete.group": "Group will be deleted. Are you sure?",
@@ -82,6 +82,8 @@ export default {
82
82
  "template.form.newGroup": "Añadir grupo",
83
83
  "template.form.scope": "Scope",
84
84
  "template.form.scope.placeholder": "Seleccionar scope...",
85
+ "template.form.subscope": "Subcope",
86
+ "template.form.subscope.placeholder": "Escriba un subscope...",
85
87
  "template.form.validation.empty_required": "Campo obligatorio vacío",
86
88
  "template.form.validation.name_duplicated": "Nombre duplicado",
87
89
  "template.form.delete.group": "Se va a eliminar el grupo. ¿Estás seguro?",
@@ -1,2 +1,3 @@
1
1
  export { makeGetDropdownOptions } from "./getOptions";
2
2
  export { makeGetApplyTemplate, makeGetTemplate } from "./templates";
3
+ export { getSubscopes } from "./subscopedTemplates";
@@ -0,0 +1,16 @@
1
+ import _ from "lodash/fp";
2
+ import { createSelector } from "reselect";
3
+
4
+ export const getSubscopes = (allTemplates, mainScope) => {
5
+ return _.flow(
6
+ _.filter({ scope: mainScope }),
7
+ _.map("subscope"),
8
+ _.uniq,
9
+ _.filter((el) => el !== null)
10
+ )(allTemplates);
11
+ };
12
+
13
+ export const makeGetSubscopes = (mainScope) =>
14
+ createSelector(_.prop("allTemplates"), (allTemplates) =>
15
+ getSubscopes(allTemplates, mainScope)
16
+ );
@@ -227,6 +227,25 @@ exports[`<Template /> matches the latest snapshot 1`] = `
227
227
  </div>
228
228
  </div>
229
229
  </div>
230
+ <div
231
+ class="disabled six wide field"
232
+ >
233
+ <label>
234
+ Subcope
235
+ </label>
236
+ <div
237
+ class="ui disabled input"
238
+ >
239
+ <input
240
+ disabled=""
241
+ name="subscope"
242
+ placeholder="Type a subscope..."
243
+ tabindex="-1"
244
+ type="text"
245
+ value=""
246
+ />
247
+ </div>
248
+ </div>
230
249
  </div>
231
250
  <div
232
251
  class="ui horizontal divider"
@@ -119,6 +119,17 @@ export const TemplateForm = ({ loading, template, onSubmit, onDelete }) => {
119
119
  options={scopeOptions(formatMessage)}
120
120
  onChange={handleChange}
121
121
  />
122
+ <Form.Input
123
+ name="subscope"
124
+ width={6}
125
+ placeholder={formatMessage({
126
+ id: "template.form.subscope.placeholder",
127
+ })}
128
+ label={formatMessage({ id: "template.form.subscope" })}
129
+ value={editedTemplate?.subscope || ""}
130
+ onChange={handleChange}
131
+ disabled={editedTemplate?.scope !== "bg"}
132
+ />
122
133
  </Form.Group>
123
134
  <Divider horizontal>
124
135
  <Header as="h4">
@@ -19,6 +19,8 @@ const messages = {
19
19
  "template.form.newGroup": "template.form.newGroup",
20
20
  "template.form.scope": "template.form.scope",
21
21
  "template.form.scope.placeholder": "template.form.scope.placeholder",
22
+ "template.form.subscope": "template.form.subscope",
23
+ "template.form.subscope.placeholder": "template.form.subscope.placeholder",
22
24
  "template.scope.bg": "bg",
23
25
  "template.scope.dd": "dd",
24
26
  "template.scope.dq": "dq",
@@ -187,6 +187,23 @@ exports[`<TemplateForm /> matches the latest snapshot (loading) 1`] = `
187
187
  </div>
188
188
  </div>
189
189
  </div>
190
+ <div
191
+ class="six wide field"
192
+ >
193
+ <label>
194
+ template.form.subscope
195
+ </label>
196
+ <div
197
+ class="ui input"
198
+ >
199
+ <input
200
+ name="subscope"
201
+ placeholder="template.form.subscope.placeholder"
202
+ type="text"
203
+ value=""
204
+ />
205
+ </div>
206
+ </div>
190
207
  </div>
191
208
  <div
192
209
  class="ui horizontal divider"
@@ -433,6 +450,23 @@ exports[`<TemplateForm /> matches the latest snapshot 1`] = `
433
450
  </div>
434
451
  </div>
435
452
  </div>
453
+ <div
454
+ class="six wide field"
455
+ >
456
+ <label>
457
+ template.form.subscope
458
+ </label>
459
+ <div
460
+ class="ui input"
461
+ >
462
+ <input
463
+ name="subscope"
464
+ placeholder="template.form.subscope.placeholder"
465
+ type="text"
466
+ value=""
467
+ />
468
+ </div>
469
+ </div>
436
470
  </div>
437
471
  <div
438
472
  class="ui horizontal divider"
@@ -0,0 +1,47 @@
1
+ import { clearTemplates, fetchTemplates } from "../../routines";
2
+ import { allTemplates } from "..";
3
+
4
+ const fooState = { foo: "bar" };
5
+
6
+ describe("reducers: templates", () => {
7
+ const initialState = [];
8
+
9
+ it("should provide the initial state", () => {
10
+ expect(allTemplates(undefined, {})).toEqual(initialState);
11
+ });
12
+
13
+ it("should handle the fetchTemplates.TRIGGER action", () => {
14
+ expect(allTemplates(fooState, { type: fetchTemplates.TRIGGER })).toEqual(
15
+ initialState
16
+ );
17
+ });
18
+
19
+ it("should ignore the clearTemplates.TRIGGER action", () => {
20
+ expect(allTemplates(fooState, { type: clearTemplates.TRIGGER })).toEqual(
21
+ fooState
22
+ );
23
+ });
24
+
25
+ it("should ignore fetchTemplates.SUCCESS action with payload.scope", () => {
26
+ expect(
27
+ allTemplates(fooState, {
28
+ type: fetchTemplates.SUCCESS,
29
+ payload: { scope: "dd", data: [] },
30
+ })
31
+ ).toEqual(fooState);
32
+ });
33
+
34
+ it("should handle fetchTemplates.SUCCESS action with undefined payload.scope (i.e., all scopes requested)", () => {
35
+ const templates = [{ id: 1, name: "Template 1" }];
36
+ expect(
37
+ allTemplates(fooState, {
38
+ type: fetchTemplates.SUCCESS,
39
+ payload: { data: templates },
40
+ })
41
+ ).toEqual(templates);
42
+ });
43
+
44
+ it("should ignore unknown actions", () => {
45
+ expect(allTemplates(fooState, { type: "FOO" })).toBe(fooState);
46
+ });
47
+ });
@@ -10,7 +10,7 @@ describe("reducers: templates", () => {
10
10
  expect(templates(undefined, {})).toEqual(initialState);
11
11
  });
12
12
 
13
- it("should handle the clearConcept.TRIGGER action", () => {
13
+ it("should handle the clearTemplates.TRIGGER action", () => {
14
14
  expect(templates(fooState, { type: clearTemplates.TRIGGER })).toEqual(
15
15
  initialState
16
16
  );
@@ -27,7 +27,7 @@ describe("reducers: templates", () => {
27
27
  expect(
28
28
  templates(fooState, {
29
29
  type: fetchTemplates.SUCCESS,
30
- payload: { data }
30
+ payload: { data },
31
31
  })
32
32
  ).toEqual(data);
33
33
  });
@@ -0,0 +1,18 @@
1
+ import { fetchTemplates } from "../routines";
2
+
3
+ const initialState = [];
4
+
5
+ export const allTemplates = (state = initialState, { type, payload }) => {
6
+ switch (type) {
7
+ // GlossaryMenu is always present, so this state should always be present
8
+ // too. Therefore, no case clearTemplates.TRIGGER returning initialState
9
+ case fetchTemplates.TRIGGER:
10
+ return payload?.scope === undefined ? initialState : state;
11
+ case fetchTemplates.SUCCESS:
12
+ // allTemplates only returns payload.data if all scopes
13
+ // (payload?.scope === undefined) have been requested.
14
+ return payload?.scope === undefined ? payload?.data : state;
15
+ default:
16
+ return state;
17
+ }
18
+ };
@@ -1,3 +1,4 @@
1
+ import { allTemplates } from "./allTemplates";
1
2
  import { selectedTemplate } from "./selectedTemplate";
2
3
  import { template } from "./template";
3
4
  import { templateDeleting } from "./templateDeleting";
@@ -8,6 +9,7 @@ import { templatesLoading } from "./templatesLoading";
8
9
  import { templateLoading } from "./templateLoading";
9
10
 
10
11
  export {
12
+ allTemplates,
11
13
  selectedTemplate,
12
14
  template,
13
15
  templateDeleting,
@@ -15,5 +17,5 @@ export {
15
17
  templateSaving,
16
18
  templates,
17
19
  templatesLoading,
18
- templateLoading
20
+ templateLoading,
19
21
  };
@@ -1,4 +1,4 @@
1
- import { call, put, takeLatest } from "redux-saga/effects";
1
+ import { call, put, takeEvery } from "redux-saga/effects";
2
2
  import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
3
3
  import { fetchTemplates } from "../routines";
4
4
  import { API_TEMPLATES } from "../api";
@@ -24,5 +24,7 @@ export function* fetchTemplatesSaga({ payload }) {
24
24
  }
25
25
 
26
26
  export function* fetchTemplatesRequestSaga() {
27
- yield takeLatest(fetchTemplates.TRIGGER, fetchTemplatesSaga);
27
+ // Several TenplatesLoader are rendered concurrently, so process all
28
+ // fetchTemplageSaga sagas using takeEvery instead of takeLatest
29
+ yield takeEvery(fetchTemplates.TRIGGER, fetchTemplatesSaga);
28
30
  }