@truedat/df 4.47.2 → 4.47.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/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## [4.46.2] 2022-06-16
3
+ ## [4.47.3] 2022-06-28
4
+
5
+ ### Added
6
+
7
+ - [TD-4412] Created `user_group` dynamic field type
4
8
 
5
9
  ### Changed
6
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/df",
3
- "version": "4.47.2",
3
+ "version": "4.47.3",
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.4",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "4.47.2",
37
+ "@truedat/test": "4.47.3",
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
  },
89
89
  "dependencies": {
90
- "@truedat/auth": "4.47.2",
91
- "@truedat/core": "4.47.2",
90
+ "@truedat/auth": "4.47.3",
91
+ "@truedat/core": "4.47.3",
92
92
  "axios": "^0.19.2",
93
93
  "path-to-regexp": "^1.7.0",
94
94
  "prop-types": "^15.8.1",
@@ -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": "53cb62b57d41745cfcd4c0b90154a6cfcd168534"
110
+ "gitHead": "f96f532d27f7104fbc50b6b0539593cec0d2039d"
111
111
  }
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import PropTypes from "prop-types";
3
- import { Label, Table } from "semantic-ui-react";
3
+ import { Icon, Label, Table } from "semantic-ui-react";
4
4
  import { SafeLink, RichTextEditor } from "@truedat/core/components";
5
5
  import DomainPreview from "./widgets/DomainPreview";
6
6
  import FieldGroupCopy from "./FieldGroupCopy";
@@ -49,6 +49,18 @@ export const FieldViewerValue = ({ value, type, multiple, values, widget }) => {
49
49
  return <DomainPreview value={value} />;
50
50
  case "copy":
51
51
  return <FieldGroupCopy value={value} />;
52
+ case "user_group":
53
+ const [type, name] = value.split(":");
54
+ return multiple ? (
55
+ <Label>
56
+ <Icon name={type} />
57
+ {name}
58
+ </Label>
59
+ ) : (
60
+ <>
61
+ <Icon name={type} /> {name}
62
+ </>
63
+ );
52
64
  case "string":
53
65
  case "user":
54
66
  case "number":
@@ -45,6 +45,10 @@ describe("<FieldViewerValue />", () => {
45
45
  value: "user",
46
46
  type: "user",
47
47
  },
48
+ {
49
+ value: "group:group_name",
50
+ type: "user_group",
51
+ },
48
52
  {
49
53
  value: "number",
50
54
  type: "number",
@@ -959,3 +959,78 @@ Object {
959
959
  "unmount": [Function],
960
960
  }
961
961
  `;
962
+
963
+ exports[`<FieldViewerValue /> matches the latest snapshot with type: user_group 1`] = `
964
+ Object {
965
+ "asFragment": [Function],
966
+ "baseElement": <body>
967
+ <div>
968
+ <i
969
+ aria-hidden="true"
970
+ class="group icon"
971
+ />
972
+
973
+ group_name
974
+ </div>
975
+ </body>,
976
+ "container": <div>
977
+ <i
978
+ aria-hidden="true"
979
+ class="group icon"
980
+ />
981
+
982
+ group_name
983
+ </div>,
984
+ "debug": [Function],
985
+ "findAllByAltText": [Function],
986
+ "findAllByDisplayValue": [Function],
987
+ "findAllByLabelText": [Function],
988
+ "findAllByPlaceholderText": [Function],
989
+ "findAllByRole": [Function],
990
+ "findAllByTestId": [Function],
991
+ "findAllByText": [Function],
992
+ "findAllByTitle": [Function],
993
+ "findByAltText": [Function],
994
+ "findByDisplayValue": [Function],
995
+ "findByLabelText": [Function],
996
+ "findByPlaceholderText": [Function],
997
+ "findByRole": [Function],
998
+ "findByTestId": [Function],
999
+ "findByText": [Function],
1000
+ "findByTitle": [Function],
1001
+ "getAllByAltText": [Function],
1002
+ "getAllByDisplayValue": [Function],
1003
+ "getAllByLabelText": [Function],
1004
+ "getAllByPlaceholderText": [Function],
1005
+ "getAllByRole": [Function],
1006
+ "getAllByTestId": [Function],
1007
+ "getAllByText": [Function],
1008
+ "getAllByTitle": [Function],
1009
+ "getByAltText": [Function],
1010
+ "getByDisplayValue": [Function],
1011
+ "getByLabelText": [Function],
1012
+ "getByPlaceholderText": [Function],
1013
+ "getByRole": [Function],
1014
+ "getByTestId": [Function],
1015
+ "getByText": [Function],
1016
+ "getByTitle": [Function],
1017
+ "queryAllByAltText": [Function],
1018
+ "queryAllByDisplayValue": [Function],
1019
+ "queryAllByLabelText": [Function],
1020
+ "queryAllByPlaceholderText": [Function],
1021
+ "queryAllByRole": [Function],
1022
+ "queryAllByTestId": [Function],
1023
+ "queryAllByText": [Function],
1024
+ "queryAllByTitle": [Function],
1025
+ "queryByAltText": [Function],
1026
+ "queryByDisplayValue": [Function],
1027
+ "queryByLabelText": [Function],
1028
+ "queryByPlaceholderText": [Function],
1029
+ "queryByRole": [Function],
1030
+ "queryByTestId": [Function],
1031
+ "queryByText": [Function],
1032
+ "queryByTitle": [Function],
1033
+ "rerender": [Function],
1034
+ "unmount": [Function],
1035
+ }
1036
+ `;
@@ -39,6 +39,7 @@ export default {
39
39
  "template.field.type.string": "String",
40
40
  "template.field.type.url": "Url",
41
41
  "template.field.type.user": "User",
42
+ "template.field.type.user_group": "User or Group",
42
43
  "template.field.type.table": "Table",
43
44
  "template.field.type.image": "Image",
44
45
  "template.field.type.integer": "Integer",
@@ -59,6 +60,7 @@ export default {
59
60
  "template.field.values.fixed_tuple": "Key/Value list",
60
61
  "template.field.values.none": "Free text",
61
62
  "template.field.values.role_users": "Users of a Role",
63
+ "template.field.values.role_groups": "Users or Groups of a Role",
62
64
  "template.field.values.switch": "Dependent on other field",
63
65
  "template.field.values.switch_field": "In funtion of the field",
64
66
  "template.field.values.table_columns": "Columns of the table",
@@ -39,6 +39,7 @@ export default {
39
39
  "template.field.type.string": "Cadena de Texto",
40
40
  "template.field.type.url": "Enlace",
41
41
  "template.field.type.user": "Usuario",
42
+ "template.field.type.user_group": "Usuario o Grupo",
42
43
  "template.field.type.table": "Tabla",
43
44
  "template.field.type.image": "Imagen",
44
45
  "template.field.type.integer": "Entero",
@@ -59,6 +60,7 @@ export default {
59
60
  "template.field.values.fixed_tuple": "Lista de código/descripción",
60
61
  "template.field.values.none": "Texto libre",
61
62
  "template.field.values.role_users": "Usuarios de un Role",
63
+ "template.field.values.role_groups": "Usuarios o grupos de un Role",
62
64
  "template.field.values.switch": "En función de otro campo",
63
65
  "template.field.values.switch_field": "En función del campo",
64
66
  "template.field.values.table_columns": "Columnas de la tabla",
@@ -61,6 +61,15 @@ export const ValuesSelector = ({
61
61
  onChange={(e, { value }) => onValueChange(value)}
62
62
  />
63
63
  )}
64
+ {type === "role_groups" && (
65
+ <Form.Input
66
+ value={values || ""}
67
+ placeholder={formatMessage({
68
+ id: "template.field.values.role_groups",
69
+ })}
70
+ onChange={(e, { value }) => onValueChange(value)}
71
+ />
72
+ )}
64
73
  </>
65
74
  );
66
75
  };
@@ -55,4 +55,14 @@ describe("<ValuesSelector />", () => {
55
55
  value: { role_users: "some_role" },
56
56
  });
57
57
  });
58
+
59
+ it("changes value on onChange with role_groups", () => {
60
+ const wrapper = shallow(<ValuesSelector {...props} type={"role_groups"} />);
61
+ const input = wrapper.find("FormInput");
62
+ input.simulate("change", null, { value: "some_role" });
63
+ expect(onChange).toBeCalledWith(null, {
64
+ name,
65
+ value: { role_groups: "some_role" },
66
+ });
67
+ });
58
68
  });
@@ -1201,6 +1201,11 @@ exports[`<FieldForm /> renders ValuesField and manages onChange 1`] = `
1201
1201
  "text": "template.field.type.user",
1202
1202
  "value": "user",
1203
1203
  },
1204
+ Object {
1205
+ "key": "user_group",
1206
+ "text": "template.field.type.user_group",
1207
+ "value": "user_group",
1208
+ },
1204
1209
  ]
1205
1210
  }
1206
1211
  required={true}
@@ -6,6 +6,7 @@ const valueTypes = [
6
6
  { id: "template.field.values.fixed_tuple", value: "fixed_tuple" },
7
7
  { id: "template.field.values.switch", value: "switch" },
8
8
  { id: "template.field.values.role_users", value: "role_users" },
9
+ { id: "template.field.values.role_groups", value: "role_groups" },
9
10
  { id: "template.field.values.table_columns", value: "table_columns" },
10
11
  { id: "template.field.values.file_types", value: "file_types" },
11
12
  { id: "template.field.values.domain", value: "domain" },
@@ -14,6 +15,7 @@ const valueTypes = [
14
15
  const selectableValues = {
15
16
  string: ["domain", "fixed", "fixed_tuple", "switch"],
16
17
  user: ["role_users"],
18
+ user_group: ["role_groups"],
17
19
  };
18
20
 
19
21
  const eligibleValues = {
@@ -45,7 +47,8 @@ export const defaultValue = (type, fieldType) =>
45
47
 
46
48
  export const valuesSelector = (type) =>
47
49
  type &&
48
- (listFormat(type) || ["domain", "switch", "role_users"].includes(type));
50
+ (listFormat(type) ||
51
+ ["domain", "switch", "role_users", "role_groups"].includes(type));
49
52
 
50
53
  export const valueSegment = (values, type, fieldType) =>
51
54
  _.size(values) > 1 || valuesSelector(type) || defaultValue(type, fieldType);
@@ -61,7 +61,7 @@ export const WIDGETS = [
61
61
  text: "Dropdown",
62
62
  icon: "arrow down",
63
63
  cardinalities: ["?", "1", "*", "+"],
64
- types: ["string", "system", "domain", "user"],
64
+ types: ["string", "system", "domain", "user", "user_group"],
65
65
  },
66
66
  {
67
67
  key: "radio",
@@ -69,7 +69,7 @@ export const WIDGETS = [
69
69
  text: "Radio",
70
70
  icon: "radio",
71
71
  cardinalities: ["?", "1"],
72
- types: ["string", "user"],
72
+ types: ["string", "user", "user_group"],
73
73
  },
74
74
  {
75
75
  key: "checkbox",
@@ -77,7 +77,7 @@ export const WIDGETS = [
77
77
  text: "Checkbox",
78
78
  icon: "check square outline",
79
79
  cardinalities: ["*", "+"],
80
- types: ["string", "user"],
80
+ types: ["string", "user", "user_group"],
81
81
  },
82
82
  {
83
83
  key: "pair_list",
@@ -1,5 +1,17 @@
1
1
  import _ from "lodash/fp";
2
2
 
3
+ const userGroupValues = (field) =>
4
+ _.concat(
5
+ _.flow(
6
+ _.get("processed_users"),
7
+ _.map((name) => `user:${name}`)
8
+ )(field),
9
+ _.flow(
10
+ _.get("processed_groups"),
11
+ _.map((name) => `group:${name}`)
12
+ )(field)
13
+ );
14
+
3
15
  export const validValues = _.flow(
4
16
  _.filter(
5
17
  _.overSome([_.has("values.fixed"), _.has("values.processed_users")])
@@ -9,6 +21,7 @@ export const validValues = _.flow(
9
21
  name,
10
22
  _.cond([
11
23
  [_.has("fixed"), _.pathOr([], "fixed")],
24
+ [_.has("processed_groups"), userGroupValues],
12
25
  [_.has("processed_users"), _.pathOr([], "processed_users")],
13
26
  ])(values),
14
27
  ]),
@@ -19,6 +19,25 @@ const parseFieldOptions = (content, selectedDomain) => (field) => {
19
19
  ]),
20
20
  stringToValueTextList
21
21
  );
22
+ const parseRoleGroups = (values) =>
23
+ _.concat(
24
+ _.flow(
25
+ _.get("processed_users"),
26
+ _.map((name) => ({
27
+ value: `user:${name}`,
28
+ text: name,
29
+ icon: "user",
30
+ }))
31
+ )(values),
32
+ _.flow(
33
+ _.get("processed_groups"),
34
+ _.map((name) => ({
35
+ value: `group:${name}`,
36
+ text: name,
37
+ icon: "group",
38
+ }))
39
+ )(values)
40
+ );
22
41
  const parseDomain = _.flow(
23
42
  _.get("domain"),
24
43
  _.propOr([], _.toString(selectedDomain?.id)),
@@ -32,6 +51,7 @@ const parseFieldOptions = (content, selectedDomain) => (field) => {
32
51
  [_.has("fixed"), parseFixed],
33
52
  [_.has("fixed_tuple"), _.get("fixed_tuple")],
34
53
  [_.has("role_users"), parseRoleUsers],
54
+ [_.has("role_groups"), parseRoleGroups],
35
55
  [_.has("domain"), parseDomain],
36
56
  ])
37
57
  )(field);